From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Joel Granados <joel.granados@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jianlin Shi <shijianlin11@foxmail.com>,
Kees Cook <kees@kernel.org>,
linux-mm@kvack.org, hannes@cmpxchg.org, surenb@google.com,
mhocko@suse.com, jackmanb@google.com, ziy@nvidia.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] mm/page_alloc: only update lowmem_reserve_ratio on sysctl write
Date: Tue, 4 Aug 2026 16:33:37 +0200 [thread overview]
Message-ID: <de96dcdb-f981-467c-b95b-262f70f95d23@kernel.org> (raw)
In-Reply-To: <k53aljpl7v7naqs5fj4i4po6tu4grkzu5nui4h37orwt6v7bqo@sw4frf2ystmi>
On 8/4/26 14:20, Joel Granados wrote:
> On Mon, Aug 03, 2026 at 10:27:46AM +0200, Vlastimil Babka (SUSE) wrote:
>> +Cc: sysctl maintainers
>>
>> On 8/1/26 20:44, Andrew Morton wrote:
>> > On Sat, 1 Aug 2026 23:11:25 +0800 Jianlin Shi <shijianlin11@foxmail.com> wrote:
>> >
>> >> 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.
>> >
>> > AI review suggest that this caused a new problem:
>> >
>> > https://sashiko.dev/#/patchset/tencent_1BB7A5C4D5EEA67346634417753190E92A09@qq.com
>> >
>> > Not sure what to do here. Perhaps pass proc_dointvec_minmax() a
>> > temporary then copy that into sysctl_lowmem_reserve_ratio if all
>> > proc_dointvec_minmax() returns "OK".
>>
>> Seeing the v4 [1] it seems easier to keep the current fixup code until
>> proc_dointvec_minmax() is fixed.
>
> 1. V3 -vs- V4:
> I would prefer V4 as it actually prevents the partial write of the
> vector in case of an error & returns that error back to user space.
> Whereas V3 returns the error back to user space but keeps the partial
> write.
>
> That patterns of using a temp ctltable entry is seldom used but not
> unheard of.
>
>>
>> > But really this is a flaw in proc_dointvec_minmax() isn't it? It
>> > shouldn't update the table data until all the data has been validated.
>>
>> I agree. What do the maintainers think?
>
> I agree. The arrays being changed are not too big so we can easily have
> a staging variable that that gets written when all validations are done.
> The only "con" that I see for this solution is for when these
> proc_handlers get used with temp variables; in these cases we will be
> staging an already staging variable.
Maybe have a variant of the function e.g. proc_dointvec_minmax() that takes
an extra parameter pointing to the staging array? That way the caller can
allocate it on stack according to its needs (like v4 does) but there's no
fiddling with a temp ctltable entry. That way the core code doesn't need a
staging variable big enough for everyone, and users can be converted to the
new variant, and there's not double staging at any point.
> I have added this to my Todos
>
> Best
>
next prev parent reply other threads:[~2026-08-04 14:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 10:32 [PATCH] mm/page_alloc: only update lowmem_reserve_ratio on sysctl write Jianlin Shi
2026-07-30 15:28 ` Vlastimil Babka (SUSE)
2026-07-31 3:36 ` Jianlin Shi
2026-07-31 3:42 ` [PATCH v2] " Jianlin Shi
2026-07-31 8:06 ` Vlastimil Babka (SUSE)
2026-08-01 7:36 ` Johannes Weiner
2026-08-01 15:11 ` [PATCH v3] " Jianlin Shi
2026-08-01 18:44 ` Andrew Morton
2026-08-02 14:31 ` Jianlin Shi
2026-08-03 8:27 ` Vlastimil Babka (SUSE)
2026-08-04 12:20 ` Joel Granados
2026-08-04 14:33 ` Vlastimil Babka (SUSE) [this message]
2026-08-06 8:27 ` Joel Granados
2026-08-02 14:57 ` [PATCH v4] " Jianlin Shi
2026-08-04 0:48 ` Andrew Morton
2026-08-06 7:32 ` Jianlin Shi
2026-08-06 8:27 ` [PATCH v5] " Jianlin Shi
2026-08-06 13:50 ` Johannes Weiner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=de96dcdb-f981-467c-b95b-262f70f95d23@kernel.org \
--to=vbabka@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=joel.granados@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=shijianlin11@foxmail.com \
--cc=surenb@google.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox