Userspace controls soft-offline pages
Subsystems (6)
v3 cover Userspace controls soft-offline pages
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.
Changelog
v2 => v3:
* incorporate feedbacks from Miaohe Lin <[email protected]>, Lance Yang <[email protected]>, Oscar Salvador <[email protected]>, and David Rientjes <[email protected]>.
* release potential refcount if enable_soft_offline is 0.
* soft_offline_page() returns EOPNOTSUPP if enable_soft_offline is 0.
* refactor hugetlb-soft-offline.c, for example, introduce test_soft_offline_common to reduce repeated code.
* rewrite enable_soft_offline's documentation, adds more details about the cost of soft-offline for transparent and hugetlb hugepages, and components that are impacted when enable_soft_offline becomes 0.
* fix typos in commit messages.
* v3 is still based on commit 83a7eefedc9b ("Linux 6.10-rc3").
v1 => v2:
* incorporate feedbacks from both Miaohe Lin <[email protected]> and Jane Chu <[email protected]>.
* make the switch to control all pages, instead of HugeTLB specific.
* change the API from /sys/kernel/mm/hugepages/hugepages-${size}kB/softoffline_corrected_errors to /proc/sys/vm/enable_soft_offline.
* minor update to test code.
* update documentation of the user control API.
* v2 is based on commit 83a7eefedc9b ("Linux 6.10-rc3").
Jiaqi Yan (3):
mm/memory-failure: userspace controls soft-offlining pages selftest/mm: test enable_soft_offline behaviors
docs: mm: add enable_soft_offline sysctl
Documentation/admin-guide/sysctl/vm.rst | 33 +++ mm/memory-failure.c | 22 +- tools/testing/selftests/mm/.gitignore | 1 + tools/testing/selftests/mm/Makefile | 1 + .../selftests/mm/hugetlb-soft-offline.c | 229 ++++++++++++++++++ tools/testing/selftests/mm/run_vmtests.sh | 4 + 6 files changed, 288 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/mm/hugetlb-soft-offline.c
Signature · 1 line
2.45.2.627.g7a2c4fd464-goog
PATCH v3 1/3 mm/memory-failure: userspace controls soft-offlining pages
Correctable memory errors are very common on servers with large amount of memory, and are corrected by ECC. Soft offline is kernel's additional recovery handling for memory pages having (excessive) corrected memory errors. Impacted page is migrated to a healthy page if it is in-use; 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 failed to mmap hugepages 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 doing so:
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 commit gives 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 at /proc/sys/vm/enable_soft_offline. By default its value is set to 1 to preserve existing behavior in kernel. When set to 0, soft-offline (e.g. MADV_SOFT_OFFLINE) will fail with EOPNOTSUPP.
--- mm/memory-failure.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
mm/memory-failure.c +20 -2
@@ -68,6 +68,8 @@ static int sysctl_memory_failure_early_kill __read_mostly;static int sysctl_memory_failure_recovery__read_mostly =1 ; +static int sysctl_enable_soft_offline__read_mostly =1 ; +atomic_long_t num_poisoned_pages__read_mostly =ATOMIC_LONG_INIT (0 );static bool hw_memory_failure__read_mostly = false;
@@ -141,6 +143,15 @@ static struct ctl_table memory_failure_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, + { + .procname = "enable_soft_offline", + .data = &sysctl_enable_soft_offline, + .maxlen = sizeof(sysctl_enable_soft_offline), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + } };/*
@@ -2746,8 +2757,9 @@ static int soft_offline_in_use_page(struct page *page)* @pfn: pfn to soft-offline * @flags: flags. Same as memory_failure(). * -* Returns 0 on success -* -EOPNOTSUPP for hwpoison_filter() filtered the error event +* Returns 0 on success, +* -EOPNOTSUPP for hwpoison_filter() filtered the error event, +* -EOPNOTSUPP if disabled by /proc/sys/vm/enable_soft_offline, * < 0 otherwise negated errno. * * Soft offline a page, by migration or invalidation,
@@ -2783,6 +2795,12 @@ int soft_offline_page(unsigned long pfn, int flags)return -EIO ; } +if (!sysctl_enable_soft_offline) { +pr_info ("%#lx: OS-wide disabled\n" , pfn); +put_ref_page (pfn, flags); +return -EOPNOTSUPP ; + } +mutex_lock (&mf_mutex);if (PageHWPoison (page)) {
Signature · 1 line
2.45.2.627.g7a2c4fd464-goog
Andrew Morton
maintainerRe: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
Quoted 26 lines · On Mon, 17 Jun 2024 17:05:43 +0000 Jiaqi Yan <[email protected]> wrote:
Correctable memory errors are very common on servers with large amount of memory, and are corrected by ECC. Soft offline is kernel's additional recovery handling for memory pages having (excessive) corrected memory errors. Impacted page is migrated to a healthy page if it is in-use; 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 failed to mmap hugepages 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 doing so:
1. GHES driver sees bothGHES_SEV_CORRECTEDandCPER_SEC_ERROR_THRESHOLD_EXCEEDEDafter 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.
Quoted 7 lines
This commit gives 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 at/proc/sys/vm/enable_soft_offline. By default its value is set to 1 to preserve existing behavior in kernel. When set to 0, soft-offline (e.g.MADV_SOFT_OFFLINE) will fail with EOPNOTSUPP.
Seems reasonable. A very simple patch.
Is there sufficient instrumentation in place for userspace to be able to know that these errors are occurring? To be able to generally monitor the machine's health?
mm/memory-failure.c int soft_offline_page(unsigned long pfn, int flags) · line 2799
Quoted 6 lines
mm/memory-failure.c +2
-0@@ -2783,6 +2795,12 @@ int soft_offline_page(unsigned long pfn, int flags)return -EIO ; } +if (!sysctl_enable_soft_offline) { +pr_info ("%#lx: OS-wide disabled\n" , pfn);
This doesn't seem a very good message. There's no indication that it comes from the memory failure code at all. If the sysadmin sees this come out in the kernels logs, he/she will have to grep the kernel sources just to figure out where the message came from. Perhaps we can be more helpful here..
Quoted 6 lines
mm/memory-failure.c +4
-0+put_ref_page (pfn, flags); +return -EOPNOTSUPP ; + } +mutex_lock (&mf_mutex);
Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
Quoted 37 lines · Andrew Morton
Quoted 26 lines · On Mon, 17 Jun 2024 17:05:43 +0000 Jiaqi Yan <[email protected]> wrote:
Correctable memory errors are very common on servers with large amount of memory, and are corrected by ECC. Soft offline is kernel's additional recovery handling for memory pages having (excessive) corrected memory errors. Impacted page is migrated to a healthy page if it is in-use; 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 failed to mmap hugepages 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 doing so:
1. GHES driver sees bothGHES_SEV_CORRECTEDandCPER_SEC_ERROR_THRESHOLD_EXCEEDEDafter 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.Quoted 7 lines
This commit gives 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 at/proc/sys/vm/enable_soft_offline. By default its value is set to 1 to preserve existing behavior in kernel. When set to 0, soft-offline (e.g.MADV_SOFT_OFFLINE) will fail with EOPNOTSUPP.
Quoted 1 line
Seems reasonable. A very simple patch.
Thanks for taking a look, Andrew!
Quoted 4 lines
Is there sufficient instrumentation in place for userspace to be able to know that these errors are occurring? To be able to generally monitor the machine's health?
For corrected memory errors, in general they are available in kernel logs. On X86 Machine Check handling will log unparsed MCs (one needs to read mci_status to know what exactly the error is). On ARM, GHES logs parsed CPER (already containing error type and error severity). The shortcoming is logs are rate limited. So in a burst of corrected memory errors the user may not be able to figure out exactly how many there were.
For uncorrectable memory errors, num_poisoned_pages is a reliable counter.
Quoted 5 lines
Quoted 5 lines
mm/memory-failure.c +0
-0@@ -2783,6 +2795,12 @@ int soft_offline_page(unsigned long pfn, int flags)return -EIO ; }
Quoted 8 lines
mm/memory-failure.c int soft_offline_page(unsigned long pfn, int flags) · line 2799
Quoted 2 lines
mm/memory-failure.c +2
-0+if (!sysctl_enable_soft_offline) { +pr_info ("%#lx: OS-wide disabled\n" , pfn);This doesn't seem a very good message. There's no indication that it comes from the memory failure code at all. If the sysadmin sees this come out in the kernels logs, he/she will have to grep the kernel sources just to figure out where the message came from. Perhaps we can be more helpful here..
For sure. I took it for granted that any pr_info will have the "Memory
failure: " prefix, but now realize there is a #undef pr_fmt + #define pr_fmt(fmt) "" fmt just above unpoison_memory.
I propose to do #define pr_fmt(fmt) "Soft offline: " fmt above mf_isolate_folio, so that any soft-offline related code generates logs with the same following format:
"Soft offline: 0x${pfn}: ${detailed_message}"If everyone thinks this is reasonable, in v4 I can insert a new commit to make the log formats unified.
Quoted 9 lines
Quoted 7 lines
mm/memory-failure.c +4
-0+put_ref_page (pfn, flags); +return -EOPNOTSUPP ; + } +mutex_lock (&mf_mutex);
Miaohe Lin
maintainerRe: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
Quoted 76 lines · Jiaqi Yan
Quoted 37 lines · Andrew Morton
Quoted 26 lines · On Mon, 17 Jun 2024 17:05:43 +0000 Jiaqi Yan <[email protected]> wrote:
Correctable memory errors are very common on servers with large amount of memory, and are corrected by ECC. Soft offline is kernel's additional recovery handling for memory pages having (excessive) corrected memory errors. Impacted page is migrated to a healthy page if it is in-use; 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 failed to mmap hugepages 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 doing so:
1. GHES driver sees bothGHES_SEV_CORRECTEDandCPER_SEC_ERROR_THRESHOLD_EXCEEDEDafter 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.Quoted 7 lines
This commit gives 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 at/proc/sys/vm/enable_soft_offline. By default its value is set to 1 to preserve existing behavior in kernel. When set to 0, soft-offline (e.g.MADV_SOFT_OFFLINE) will fail with EOPNOTSUPP.Quoted 1 line
Seems reasonable. A very simple patch.
Thanks for taking a look, Andrew!
Quoted 4 lines
Is there sufficient instrumentation in place for userspace to be able to know that these errors are occurring? To be able to generally monitor the machine's health?
For corrected memory errors, in general they are available in kernel logs. On X86 Machine Check handling will log unparsed MCs (one needs to read
mci_statusto know what exactly the error is). On ARM, GHES logs parsed CPER (already containing error type and error severity). The shortcoming is logs are rate limited. So in a burst of corrected memory errors the user may not be able to figure out exactly how many there were.For uncorrectable memory errors,
num_poisoned_pagesis a reliable counter.Quoted 5 lines
Quoted 5 lines
mm/memory-failure.c +0
-0@@ -2783,6 +2795,12 @@ int soft_offline_page(unsigned long pfn, int flags)return -EIO ; }Quoted 8 lines
mm/memory-failure.c int soft_offline_page(unsigned long pfn, int flags) · line 2799
Quoted 2 lines
mm/memory-failure.c +2
-0+if (!sysctl_enable_soft_offline) { +pr_info ("%#lx: OS-wide disabled\n" , pfn);This doesn't seem a very good message. There's no indication that it comes from the memory failure code at all. If the sysadmin sees this come out in the kernels logs, he/she will have to grep the kernel sources just to figure out where the message came from. Perhaps we can be more helpful here..
For sure. I took it for granted that any
pr_infowill have the "Memory
failure: " prefix, but now realize there is a#undef pr_fmt+#define pr_fmt(fmt) "" fmtjust aboveunpoison_memory.
Quoted 8 lines
I propose to do
#define pr_fmt(fmt) "Soft offline: " fmtabovemf_isolate_folio, so that any soft-offline related code generates logs with the same following format:"Soft offline: 0x${pfn}: ${detailed_message}"If everyone thinks this is reasonable, in v4 I can insert a new commit to make the log formats unified.
This sounds fine to me. And even better, #define pr_fmt(fmt) "Unpoison: " fmt can also be done just above unpoison_memory.
Thanks.
.
Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
Quoted 82 lines · Miaohe Lin
Quoted 80 lines · Jiaqi Yan
Quoted 37 lines · Andrew Morton
Quoted 26 lines · On Mon, 17 Jun 2024 17:05:43 +0000 Jiaqi Yan <[email protected]> wrote:
Correctable memory errors are very common on servers with large amount of memory, and are corrected by ECC. Soft offline is kernel's additional recovery handling for memory pages having (excessive) corrected memory errors. Impacted page is migrated to a healthy page if it is in-use; 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 failed to mmap hugepages 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 doing so:
1. GHES driver sees bothGHES_SEV_CORRECTEDandCPER_SEC_ERROR_THRESHOLD_EXCEEDEDafter 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.Quoted 7 lines
This commit gives 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 at/proc/sys/vm/enable_soft_offline. By default its value is set to 1 to preserve existing behavior in kernel. When set to 0, soft-offline (e.g.MADV_SOFT_OFFLINE) will fail with EOPNOTSUPP.Quoted 1 line
Seems reasonable. A very simple patch.
Thanks for taking a look, Andrew!
Quoted 4 lines
Is there sufficient instrumentation in place for userspace to be able to know that these errors are occurring? To be able to generally monitor the machine's health?
For corrected memory errors, in general they are available in kernel logs. On X86 Machine Check handling will log unparsed MCs (one needs to read
mci_statusto know what exactly the error is). On ARM, GHES logs parsed CPER (already containing error type and error severity). The shortcoming is logs are rate limited. So in a burst of corrected memory errors the user may not be able to figure out exactly how many there were.For uncorrectable memory errors,
num_poisoned_pagesis a reliable counter.Quoted 5 lines
Quoted 5 lines
mm/memory-failure.c +0
-0@@ -2783,6 +2795,12 @@ int soft_offline_page(unsigned long pfn, int flags)return -EIO ; }Quoted 8 lines
mm/memory-failure.c int soft_offline_page(unsigned long pfn, int flags) · line 2799
Quoted 2 lines
mm/memory-failure.c +2
-0+if (!sysctl_enable_soft_offline) { +pr_info ("%#lx: OS-wide disabled\n" , pfn);This doesn't seem a very good message. There's no indication that it comes from the memory failure code at all. If the sysadmin sees this come out in the kernels logs, he/she will have to grep the kernel sources just to figure out where the message came from. Perhaps we can be more helpful here..
For sure. I took it for granted that any
pr_infowill have the "Memory
failure: " prefix, but now realize there is a#undef pr_fmt+#define pr_fmt(fmt) "" fmtjust aboveunpoison_memory.I propose to do
#define pr_fmt(fmt) "Soft offline: " fmtabovemf_isolate_folio, so that any soft-offline related code generates logs with the same following format:
Quoted 7 lines
Quoted 4 lines
"Soft offline: 0x${pfn}: ${detailed_message}"If everyone thinks this is reasonable, in v4 I can insert a new commit to make the log formats unified.
This sounds fine to me. And even better,
#define pr_fmt(fmt) "Unpoison: " fmtcan also be done just aboveunpoison_memory.
Of course. I just sent out a standalone patch for unpoison_memory to you.
Quoted 4 lines
Thanks.
.
Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
In reply to Jiaqi YanQuoted 9 lines · Jiaqi Yan
- * Returns 0 on success
- *-EOPNOTSUPPforhwpoison_filter()filtered the error event
+ * Returns 0 on success,+ * -EOPNOTSUPP for hwpoison_filter() filtered the error event, + * -EOPNOTSUPP if disabled by /proc/sys/vm/enable_soft_offline, * < 0 otherwise negated errno.*
* Soft offline a page, by migration or invalidation,
mm/memory-failure.c int soft_offline_page(unsigned long pfn, int flags) · line 2802
Quoted 8 lines
mm/memory-failure.c +5
-0@@ -2783,6 +2795,12 @@ int soft_offline_page(unsigned long pfn, int flags)return -EIO ; } +if (!sysctl_enable_soft_offline) { +pr_info ("%#lx: OS-wide disabled\n" , pfn); +put_ref_page (pfn, flags); +return -EOPNOTSUPP ; + }
We should not be doing anything if soft_offline is disabled, so this check should be placed upfront, at the very beginning of the function.
Then you can remove the 'put_ref_page' call.
Signature · 2 lines
Oscar Salvador SUSE Labs
Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
Quoted 10 lines · Oscar Salvador
mm/memory-failure.c int soft_offline_page(unsigned long pfn, int flags) · line 2802
Quoted 5 lines · Jiaqi Yan
mm/memory-failure.c +5
-0+if (!sysctl_enable_soft_offline) { +pr_info ("%#lx: OS-wide disabled\n" , pfn); +put_ref_page (pfn, flags); +return -EOPNOTSUPP ; + }We should not be doing anything if
soft_offlineis disabled, so this check should be placed upfront, at the very beginning of the function.
Then you can remove the 'put_ref_page' call.
Also, I would go for a pr_info_once here, as otherwise we can spam the log quite easy.
Signature · 2 lines
Oscar Salvador SUSE Labs
Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
Quoted 9 lines · Oscar Salvador
Quoted 7 lines · Oscar Salvador
Quoted 5 lines · Jiaqi Yan
mm/memory-failure.c +5
-0+if (!sysctl_enable_soft_offline) { +pr_info ("%#lx: OS-wide disabled\n" , pfn); +put_ref_page (pfn, flags); +return -EOPNOTSUPP ; + }
Quoted 6 lines
Quoted 3 lines
We should not be doing anything if
soft_offlineis disabled, so this check should be placed upfront, at the very beginning of the function.
Then you can remove the 'put_ref_page' call.Also, I would go for a
pr_info_oncehere, as otherwise we can spam the log quite easy.
Nice catch. I will do pr_info_once in v4.
Quoted 4 lines
--
Oscar Salvador
SUSE Labs
Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
In reply to Oscar SalvadorQuoted 3 lines · Oscar Salvador
We should not be doing anything if
soft_offlineis disabled, so this check should be placed upfront, at the very beginning of the function.
Then you can remove the 'put_ref_page' call.
Sorry, I managed to confuse myself, this has to stay as is.
Signature · 2 lines
Oscar Salvador SUSE Labs
Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
In reply to Oscar SalvadorQuoted 14 lines · Oscar Salvador
Quoted 12 lines · Jiaqi Yan
- * Returns 0 on success
- *-EOPNOTSUPPforhwpoison_filter()filtered the error event
+ * Returns 0 on success,+ * -EOPNOTSUPP for hwpoison_filter() filtered the error event, + * -EOPNOTSUPP if disabled by /proc/sys/vm/enable_soft_offline, * < 0 otherwise negated errno.*
* Soft offline a page, by migration or invalidation,mm/memory-failure.c +0
-0@@ -2783,6 +2795,12 @@ int soft_offline_page(unsigned long pfn, int flags)return -EIO ; }
Quoted 9 lines
mm/memory-failure.c int soft_offline_page(unsigned long pfn, int flags) · line 2802
Quoted 5 lines
mm/memory-failure.c +5
-0+if (!sysctl_enable_soft_offline) { +pr_info ("%#lx: OS-wide disabled\n" , pfn); +put_ref_page (pfn, flags); +return -EOPNOTSUPP ; + }We should not be doing anything if
soft_offlineis disabled, so this check should be placed upfront, at the very beginning of the function.
Then you can remove the 'put_ref_page' call.
I think if MF_COUNT_INCREASED is in flags, we still need to put_ref_page(), right?
Quoted 5 lines
--
Oscar Salvador
SUSE Labs
PATCH v3 2/3 selftest/mm: test enable_soft_offline behaviors
In reply to Jiaqi YanAdd regression and new tests when hugepage has correctable memory errors, and how userspace wants to deal with it:
* if enable_soft_offline=1, mapped hugepage is soft offlined
* if enable_soft_offline=0, mapped hugepage is intact
Free hugepages case is not explicitly covered by the tests.
Hugepage having corrected memory errors is emulated with MADV_SOFT_OFFLINE.
--- tools/testing/selftests/mm/.gitignore | 1 + tools/testing/selftests/mm/Makefile | 1 + .../selftests/mm/hugetlb-soft-offline.c | 229 ++++++++++++++++++ tools/testing/selftests/mm/run_vmtests.sh | 4 + 4 files changed, 235 insertions(+) create mode 100644 tools/testing/selftests/mm/hugetlb-soft-offline.c
tools/testing/selftests/mm/.gitignore +1 -0
@@ -6,6 +6,7 @@ hugepage-shm hugepage-vmemmap hugetlb-madvise hugetlb-read-hwpoison +hugetlb-soft-offline khugepaged map_hugetlb map_populate
tools/testing/selftests/mm/Makefile +1 -0
@@ -42,6 +42,7 @@ TEST_GEN_FILES += gup_test TEST_GEN_FILES += hmm-tests TEST_GEN_FILES += hugetlb-madvise TEST_GEN_FILES += hugetlb-read-hwpoison +TEST_GEN_FILES += hugetlb-soft-offline TEST_GEN_FILES += hugepage-mmap TEST_GEN_FILES += hugepage-mremap TEST_GEN_FILES += hugepage-shm
tools/testing/selftests/mm/hugetlb-soft-offline.c new file +229 -0
229 lines not on this page · raw message
tools/testing/selftests/mm/run_vmtests.sh +4 -0
@@ -331,6 +331,10 @@ CATEGORY="hugetlb" run_test ./thuge-gen CATEGORY="hugetlb" run_test ./charge_reserved_hugetlb.sh -cgroup-v2 CATEGORY="hugetlb" run_test ./hugetlb_reparenting_test.sh -cgroup-v2 if $RUN_DESTRUCTIVE; then +nr_hugepages_tmp=$(cat /proc/sys/vm/nr_hugepages) +echo 8 > /proc/sys/vm/nr_hugepages +CATEGORY="hugetlb" run_test ./hugetlb-soft-offline +echo "$nr_hugepages_tmp" > /proc/sys/vm/nr_hugepages CATEGORY="hugetlb" run_test ./hugetlb-read-hwpoison fi
Signature · 1 line
2.45.2.627.g7a2c4fd464-goog
PATCH v3 3/3 docs: mm: add enable_soft_offline sysctl
In reply to Jiaqi YanAdd the documentation for soft offline behaviors / costs, and what the new enable_soft_offline sysctl is for.
--- Documentation/admin-guide/sysctl/vm.rst | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
Documentation/admin-guide/sysctl/vm.rst +33 -0
@@ -36,6 +36,7 @@ Currently, these files are in /proc/sys/vm: - dirtytime_expire_seconds - dirty_writeback_centisecs - drop_caches +- enable_soft_offline - extfrag_threshold - highmem_is_dirtyable - hugetlb_shm_group
@@ -267,6 +268,38 @@ used:: These are informational only. They do not mean that anything is wrong with your system. To disable them, echo 4 (bit 2) into drop_caches. +enable_soft_offline +=================== +Correctable memory errors are very common on servers. Soft-offline is kernel's +solution for memory pages having (excessive) corrected memory errors. + +For different types of page, soft-offline has different behaviors / costs. +- For a raw error page, soft-offline migrates the in-use page's content to + a new raw page. +- For a page that is part of a transparent hugepage, soft-offline splits the + transparent hugepage into raw pages, then migrates only the raw error page. + As a result, user is transparently backed by 1 less hugepage, impacting + memory access performance. +- For a page that is part of a HugeTLB hugepage, soft-offline first migrates + the entire HugeTLB hugepage, during which a free hugepage will be consumed + as migration target. Then the original hugepage is dissolved into raw + pages without compensation, reducing the capacity of the HugeTLB pool by 1. + +It is user's call to choose between reliability (staying away from fragile +physical memory) vs performance / capacity implications in transparent and +HugeTLB cases. + +For all architectures, enable_soft_offline controls whether to soft offline +memory pages. When setting to 1, kernel attempts to soft offline the pages +whenever it thinks needed. When setting to 0, kernel returns EOPNOTSUPP to +the request to soft offline the pages. Its default value is 1. + +It is worth mentioning that after setting enable_soft_offline to 0: +- If RAS Correctable Errors Collector is running, its request to soft offline + pages will fail. +- On ARM, the request to soft offline pages from GHES driver will fail. +- On PARISC, the request to soft offline pages from Page Deallocation Table + will fail. extfrag_threshold =================
Signature · 1 line
2.45.2.627.g7a2c4fd464-goog
Re: [PATCH v3 3/3] docs: mm: add enable_soft_offline sysctl
Quoted 46 lines · Jiaqi Yan
Add the documentation for soft offline behaviors / costs, and what the new
enable_soft_offlinesysctl is for.Signed-off-by Jiaqi Yan <[email protected]>--- Documentation/admin-guide/sysctl/vm.rst | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+)Documentation/admin-guide/sysctl/vm.rst +23
-0@@ -36,6 +36,7 @@ Currently, these files are in /proc/sys/vm: - dirtytime_expire_seconds - dirty_writeback_centisecs - drop_caches +- enable_soft_offline - extfrag_threshold - highmem_is_dirtyable - hugetlb_shm_group@@ -267,6 +268,38 @@ used:: These are informational only. They do not mean that anything is wrong with your system. To disable them, echo 4 (bit 2) into drop_caches. +enable_soft_offline +=================== +Correctable memory errors are very common on servers. Soft-offline is kernel's +solution for memory pages having (excessive) corrected memory errors. + +For different types of page, soft-offline has different behaviors / costs. +- For a raw error page, soft-offline migrates the in-use page's content to + a new raw page. +- For a page that is part of a transparent hugepage, soft-offline splits the + transparent hugepage into raw pages, then migrates only the raw error page. + As a result, user is transparently backed by 1 less hugepage, impacting + memory access performance. +- For a page that is part of a HugeTLB hugepage, soft-offline first migrates + the entire HugeTLB hugepage, during which a free hugepage will be consumed + as migration target. Then the original hugepage is dissolved into raw + pages without compensation, reducing the capacity of the HugeTLB pool by 1. + +It is user's call to choose between reliability (staying away from fragile +physical memory) vs performance / capacity implications in transparent and +HugeTLB cases. + +For all architectures, enable_soft_offline controls whether to soft offline
Documentation/admin-guide/sysctl/vm.rst used:: · line 302
Quoted 10 lines
Documentation/admin-guide/sysctl/vm.rst +10
-0+memory pages. When setting to 1, kernel attempts to soft offline the pages +whenever it thinks needed. When setting to 0, kernel returns EOPNOTSUPP to +the request to soft offline the pages. Its default value is 1. + +It is worth mentioning that after setting enable_soft_offline to 0: +- If RAS Correctable Errors Collector is running, its request to soft offline + pages will fail. +- On ARM, the request to soft offline pages from GHES driver will fail. +- On PARISC, the request to soft offline pages from Page Deallocation Table + will fail.
I do not know about others but the 'fail' word feels wrong here. I would reword that as "... the request to soft offline pages from xxxx will not be performed".
Other than that:
Signature · 2 lines
Oscar Salvador SUSE Labs
Re: [PATCH v3 3/3] docs: mm: add enable_soft_offline sysctl
Quoted 54 lines · Oscar Salvador
Quoted 52 lines · Jiaqi Yan
Add the documentation for soft offline behaviors / costs, and what the new
enable_soft_offlinesysctl is for.Signed-off-by Jiaqi Yan <[email protected]>--- Documentation/admin-guide/sysctl/vm.rst | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+)Documentation/admin-guide/sysctl/vm.rst +29
-0@@ -36,6 +36,7 @@ Currently, these files are in /proc/sys/vm: - dirtytime_expire_seconds - dirty_writeback_centisecs - drop_caches +- enable_soft_offline - extfrag_threshold - highmem_is_dirtyable - hugetlb_shm_group@@ -267,6 +268,38 @@ used:: These are informational only. They do not mean that anything is wrong with your system. To disable them, echo 4 (bit 2) into drop_caches. +enable_soft_offline +=================== +Correctable memory errors are very common on servers. Soft-offline is kernel's +solution for memory pages having (excessive) corrected memory errors. + +For different types of page, soft-offline has different behaviors / costs. +- For a raw error page, soft-offline migrates the in-use page's content to + a new raw page. +- For a page that is part of a transparent hugepage, soft-offline splits the + transparent hugepage into raw pages, then migrates only the raw error page. + As a result, user is transparently backed by 1 less hugepage, impacting + memory access performance. +- For a page that is part of a HugeTLB hugepage, soft-offline first migrates + the entire HugeTLB hugepage, during which a free hugepage will be consumed + as migration target. Then the original hugepage is dissolved into raw + pages without compensation, reducing the capacity of the HugeTLB pool by 1. + +It is user's call to choose between reliability (staying away from fragile +physical memory) vs performance / capacity implications in transparent and +HugeTLB cases. + +For all architectures, enable_soft_offline controls whether to soft offline +memory pages. When setting to 1, kernel attempts to soft offline the pages +whenever it thinks needed. When setting to 0, kernel returns EOPNOTSUPP to +the request to soft offline the pages. Its default value is 1. + +It is worth mentioning that after setting enable_soft_offline to 0: +- If RAS Correctable Errors Collector is running, its request to soft offline
Quoted 8 lines
Documentation/admin-guide/sysctl/vm.rst used:: · line 302
Quoted 4 lines
Documentation/admin-guide/sysctl/vm.rst +4
-0+ pages will fail. +- On ARM, the request to soft offline pages from GHES driver will fail. +- On PARISC, the request to soft offline pages from Page Deallocation Table + will fail.I do not know about others but the 'fail' word feels wrong here. I would reword that as "... the request to soft offline pages from xxxx will not be performed".
Will reword in v4.
Quoted 5 lines
Other than that:
Acked-by Oscar Salvador <[email protected]>
Thanks Oscar!
Quoted 4 lines
--
Oscar Salvador
SUSE Labs