Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/memory-failure: refactor log format in soft offline code

Patch series "Userspace controls soft-offline pages", v6.

Correctable memory errors are very common on servers with large amount of
memory, and are corrected by ECC, but with two pain points to users:

1. Correction usually happens on the fly and adds latency overhead
2. Not-fully-proved theory states excessive correctable memory
errors can develop into uncorrectable memory error.

Soft offline is kernel's additional solution for memory pages having
(excessive) corrected memory errors. Impacted page is migrated to healthy
page if it is in use, then the original page is discarded for any future
use.

The actual policy on whether (and when) to soft offline should be
maintained by userspace, especially in case of an 1G HugeTLB page.
Soft-offline dissolves the HugeTLB page, either in-use or free, into
chunks of 4K pages, reducing HugeTLB pool capacity by 1 hugepage. If
userspace has not acknowledged such behavior, it may be surprised when
later mmap hugepages MAP_FAILED due to lack of hugepages. In case of a
transparent hugepage, it will be split into 4K pages as well; userspace
will stop enjoying the transparent performance.

In addition, discarding the entire 1G HugeTLB page only because of
corrected memory errors sounds very costly and kernel better not doing
under the hood. But today there are at least 2 such cases:

1. GHES driver sees both GHES_SEV_CORRECTED and
CPER_SEC_ERROR_THRESHOLD_EXCEEDED after parsing CPER.
2. RAS Correctable Errors Collector counts correctable errors per
PFN and when the counter for a PFN reaches threshold

In both cases, userspace has no control of the soft offline performed by
kernel's memory failure recovery.

This patch series give userspace the control of softofflining any page:
kernel only soft offlines raw page / transparent hugepage / HugeTLB
hugepage if userspace has agreed to. The interface to userspace is a new
sysctl called enable_soft_offline under /proc/sys/vm. By default
enable_soft_line is 1 to preserve existing behavior in kernel.


This patch (of 4):

Logs from soft_offline_page and soft_offline_in_use_page have different
formats than majority of the memory failure code:

"Memory failure: 0x${pfn}: ${lower_case_message}"

Convert them to the following format:

"Soft offline: 0x${pfn}: ${lower_case_message}"

No functional change in this commit.

Link: https://lkml.kernel.org/r/20240626050818.2277273-1-jiaqiyan@google.com
Link: https://lkml.kernel.org/r/20240626050818.2277273-2-jiaqiyan@google.com
Signed-off-by: Jiaqi Yan <jiaqiyan@google.com>
Acked-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Lance Yang <ioworker0@gmail.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Frank van der Linden <fvdl@google.com>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Jiaqi Yan and committed by
Andrew Morton
865319f7 c2fad56b

+9 -6
+9 -6
mm/memory-failure.c
··· 2640 2640 } 2641 2641 EXPORT_SYMBOL(unpoison_memory); 2642 2642 2643 + #undef pr_fmt 2644 + #define pr_fmt(fmt) "Soft offline: " fmt 2645 + 2643 2646 static bool mf_isolate_folio(struct folio *folio, struct list_head *pagelist) 2644 2647 { 2645 2648 bool isolated = false; ··· 2698 2695 2699 2696 if (!huge && folio_test_large(folio)) { 2700 2697 if (try_to_split_thp_page(page, true)) { 2701 - pr_info("soft offline: %#lx: thp split failed\n", pfn); 2698 + pr_info("%#lx: thp split failed\n", pfn); 2702 2699 return -EBUSY; 2703 2700 } 2704 2701 folio = page_folio(page); ··· 2710 2707 if (PageHWPoison(page)) { 2711 2708 folio_unlock(folio); 2712 2709 folio_put(folio); 2713 - pr_info("soft offline: %#lx page already poisoned\n", pfn); 2710 + pr_info("%#lx: page already poisoned\n", pfn); 2714 2711 return 0; 2715 2712 } 2716 2713 ··· 2723 2720 folio_unlock(folio); 2724 2721 2725 2722 if (ret) { 2726 - pr_info("soft_offline: %#lx: invalidated\n", pfn); 2723 + pr_info("%#lx: invalidated\n", pfn); 2727 2724 page_handle_poison(page, false, true); 2728 2725 return 0; 2729 2726 } ··· 2740 2737 if (!list_empty(&pagelist)) 2741 2738 putback_movable_pages(&pagelist); 2742 2739 2743 - pr_info("soft offline: %#lx: %s migration failed %ld, type %pGp\n", 2740 + pr_info("%#lx: %s migration failed %ld, type %pGp\n", 2744 2741 pfn, msg_page[huge], ret, &page->flags); 2745 2742 if (ret > 0) 2746 2743 ret = -EBUSY; 2747 2744 } 2748 2745 } else { 2749 - pr_info("soft offline: %#lx: %s isolation failed, page count %d, type %pGp\n", 2746 + pr_info("%#lx: %s isolation failed, page count %d, type %pGp\n", 2750 2747 pfn, msg_page[huge], page_count(page), &page->flags); 2751 2748 ret = -EBUSY; 2752 2749 } ··· 2798 2795 mutex_lock(&mf_mutex); 2799 2796 2800 2797 if (PageHWPoison(page)) { 2801 - pr_info("%s: %#lx page already poisoned\n", __func__, pfn); 2798 + pr_info("%#lx: page already poisoned\n", pfn); 2802 2799 put_ref_page(pfn, flags); 2803 2800 mutex_unlock(&mf_mutex); 2804 2801 return 0;