+ mm-page_alloc-only-update-lowmem_reserve_ratio-on-sysctl-write.patch added to mm-new branch
Andrew Morton <[email protected]> Sat, 01 Aug 2026 11:32:23 -0700
| Newsgroups | org.kernel.vger.mm-commits |
|---|---|
| Message-ID | <[email protected]> |
The patch titled
Subject: mm/page_alloc: only update lowmem_reserve_ratio on sysctl write
has been added to the -mm mm-new branch. Its filename is
mm-page_alloc-only-update-lowmem_reserve_ratio-on-sysctl-write.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-page_alloc-only-update-lowmem_reserve_ratio-on-sysctl-write.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Jianlin Shi <[email protected]>
Subject: mm/page_alloc: only update lowmem_reserve_ratio on sysctl write
Date: Sat, 1 Aug 2026 23:11:25 +0800
lowmem_reserve_ratio_sysctl_handler() ignores the return value of
proc_dointvec_minmax() and always calls setup_per_zone_lowmem_reserve(),
even for read operations.
Fix two issues:
1. Propagate errors from proc_dointvec_minmax() instead of always
returning success. For example, writing non-integer garbage to the
sysctl now returns an error instead of silently succeeding with
unchanged values.
2. Only call setup_per_zone_lowmem_reserve() when the sysctl is
actually written. Reading /proc/sys/vm/lowmem_reserve_ratio should
not recompute derived lowmem_reserve[] and totalreserve_pages when
the inputs did not change, matching min_free_kbytes and
watermark_scale_factor handlers.
Drop the manual "< 1 -> 0" sanitization loop and set .extra1 = SYSCTL_ZERO
on the ctl_table entry so proc_dointvec_minmax() enforces the minimum on
write; negative values now return -EINVAL instead of being silently
coerced to 0 (suggested by Vlastimil Babka).
Link: https://lore.kernel.org/[email protected]
Link: https://lore.kernel.org/linux-mm/[email protected]/
Signed-off-by: Jianlin Shi <[email protected]>
Reviewed-by: Vlastimil Babka (SUSE) <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Brendan Jackman <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Suren Baghdasaryan <[email protected]>
Cc: Zi Yan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---
mm/page_alloc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
--- a/mm/page_alloc.c~mm-page_alloc-only-update-lowmem_reserve_ratio-on-sysctl-write
+++ a/mm/page_alloc.c
@@ -6925,16 +6925,15 @@ static int sysctl_min_slab_ratio_sysctl_
static int lowmem_reserve_ratio_sysctl_handler(const struct ctl_table *table,
int write, void *buffer, size_t *length, loff_t *ppos)
{
- int i;
+ int rc;
- proc_dointvec_minmax(table, write, buffer, length, ppos);
+ rc = proc_dointvec_minmax(table, write, buffer, length, ppos);
+ if (rc)
+ return rc;
- for (i = 0; i < MAX_NR_ZONES; i++) {
- if (sysctl_lowmem_reserve_ratio[i] < 1)
- sysctl_lowmem_reserve_ratio[i] = 0;
- }
+ if (write)
+ setup_per_zone_lowmem_reserve();
- setup_per_zone_lowmem_reserve();
return 0;
}
@@ -7033,6 +7032,7 @@ static const struct ctl_table page_alloc
.maxlen = sizeof(sysctl_lowmem_reserve_ratio),
.mode = 0644,
.proc_handler = lowmem_reserve_ratio_sysctl_handler,
+ .extra1 = SYSCTL_ZERO,
},
#ifdef CONFIG_NUMA
{
_
Patches currently in -mm which might be from [email protected] are
mm-page_alloc-only-update-lowmem_reserve_ratio-on-sysctl-write.patch
ipc-only-destroy-orphaned-shm-segments-on-sysctl-write.patch