mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
@ 2026-09-14 23:49 Kyle Meyer
  2026-09-15  0:37 ` Andrew Morton
  2026-09-15  8:31 ` Michal Hocko
  0 siblings, 2 replies; 11+ messages in thread
From: Kyle Meyer @ 2026-09-14 23:49 UTC (permalink / raw)
  To: akpm, corbet, david, linmiaohe, shuah, tony.luck, jane.chu, jiaqiyan
  Cc: Liam.Howlett, bp, hannes, jack, joel.granados, kyle.meyer,
	laoar.shao, lorenzo.stoakes, mclapinski, mhocko, nao.horiguchi,
	osalvador, rafael.j.wysocki, rppt, russ.anderson, shawn.fan,
	surenb, vbabka, linux-acpi, linux-doc, linux-kernel,
	linux-kselftest, linux-mm

Soft offlining a HugeTLB page dissolves it, permanently reducing the
HugeTLB page pool. This can be problematic for workloads that depend on
a fixed number of HugeTLB pages.

Currently, soft offline must be disabled to prevent HugeTLB pages from
being soft offlined.

This patch allows soft offline to be disabled for HugeTLB pages while
remaining enabled for non-HugeTLB pages.

Commit 56374430c5dfc ("mm/memory-failure: userspace controls
soft-offlining pages") introduced the following sysctl interface to
control soft offline:

/proc/sys/vm/enable_soft_offline

The interface does not distinguish between page types:

    0 - Soft offline is disabled
    1 - Soft offline is enabled

Convert enable_soft_offline to a bitmask and support disabling soft
offline for HugeTLB pages:

Bits:

    0 - Enable soft offline
    1 - Disable soft offline for HugeTLB pages

Supported values:

    0 - Soft offline is disabled
    1 - Soft offline is enabled
    3 - Soft offline is enabled (disabled for HugeTLB pages)

Existing behavior is preserved.

Update documentation and HugeTLB soft offline selftests.

Suggested-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
---

Tony's patch:
* https://lore.kernel.org/all/20250904155720.22149-1-tony.luck@intel.com

v1:
* https://lore.kernel.org/all/aMGkAI3zKlVsO0S2@hpe.com

v1 -> v2:
* Make the interface extensible, as suggested by David.
* Preserve existing behavior, as suggested by Jiaqi and David.
* https://lore.kernel.org/all/aMiu_Uku6Y5ZbuhM@hpe.com

v2 -> v3:
* Minor documentation updates.
* Use page_folio(page) instead of pfn_folio(pfn) for HugeTLB page check.

---
 .../ABI/testing/sysfs-memory-page-offline     |  3 +++
 Documentation/admin-guide/sysctl/vm.rst       | 27 +++++++++++++++----
 mm/memory-failure.c                           | 17 +++++++++---
 .../selftests/mm/hugetlb-soft-offline.c       | 19 ++++++++++---
 4 files changed, 54 insertions(+), 12 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-memory-page-offline b/Documentation/ABI/testing/sysfs-memory-page-offline
index 00f4e35f916f..19aa539fb910 100644
--- a/Documentation/ABI/testing/sysfs-memory-page-offline
+++ b/Documentation/ABI/testing/sysfs-memory-page-offline
@@ -20,6 +20,9 @@ Description:
 		number, or a error when the offlining failed.  Reading
 		the file is not allowed.
 
+		Soft-offline can be controlled via sysctl:
+		Documentation/admin-guide/sysctl/vm.rst
+
 What:		/sys/devices/system/memory/hard_offline_page
 Date:		Sep 2009
 KernelVersion:	2.6.33
diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-guide/sysctl/vm.rst
index 5b318d17aa4b..ee1941e44643 100644
--- a/Documentation/admin-guide/sysctl/vm.rst
+++ b/Documentation/admin-guide/sysctl/vm.rst
@@ -309,16 +309,33 @@ 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 set to 1, kernel attempts to soft offline the pages
-whenever it thinks needed.  When set to 0, kernel returns EOPNOTSUPP to
-the request to soft offline the pages.  Its default value is 1.
+memory pages.
 
-It is worth mentioning that after setting enable_soft_offline to 0, the
+enable_soft_offline is a bitmask:
+
+Bits::
+
+	0 - Enable soft offline
+	1 - Disable soft offline for HugeTLB pages
+
+Supported values::
+
+	0 - Soft offline is disabled
+	1 - Soft offline is enabled
+	3 - Soft offline is enabled (disabled for HugeTLB pages)
+
+The default value is 1.
+
+If soft offline is disabled for the requested page type, EOPNOTSUPP is returned.
+
+It is worth mentioning that after disabling soft offline, the
 following requests to soft offline pages will not be performed:
 
+- Request to soft offline pages from sysfs.
+
 - Request to soft offline pages from RAS Correctable Errors Collector.
 
-- On ARM, the request to soft offline pages from GHES driver.
+- Request to soft offline pages from GHES driver.
 
 - On PARISC, the request to soft offline pages from Page Deallocation Table.
 
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index a8b03e2920ba..6c4ce39f46df 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -69,11 +69,14 @@
 #include "page_alloc.h"
 #include "internal.h"
 
+#define SOFT_OFFLINE_ENABLED		BIT(0)
+#define SOFT_OFFLINE_SKIP_HUGETLB	BIT(1)
+
 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;
+static int sysctl_enable_soft_offline __read_mostly = SOFT_OFFLINE_ENABLED;
 
 static int sysctl_panic_on_unrecoverable_mf __read_mostly;
 
@@ -157,7 +160,7 @@ static const struct ctl_table memory_failure_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_ONE,
+		.extra2		= SYSCTL_THREE,
 	},
 	{
 		.procname	= "panic_on_unrecoverable_memory_failure",
@@ -2982,12 +2985,20 @@ int soft_offline_page(unsigned long pfn, int flags)
 		return -EIO;
 	}
 
-	if (!sysctl_enable_soft_offline) {
+	if (!(sysctl_enable_soft_offline & SOFT_OFFLINE_ENABLED)) {
 		pr_info_once("disabled by /proc/sys/vm/enable_soft_offline\n");
 		put_ref_page(pfn, flags);
 		return -EOPNOTSUPP;
 	}
 
+	if (sysctl_enable_soft_offline & SOFT_OFFLINE_SKIP_HUGETLB) {
+		if (folio_test_hugetlb(page_folio(page))) {
+			pr_info_once("disabled for HugeTLB pages by /proc/sys/vm/enable_soft_offline\n");
+			put_ref_page(pfn, flags);
+			return -EOPNOTSUPP;
+		}
+	}
+
 	mutex_lock(&mf_mutex);
 
 	if (PageHWPoison(page)) {
diff --git a/tools/testing/selftests/mm/hugetlb-soft-offline.c b/tools/testing/selftests/mm/hugetlb-soft-offline.c
index bc202e4ed2bd..9837c315a81e 100644
--- a/tools/testing/selftests/mm/hugetlb-soft-offline.c
+++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c
@@ -5,6 +5,8 @@
  *   offlining failed with EOPNOTSUPP.
  * - if enable_soft_offline = 1, a hugepage should be dissolved and
  *   nr_hugepages/free_hugepages should be reduced by 1.
+ * - if enable_soft_offline = 3, HugeTLB pages should stay intact and soft
+ *   offlining failed with EOPNOTSUPP.
  *
  * The test allocates 8 default hugepages
  */
@@ -31,6 +33,9 @@
 
 #define EPREFIX " !!! "
 
+#define SOFT_OFFLINE_ENABLED		(1 << 0)
+#define SOFT_OFFLINE_SKIP_HUGETLB	(1 << 1)
+
 static int do_soft_offline(int fd, size_t len, int expect_errno)
 {
 	char *filemap = NULL;
@@ -55,6 +60,7 @@ static int do_soft_offline(int fd, size_t len, int expect_errno)
 	ksft_print_msg("Allocated %#lx bytes of hugetlb pages\n", len);
 
 	hwp_addr = filemap + len / 2;
+	errno = 0;
 	ret = madvise(hwp_addr, pagesize, MADV_SOFT_OFFLINE);
 	ksft_print_msg("MADV_SOFT_OFFLINE %p ret=%d, errno=%d\n",
 		       hwp_addr, ret, errno);
@@ -82,7 +88,7 @@ static int set_enable_soft_offline(int value)
 	char cmd[256] = {0};
 	FILE *cmdfile = NULL;
 
-	if (value != 0 && value != 1)
+	if (value < 0 || value > 3)
 		return -EINVAL;
 
 	sprintf(cmd, "echo %d > /proc/sys/vm/enable_soft_offline", value);
@@ -128,13 +134,17 @@ static int create_hugetlbfs_file(struct statfs *file_stat)
 static void test_soft_offline_common(int enable_soft_offline)
 {
 	int fd;
-	int expect_errno = enable_soft_offline ? 0 : EOPNOTSUPP;
+	int expect_errno = 0;
 	struct statfs file_stat;
 	unsigned long hugepagesize_kb = 0;
 	unsigned long nr_hugepages_before = 0;
 	unsigned long nr_hugepages_after = 0;
 	int ret;
 
+	if (!(enable_soft_offline & SOFT_OFFLINE_ENABLED) ||
+	    (enable_soft_offline & SOFT_OFFLINE_SKIP_HUGETLB))
+		expect_errno = EOPNOTSUPP;
+
 	ksft_print_msg("Test soft-offline when enabled_soft_offline=%d\n",
 		       enable_soft_offline);
 
@@ -165,7 +175,7 @@ static void test_soft_offline_common(int enable_soft_offline)
 	// No need for the hugetlbfs file from now on.
 	close(fd);
 
-	if (enable_soft_offline) {
+	if (expect_errno == 0) {
 		if (nr_hugepages_before != nr_hugepages_after + 1) {
 			ksft_test_result_fail("MADV_SOFT_OFFLINE should reduced 1 hugepage\n");
 			return;
@@ -190,8 +200,9 @@ int main(int argc, char **argv)
 	if (!hugetlb_setup_default(8))
 		ksft_exit_skip("not enough hugetlb pages\n");
 
-	ksft_set_plan(2);
+	ksft_set_plan(3);
 
+	test_soft_offline_common(3);
 	test_soft_offline_common(1);
 	test_soft_offline_common(0);
 
-- 
2.51.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-14 23:49 [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages Kyle Meyer
@ 2026-09-15  0:37 ` Andrew Morton
  2026-09-15  0:57   ` Kyle Meyer
  2026-09-15  8:31 ` Michal Hocko
  1 sibling, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2026-09-15  0:37 UTC (permalink / raw)
  To: Kyle Meyer
  Cc: corbet, david, linmiaohe, shuah, tony.luck, jane.chu, jiaqiyan,
	Liam.Howlett, bp, hannes, jack, joel.granados, laoar.shao,
	lorenzo.stoakes, mclapinski, mhocko, nao.horiguchi, osalvador,
	rafael.j.wysocki, rppt, russ.anderson, shawn.fan, surenb, vbabka,
	linux-acpi, linux-doc, linux-kernel, linux-kselftest, linux-mm

On Mon, 14 Sep 2026 18:49:38 -0500 Kyle Meyer <kyle.meyer@hpe.com> wrote:

> Soft offlining a HugeTLB page dissolves it, permanently reducing the
> HugeTLB page pool. This can be problematic for workloads that depend on
> a fixed number of HugeTLB pages.
> 
> Currently, soft offline must be disabled to prevent HugeTLB pages from
> being soft offlined.
> 
> This patch allows soft offline to be disabled for HugeTLB pages while
> remaining enabled for non-HugeTLB pages.
> 
> Commit 56374430c5dfc ("mm/memory-failure: userspace controls
> soft-offlining pages") introduced the following sysctl interface to
> control soft offline:
> 
> /proc/sys/vm/enable_soft_offline
> 
> The interface does not distinguish between page types:
> 
>     0 - Soft offline is disabled
>     1 - Soft offline is enabled
> 
> Convert enable_soft_offline to a bitmask and support disabling soft
> offline for HugeTLB pages:
> 
> Bits:
> 
>     0 - Enable soft offline
>     1 - Disable soft offline for HugeTLB pages
> 
> Supported values:
> 
>     0 - Soft offline is disabled
>     1 - Soft offline is enabled
>     3 - Soft offline is enabled (disabled for HugeTLB pages)
> 
> Existing behavior is preserved.
> 
> Update documentation and HugeTLB soft offline selftests.

I'm hitting some rejects against
https://lore.kernel.org/20260825085756.63030-4-husong@kylinos.cn. 
Please update this against mm.git's mm-unstalbe branch or linux-next.

I'd updated v2's changelog with this:


Tony said:

: Recap of original problem is that some BIOS keep track of error
: threshold per-rank and use this GHES mechanism to report threshold
: exceeded on the rank.
: 
: Systems that stay up a long time can accumulate enough soft errors to
: trigger this threshold.  But the action of taking a page offline isn't
: going to help.  For a 4K page this is merely annoying.  For 1G page it
: can mess things up badly.
: 
: My original patch for this just skipped the GHES->offline process for
: huge pages.  But I wasn't aware of the sysctl control.  That provides a
: better solution.

Which is cumbersome but I think there's useful info here so please
incorporate in some way.

> Suggested-by: Tony Luck <tony.luck@intel.com>
> Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>

v2 had

Reported-by: Shawn Fan <shawn.fan@intel.com>

which got lost.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-15  0:37 ` Andrew Morton
@ 2026-09-15  0:57   ` Kyle Meyer
  0 siblings, 0 replies; 11+ messages in thread
From: Kyle Meyer @ 2026-09-15  0:57 UTC (permalink / raw)
  To: Andrew Morton
  Cc: corbet, david, linmiaohe, shuah, tony.luck, jane.chu, jiaqiyan,
	Liam.Howlett, bp, hannes, jack, joel.granados, laoar.shao,
	lorenzo.stoakes, mclapinski, mhocko, nao.horiguchi, osalvador,
	rafael.j.wysocki, rppt, russ.anderson, shawn.fan, surenb, vbabka,
	linux-acpi, linux-doc, linux-kernel, linux-kselftest, linux-mm

On Mon, Sep 14, 2026 at 05:37:00PM -0700, Andrew Morton wrote:
> On Mon, 14 Sep 2026 18:49:38 -0500 Kyle Meyer <kyle.meyer@hpe.com> wrote:

[...]

> I'm hitting some rejects against
> https://lore.kernel.org/20260825085756.63030-4-husong@kylinos.cn . 
> Please update this against mm.git's mm-unstalbe branch or linux-next.

Sure, I'll send a v4.

> I'd updated v2's changelog with this:
> 
> 
> Tony said:
> 
> : Recap of original problem is that some BIOS keep track of error
> : threshold per-rank and use this GHES mechanism to report threshold
> : exceeded on the rank.
> : 
> : Systems that stay up a long time can accumulate enough soft errors to
> : trigger this threshold.  But the action of taking a page offline isn't
> : going to help.  For a 4K page this is merely annoying.  For 1G page it
> : can mess things up badly.
> : 
> : My original patch for this just skipped the GHES->offline process for
> : huge pages.  But I wasn't aware of the sysctl control.  That provides a
> : better solution.
> 
> Which is cumbersome but I think there's useful info here so please
> incorporate in some way.

OK, thank you.

> > Suggested-by: Tony Luck <tony.luck@intel.com>
> > Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
> 
> v2 had
> 
> Reported-by: Shawn Fan <shawn.fan@intel.com>
> 
> which got lost.

checkpatch.pl complained about a missing "Closes: or Link:" and I don't have a
pointer to report, but I'll add that back to v4.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-14 23:49 [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages Kyle Meyer
  2026-09-15  0:37 ` Andrew Morton
@ 2026-09-15  8:31 ` Michal Hocko
  2026-09-15 17:55   ` Kyle Meyer
  1 sibling, 1 reply; 11+ messages in thread
From: Michal Hocko @ 2026-09-15  8:31 UTC (permalink / raw)
  To: Kyle Meyer
  Cc: akpm, corbet, david, linmiaohe, shuah, tony.luck, jane.chu,
	jiaqiyan, Liam.Howlett, bp, hannes, jack, joel.granados,
	laoar.shao, lorenzo.stoakes, mclapinski, nao.horiguchi,
	osalvador, rafael.j.wysocki, rppt, russ.anderson, shawn.fan,
	surenb, vbabka, linux-acpi, linux-doc, linux-kernel,
	linux-kselftest, linux-mm

On Mon 14-09-26 18:49:38, Kyle Meyer wrote:
> Soft offlining a HugeTLB page dissolves it, permanently reducing the
> HugeTLB page pool. This can be problematic for workloads that depend on
> a fixed number of HugeTLB pages.
> 
> Currently, soft offline must be disabled to prevent HugeTLB pages from
> being soft offlined.
> 
> This patch allows soft offline to be disabled for HugeTLB pages while
> remaining enabled for non-HugeTLB pages.
> 
> Commit 56374430c5dfc ("mm/memory-failure: userspace controls
> soft-offlining pages") introduced the following sysctl interface to
> control soft offline:
> 
> /proc/sys/vm/enable_soft_offline
> 
> The interface does not distinguish between page types:
> 
>     0 - Soft offline is disabled
>     1 - Soft offline is enabled
> 
> Convert enable_soft_offline to a bitmask and support disabling soft
> offline for HugeTLB pages:
> 
> Bits:
> 
>     0 - Enable soft offline
>     1 - Disable soft offline for HugeTLB pages
> 
> Supported values:
> 
>     0 - Soft offline is disabled
>     1 - Soft offline is enabled
>     3 - Soft offline is enabled (disabled for HugeTLB pages)
> 
> Existing behavior is preserved.
> 
> Update documentation and HugeTLB soft offline selftests.

This is adding a lot of user interfaces to control something you can
disable by config option for an admin only functionality.
I fail to to see any actual justification for all of that. If an admin
can disolve a hugetlb page it has power to allocate a new one as well.
Not to menation that the whole soft offlining is mostly a testing
feature so adding a lot of fine grained configuration space seems
excessive to me.

> Suggested-by: Tony Luck <tony.luck@intel.com>
> Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
> ---
> 
> Tony's patch:
> * https://lore.kernel.org/all/20250904155720.22149-1-tony.luck@intel.com
> 
> v1:
> * https://lore.kernel.org/all/aMGkAI3zKlVsO0S2@hpe.com
> 
> v1 -> v2:
> * Make the interface extensible, as suggested by David.
> * Preserve existing behavior, as suggested by Jiaqi and David.
> * https://lore.kernel.org/all/aMiu_Uku6Y5ZbuhM@hpe.com
> 
> v2 -> v3:
> * Minor documentation updates.
> * Use page_folio(page) instead of pfn_folio(pfn) for HugeTLB page check.
> 
> ---
>  .../ABI/testing/sysfs-memory-page-offline     |  3 +++
>  Documentation/admin-guide/sysctl/vm.rst       | 27 +++++++++++++++----
>  mm/memory-failure.c                           | 17 +++++++++---
>  .../selftests/mm/hugetlb-soft-offline.c       | 19 ++++++++++---
>  4 files changed, 54 insertions(+), 12 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-memory-page-offline b/Documentation/ABI/testing/sysfs-memory-page-offline
> index 00f4e35f916f..19aa539fb910 100644
> --- a/Documentation/ABI/testing/sysfs-memory-page-offline
> +++ b/Documentation/ABI/testing/sysfs-memory-page-offline
> @@ -20,6 +20,9 @@ Description:
>  		number, or a error when the offlining failed.  Reading
>  		the file is not allowed.
>  
> +		Soft-offline can be controlled via sysctl:
> +		Documentation/admin-guide/sysctl/vm.rst
> +
>  What:		/sys/devices/system/memory/hard_offline_page
>  Date:		Sep 2009
>  KernelVersion:	2.6.33
> diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-guide/sysctl/vm.rst
> index 5b318d17aa4b..ee1941e44643 100644
> --- a/Documentation/admin-guide/sysctl/vm.rst
> +++ b/Documentation/admin-guide/sysctl/vm.rst
> @@ -309,16 +309,33 @@ 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 set to 1, kernel attempts to soft offline the pages
> -whenever it thinks needed.  When set to 0, kernel returns EOPNOTSUPP to
> -the request to soft offline the pages.  Its default value is 1.
> +memory pages.
>  
> -It is worth mentioning that after setting enable_soft_offline to 0, the
> +enable_soft_offline is a bitmask:
> +
> +Bits::
> +
> +	0 - Enable soft offline
> +	1 - Disable soft offline for HugeTLB pages
> +
> +Supported values::
> +
> +	0 - Soft offline is disabled
> +	1 - Soft offline is enabled
> +	3 - Soft offline is enabled (disabled for HugeTLB pages)
> +
> +The default value is 1.
> +
> +If soft offline is disabled for the requested page type, EOPNOTSUPP is returned.
> +
> +It is worth mentioning that after disabling soft offline, the
>  following requests to soft offline pages will not be performed:
>  
> +- Request to soft offline pages from sysfs.
> +
>  - Request to soft offline pages from RAS Correctable Errors Collector.
>  
> -- On ARM, the request to soft offline pages from GHES driver.
> +- Request to soft offline pages from GHES driver.
>  
>  - On PARISC, the request to soft offline pages from Page Deallocation Table.
>  
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index a8b03e2920ba..6c4ce39f46df 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -69,11 +69,14 @@
>  #include "page_alloc.h"
>  #include "internal.h"
>  
> +#define SOFT_OFFLINE_ENABLED		BIT(0)
> +#define SOFT_OFFLINE_SKIP_HUGETLB	BIT(1)
> +
>  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;
> +static int sysctl_enable_soft_offline __read_mostly = SOFT_OFFLINE_ENABLED;
>  
>  static int sysctl_panic_on_unrecoverable_mf __read_mostly;
>  
> @@ -157,7 +160,7 @@ static const struct ctl_table memory_failure_table[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec_minmax,
>  		.extra1		= SYSCTL_ZERO,
> -		.extra2		= SYSCTL_ONE,
> +		.extra2		= SYSCTL_THREE,
>  	},
>  	{
>  		.procname	= "panic_on_unrecoverable_memory_failure",
> @@ -2982,12 +2985,20 @@ int soft_offline_page(unsigned long pfn, int flags)
>  		return -EIO;
>  	}
>  
> -	if (!sysctl_enable_soft_offline) {
> +	if (!(sysctl_enable_soft_offline & SOFT_OFFLINE_ENABLED)) {
>  		pr_info_once("disabled by /proc/sys/vm/enable_soft_offline\n");
>  		put_ref_page(pfn, flags);
>  		return -EOPNOTSUPP;
>  	}
>  
> +	if (sysctl_enable_soft_offline & SOFT_OFFLINE_SKIP_HUGETLB) {
> +		if (folio_test_hugetlb(page_folio(page))) {
> +			pr_info_once("disabled for HugeTLB pages by /proc/sys/vm/enable_soft_offline\n");
> +			put_ref_page(pfn, flags);
> +			return -EOPNOTSUPP;
> +		}
> +	}
> +
>  	mutex_lock(&mf_mutex);
>  
>  	if (PageHWPoison(page)) {
> diff --git a/tools/testing/selftests/mm/hugetlb-soft-offline.c b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> index bc202e4ed2bd..9837c315a81e 100644
> --- a/tools/testing/selftests/mm/hugetlb-soft-offline.c
> +++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> @@ -5,6 +5,8 @@
>   *   offlining failed with EOPNOTSUPP.
>   * - if enable_soft_offline = 1, a hugepage should be dissolved and
>   *   nr_hugepages/free_hugepages should be reduced by 1.
> + * - if enable_soft_offline = 3, HugeTLB pages should stay intact and soft
> + *   offlining failed with EOPNOTSUPP.
>   *
>   * The test allocates 8 default hugepages
>   */
> @@ -31,6 +33,9 @@
>  
>  #define EPREFIX " !!! "
>  
> +#define SOFT_OFFLINE_ENABLED		(1 << 0)
> +#define SOFT_OFFLINE_SKIP_HUGETLB	(1 << 1)
> +
>  static int do_soft_offline(int fd, size_t len, int expect_errno)
>  {
>  	char *filemap = NULL;
> @@ -55,6 +60,7 @@ static int do_soft_offline(int fd, size_t len, int expect_errno)
>  	ksft_print_msg("Allocated %#lx bytes of hugetlb pages\n", len);
>  
>  	hwp_addr = filemap + len / 2;
> +	errno = 0;
>  	ret = madvise(hwp_addr, pagesize, MADV_SOFT_OFFLINE);
>  	ksft_print_msg("MADV_SOFT_OFFLINE %p ret=%d, errno=%d\n",
>  		       hwp_addr, ret, errno);
> @@ -82,7 +88,7 @@ static int set_enable_soft_offline(int value)
>  	char cmd[256] = {0};
>  	FILE *cmdfile = NULL;
>  
> -	if (value != 0 && value != 1)
> +	if (value < 0 || value > 3)
>  		return -EINVAL;
>  
>  	sprintf(cmd, "echo %d > /proc/sys/vm/enable_soft_offline", value);
> @@ -128,13 +134,17 @@ static int create_hugetlbfs_file(struct statfs *file_stat)
>  static void test_soft_offline_common(int enable_soft_offline)
>  {
>  	int fd;
> -	int expect_errno = enable_soft_offline ? 0 : EOPNOTSUPP;
> +	int expect_errno = 0;
>  	struct statfs file_stat;
>  	unsigned long hugepagesize_kb = 0;
>  	unsigned long nr_hugepages_before = 0;
>  	unsigned long nr_hugepages_after = 0;
>  	int ret;
>  
> +	if (!(enable_soft_offline & SOFT_OFFLINE_ENABLED) ||
> +	    (enable_soft_offline & SOFT_OFFLINE_SKIP_HUGETLB))
> +		expect_errno = EOPNOTSUPP;
> +
>  	ksft_print_msg("Test soft-offline when enabled_soft_offline=%d\n",
>  		       enable_soft_offline);
>  
> @@ -165,7 +175,7 @@ static void test_soft_offline_common(int enable_soft_offline)
>  	// No need for the hugetlbfs file from now on.
>  	close(fd);
>  
> -	if (enable_soft_offline) {
> +	if (expect_errno == 0) {
>  		if (nr_hugepages_before != nr_hugepages_after + 1) {
>  			ksft_test_result_fail("MADV_SOFT_OFFLINE should reduced 1 hugepage\n");
>  			return;
> @@ -190,8 +200,9 @@ int main(int argc, char **argv)
>  	if (!hugetlb_setup_default(8))
>  		ksft_exit_skip("not enough hugetlb pages\n");
>  
> -	ksft_set_plan(2);
> +	ksft_set_plan(3);
>  
> +	test_soft_offline_common(3);
>  	test_soft_offline_common(1);
>  	test_soft_offline_common(0);
>  
> -- 
> 2.51.0

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-15  8:31 ` Michal Hocko
@ 2026-09-15 17:55   ` Kyle Meyer
  2026-09-16  8:52     ` Michal Hocko
  0 siblings, 1 reply; 11+ messages in thread
From: Kyle Meyer @ 2026-09-15 17:55 UTC (permalink / raw)
  To: Michal Hocko
  Cc: akpm, corbet, david, linmiaohe, shuah, tony.luck, jane.chu,
	jiaqiyan, Liam.Howlett, bp, hannes, jack, joel.granados,
	laoar.shao, lorenzo.stoakes, mclapinski, nao.horiguchi,
	osalvador, rafael.j.wysocki, rppt, russ.anderson, shawn.fan,
	surenb, vbabka, linux-acpi, linux-doc, linux-kernel,
	linux-kselftest, linux-mm

On Tue, Sep 15, 2026 at 10:31:42AM +0200, Michal Hocko wrote:
> On Mon 14-09-26 18:49:38, Kyle Meyer wrote:
> > Soft offlining a HugeTLB page dissolves it, permanently reducing the
> > HugeTLB page pool. This can be problematic for workloads that depend on
> > a fixed number of HugeTLB pages.
> > 
> > Currently, soft offline must be disabled to prevent HugeTLB pages from
> > being soft offlined.
> > 
> > This patch allows soft offline to be disabled for HugeTLB pages while
> > remaining enabled for non-HugeTLB pages.
> > 
> > Commit 56374430c5dfc ("mm/memory-failure: userspace controls
> > soft-offlining pages") introduced the following sysctl interface to
> > control soft offline:
> > 
> > /proc/sys/vm/enable_soft_offline
> > 
> > The interface does not distinguish between page types:
> > 
> >     0 - Soft offline is disabled
> >     1 - Soft offline is enabled
> > 
> > Convert enable_soft_offline to a bitmask and support disabling soft
> > offline for HugeTLB pages:
> > 
> > Bits:
> > 
> >     0 - Enable soft offline
> >     1 - Disable soft offline for HugeTLB pages
> > 
> > Supported values:
> > 
> >     0 - Soft offline is disabled
> >     1 - Soft offline is enabled
> >     3 - Soft offline is enabled (disabled for HugeTLB pages)
> > 
> > Existing behavior is preserved.
> > 
> > Update documentation and HugeTLB soft offline selftests.
> 
> This is adding a lot of user interfaces to control something you can
> disable by config option for an admin only functionality.

I may be missing it, but I'm not aware of a config option that disables soft
offline specifically for HugeTLB pages.

> I fail to to see any actual justification for all of that. If an admin
> can disolve a hugetlb page it has power to allocate a new one as well.

Allocating HugeTLB pages after boot is not guaranteed.

> Not to menation that the whole soft offlining is mostly a testing
> feature so adding a lot of fine grained configuration space seems
> excessive to me.

Can you elaborate on "mostly a testing feature"? For example, how does that
apply to the BIOS/GHES path discussed here?

https://lore.kernel.org/all/aMkOCmGBhZKhKPrI@hpe.com

If you think this should be handled differently, I'm open to suggestions.

Thanks for the feedback,
Kyle Meyer

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-15 17:55   ` Kyle Meyer
@ 2026-09-16  8:52     ` Michal Hocko
  2026-09-16 13:08       ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Hocko @ 2026-09-16  8:52 UTC (permalink / raw)
  To: Kyle Meyer
  Cc: akpm, corbet, david, linmiaohe, shuah, tony.luck, jane.chu,
	jiaqiyan, Liam.Howlett, bp, hannes, jack, joel.granados,
	laoar.shao, lorenzo.stoakes, mclapinski, nao.horiguchi,
	osalvador, rafael.j.wysocki, rppt, russ.anderson, shawn.fan,
	surenb, vbabka, linux-acpi, linux-doc, linux-kernel,
	linux-kselftest, linux-mm

On Tue 15-09-26 12:55:03, Kyle Meyer wrote:
> On Tue, Sep 15, 2026 at 10:31:42AM +0200, Michal Hocko wrote:
> > On Mon 14-09-26 18:49:38, Kyle Meyer wrote:
> > > Soft offlining a HugeTLB page dissolves it, permanently reducing the
> > > HugeTLB page pool. This can be problematic for workloads that depend on
> > > a fixed number of HugeTLB pages.
> > > 
> > > Currently, soft offline must be disabled to prevent HugeTLB pages from
> > > being soft offlined.
> > > 
> > > This patch allows soft offline to be disabled for HugeTLB pages while
> > > remaining enabled for non-HugeTLB pages.
> > > 
> > > Commit 56374430c5dfc ("mm/memory-failure: userspace controls
> > > soft-offlining pages") introduced the following sysctl interface to
> > > control soft offline:
> > > 
> > > /proc/sys/vm/enable_soft_offline
> > > 
> > > The interface does not distinguish between page types:
> > > 
> > >     0 - Soft offline is disabled
> > >     1 - Soft offline is enabled
> > > 
> > > Convert enable_soft_offline to a bitmask and support disabling soft
> > > offline for HugeTLB pages:
> > > 
> > > Bits:
> > > 
> > >     0 - Enable soft offline
> > >     1 - Disable soft offline for HugeTLB pages
> > > 
> > > Supported values:
> > > 
> > >     0 - Soft offline is disabled
> > >     1 - Soft offline is enabled
> > >     3 - Soft offline is enabled (disabled for HugeTLB pages)
> > > 
> > > Existing behavior is preserved.
> > > 
> > > Update documentation and HugeTLB soft offline selftests.
> > 
> > This is adding a lot of user interfaces to control something you can
> > disable by config option for an admin only functionality.
> 
> I may be missing it, but I'm not aware of a config option that disables soft
> offline specifically for HugeTLB pages.

No, there is none. And IMHO there shouldn't be any. We do not want
config nor runtime option for any random type of page to be soft
offlined. You can disable the whole feature. If we need to enforce a
boot time parameter then I can be convinced about usefulness because
distro kernels need to enable config to be generally available but there
are usecases where this might be better disabled during runtime.

> > I fail to to see any actual justification for all of that. If an admin
> > can disolve a hugetlb page it has power to allocate a new one as well.
> 
> Allocating HugeTLB pages after boot is not guaranteed.

yes, and so what?

> > Not to menation that the whole soft offlining is mostly a testing
> > feature so adding a lot of fine grained configuration space seems
> > excessive to me.
> 
> Can you elaborate on "mostly a testing feature"? For example, how does that
> apply to the BIOS/GHES path discussed here?
> 
> https://lore.kernel.org/all/aMkOCmGBhZKhKPrI@hpe.com

OK, so apparently there are some BIOSes which abuse this feature to
mimic a real HW poisoning. This doesn't change the overall picture
though

> If you think this should be handled differently, I'm open to suggestions.

Yes, do not treat hugetlb pages any special. In case there is a HW
related problem which decides to offline portion of the hugetlb page
then bad for you. It wouldn't be too much different if this was handled
through a real HW poisoning.
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-16  8:52     ` Michal Hocko
@ 2026-09-16 13:08       ` David Hildenbrand (Arm)
  2026-09-16 13:19         ` Michal Hocko
  0 siblings, 1 reply; 11+ messages in thread
From: David Hildenbrand (Arm) @ 2026-09-16 13:08 UTC (permalink / raw)
  To: Michal Hocko, Kyle Meyer
  Cc: akpm, corbet, linmiaohe, shuah, tony.luck, jane.chu, jiaqiyan,
	Liam.Howlett, bp, hannes, jack, joel.granados, laoar.shao,
	lorenzo.stoakes, mclapinski, nao.horiguchi, osalvador,
	rafael.j.wysocki, rppt, russ.anderson, shawn.fan, surenb, vbabka,
	linux-acpi, linux-doc, linux-kernel, linux-kselftest, linux-mm


> 
> OK, so apparently there are some BIOSes which abuse this feature to
> mimic a real HW poisoning. This doesn't change the overall picture
> though

Is this really abusing? We know that a page is shaky and will likely go bad in
the future, For now it is still accessible. Trying to migrate off that page stop
using it right away sounds pretty logical to me.

Now, the weird thing is that for hugetlb we wants a different behavior (keep
using the page and ignore the request to evacuate).

> 
>> If you think this should be handled differently, I'm open to suggestions.
> 
> Yes, do not treat hugetlb pages any special. In case there is a HW
> related problem which decides to offline portion of the hugetlb page
> then bad for you. It wouldn't be too much different if this was handled
> through a real HW poisoning.

I agree with that.

-- 
Cheers,

David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-16 13:08       ` David Hildenbrand (Arm)
@ 2026-09-16 13:19         ` Michal Hocko
  2026-09-16 13:28           ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Hocko @ 2026-09-16 13:19 UTC (permalink / raw)
  To: David Hildenbrand (Arm)
  Cc: Kyle Meyer, akpm, corbet, linmiaohe, shuah, tony.luck, jane.chu,
	jiaqiyan, Liam.Howlett, bp, hannes, jack, joel.granados,
	laoar.shao, lorenzo.stoakes, mclapinski, nao.horiguchi,
	osalvador, rafael.j.wysocki, rppt, russ.anderson, shawn.fan,
	surenb, vbabka, linux-acpi, linux-doc, linux-kernel,
	linux-kselftest, linux-mm

On Wed 16-09-26 15:08:45, David Hildenbrand wrote:
> 
> > 
> > OK, so apparently there are some BIOSes which abuse this feature to
> > mimic a real HW poisoning. This doesn't change the overall picture
> > though
> 
> Is this really abusing? We know that a page is shaky and will likely go bad in
> the future, For now it is still accessible. Trying to migrate off that page stop
> using it right away sounds pretty logical to me.

Yes, no dispute on that. But we have HW poisoning for exactly that
purpose, no?

> Now, the weird thing is that for hugetlb we wants a different behavior (keep
> using the page and ignore the request to evacuate).

Exactly

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-16 13:19         ` Michal Hocko
@ 2026-09-16 13:28           ` David Hildenbrand (Arm)
  2026-09-16 13:45             ` Michal Hocko
  0 siblings, 1 reply; 11+ messages in thread
From: David Hildenbrand (Arm) @ 2026-09-16 13:28 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Kyle Meyer, akpm, corbet, linmiaohe, shuah, tony.luck, jane.chu,
	jiaqiyan, Liam.Howlett, bp, hannes, jack, joel.granados,
	laoar.shao, lorenzo.stoakes, mclapinski, nao.horiguchi,
	osalvador, rafael.j.wysocki, rppt, russ.anderson, shawn.fan,
	surenb, vbabka, linux-acpi, linux-doc, linux-kernel,
	linux-kselftest, linux-mm

On 9/16/26 15:19, Michal Hocko wrote:
> On Wed 16-09-26 15:08:45, David Hildenbrand wrote:
>>
>>>
>>> OK, so apparently there are some BIOSes which abuse this feature to
>>> mimic a real HW poisoning. This doesn't change the overall picture
>>> though
>>
>> Is this really abusing? We know that a page is shaky and will likely go bad in
>> the future, For now it is still accessible. Trying to migrate off that page stop
>> using it right away sounds pretty logical to me.
> 
> Yes, no dispute on that. But we have HW poisoning for exactly that
> purpose, no?

Well, that tells you that the page content is effectively gone and should be
tried to be recovered / migrated away. Unless I am messing up terminology here.

-- 
Cheers,

David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-16 13:28           ` David Hildenbrand (Arm)
@ 2026-09-16 13:45             ` Michal Hocko
  2026-09-16 14:30               ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Hocko @ 2026-09-16 13:45 UTC (permalink / raw)
  To: David Hildenbrand (Arm)
  Cc: Kyle Meyer, akpm, corbet, linmiaohe, shuah, tony.luck, jane.chu,
	jiaqiyan, Liam.Howlett, bp, hannes, jack, joel.granados,
	laoar.shao, lorenzo.stoakes, mclapinski, nao.horiguchi,
	osalvador, rafael.j.wysocki, rppt, russ.anderson, shawn.fan,
	surenb, vbabka, linux-acpi, linux-doc, linux-kernel,
	linux-kselftest, linux-mm

On Wed 16-09-26 15:28:01, David Hildenbrand wrote:
> On 9/16/26 15:19, Michal Hocko wrote:
> > On Wed 16-09-26 15:08:45, David Hildenbrand wrote:
> >>
> >>>
> >>> OK, so apparently there are some BIOSes which abuse this feature to
> >>> mimic a real HW poisoning. This doesn't change the overall picture
> >>> though
> >>
> >> Is this really abusing? We know that a page is shaky and will likely go bad in
> >> the future, For now it is still accessible. Trying to migrate off that page stop
> >> using it right away sounds pretty logical to me.
> > 
> > Yes, no dispute on that. But we have HW poisoning for exactly that
> > purpose, no?
> 
> Well, that tells you that the page content is effectively gone and should be
> tried to be recovered / migrated away. Unless I am messing up terminology here.

Maybe it is me messing up the terminology...
But I guess we have established that whether soft offlining is being
abused or not, excluding hugetlb through a configuration is just a wrong
thing to do.
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages
  2026-09-16 13:45             ` Michal Hocko
@ 2026-09-16 14:30               ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 11+ messages in thread
From: David Hildenbrand (Arm) @ 2026-09-16 14:30 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Kyle Meyer, akpm, corbet, linmiaohe, shuah, tony.luck, jane.chu,
	jiaqiyan, Liam.Howlett, bp, hannes, jack, joel.granados,
	laoar.shao, lorenzo.stoakes, mclapinski, nao.horiguchi,
	osalvador, rafael.j.wysocki, rppt, russ.anderson, shawn.fan,
	surenb, vbabka, linux-acpi, linux-doc, linux-kernel,
	linux-kselftest, linux-mm

On 9/16/26 15:45, Michal Hocko wrote:
> On Wed 16-09-26 15:28:01, David Hildenbrand wrote:
>> On 9/16/26 15:19, Michal Hocko wrote:
>>>
>>> Yes, no dispute on that. But we have HW poisoning for exactly that
>>> purpose, no?
>>
>> Well, that tells you that the page content is effectively gone and should be
>> tried to be recovered / migrated away. Unless I am messing up terminology here.
> 
> Maybe it is me messing up the terminology...
> But I guess we have established that whether soft offlining is being
> abused or not, excluding hugetlb through a configuration is just a wrong
> thing to do.

Yes, it's odd that you wouldn't want to evacuate hugetlb but everything else.

-- 
Cheers,

David

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-09-16 14:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-14 23:49 [PATCH v3] mm/memory-failure: Support disabling soft offline for HugeTLB pages Kyle Meyer
2026-09-15  0:37 ` Andrew Morton
2026-09-15  0:57   ` Kyle Meyer
2026-09-15  8:31 ` Michal Hocko
2026-09-15 17:55   ` Kyle Meyer
2026-09-16  8:52     ` Michal Hocko
2026-09-16 13:08       ` David Hildenbrand (Arm)
2026-09-16 13:19         ` Michal Hocko
2026-09-16 13:28           ` David Hildenbrand (Arm)
2026-09-16 13:45             ` Michal Hocko
2026-09-16 14:30               ` David Hildenbrand (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®