Re: [PATCH v5] mm/page_alloc: only update lowmem_reserve_ratio on sysctl write

From: Andrew Morton

Date: Thu Aug 06 2026 - 17:20:54 EST


On Thu, 6 Aug 2026 09:50:16 -0400 Johannes Weiner <hannes@xxxxxxxxxxx> wrote:

> > - proc_dointvec_minmax(table, write, buffer, length, ppos);
> > + if (!write)
> > + return proc_dointvec_minmax(table, write, buffer, length, ppos);
> >
> > - for (i = 0; i < MAX_NR_ZONES; i++) {
> > - if (sysctl_lowmem_reserve_ratio[i] < 1)
> > - sysctl_lowmem_reserve_ratio[i] = 0;
> > - }
>
> This could use a comment. How about:
>
> /*
> * proc_dointvec_max() works incrementally. Use a buffer
> * and only set the values if all of them parse cleanly.
> */
>

I added a fixlet:

--- a/mm/page_alloc.c~mm-page_alloc-only-update-lowmem_reserve_ratio-on-sysctl-write-fix
+++ a/mm/page_alloc.c
@@ -6932,6 +6932,10 @@ static int lowmem_reserve_ratio_sysctl_h
if (!write)
return proc_dointvec_minmax(table, write, buffer, length, ppos);

+ /*
+ * proc_dointvec_max() works incrementally. Use a buffer and only set
+ * the values if all of them parse cleanly.
+ */
memcpy(ratio, sysctl_lowmem_reserve_ratio, sizeof(ratio));
tmp.data = ratio;

_

Sashiko got all upset about concurrency issues:

https://sashiko.dev/#/patchset/tencent_A860C873956A52E26AD8D309A308A241BA08@xxxxxx

But I think I'm hearing from Joel is that the longer-term plan is to fix
all this up within proc_dointvec_minmax()?