From: SeongJae Park <sj@kernel.org>
To: SeongJae Park <sj@kernel.org>
Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
"# 5 . 19 . x" <stable@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Lorenzo Stoakes <ljs@kernel.org>, Michal Hocko <mhocko@suse.com>,
Mike Rapoport <rppt@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Suren Baghdasaryan <surenb@google.com>,
Vlastimil Babka <vbabka@kernel.org>,
damon@lists.linux.dev, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Liew Rui Yan <aethernet65535@gmail.com>
Subject: Re: (sashiko review) [RFC PATCH 1/2] Docs/admin-guide/mm/damon/reclaim: warn commit_inputs vs param updates race
Date: Sat, 28 Mar 2026 10:48:51 -0700 [thread overview]
Message-ID: <20260328174852.53338-1-sj@kernel.org> (raw)
In-Reply-To: <20260328173446.53021-1-sj@kernel.org>
On Sat, 28 Mar 2026 10:34:45 -0700 SeongJae Park <sj@kernel.org> wrote:
> Forwarding Sashiko review for doing discussions via mails.
>
> # review url: https://sashiko.dev/#/patchset/20260328172415.49940-2-sj@kernel.org
> # start of sashiko.dev inline review
> commit 8b189801fc104c5ecc412454a3d8db6a3faf27d6
> Author: SeongJae Park <sj@kernel.org>
>
> Docs/admin-guide/mm/damon/reclaim: warn commit_inputs vs param updates race
>
> This commit adds documentation warning users not to write to module
> parameters while commit_inputs is in progress. This warning is intended to
> help users avoid a race condition that can cause undefined kernel behavior.
>
> Link: https://lore.kernel.org/20260319161620.189392-3-objecting@objecting.org
>
> > diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation/admin-guide/mm/damon/reclaim.rst
> > --- a/Documentation/admin-guide/mm/damon/reclaim.rst
> > +++ b/Documentation/admin-guide/mm/damon/reclaim.rst
> > @@ -71,6 +71,10 @@ of parametrs except ``enabled`` again. Once the re-reading is done, this
> > parameter is set as ``N``. If invalid parameters are found while the
> > re-reading, DAMON_RECLAIM will be disabled.
> >
> > +Once ``Y`` is written to this parametr, the user must not write to any
>
> This isn't a bug, but there is a typo ("parametr") in this line.
Good eye, I will fix this in the next revision.
>
> > +parameters until reading ``commit_inputs`` again returns ``N``. If users
> > +violate this rule, the kernel can do undefined behaviors.
>
> Is it acceptable to document a race condition that leads to undefined
> behavior instead of fixing it?
>
> Even if the module parameter interface is restricted to root, user space
> shouldn't be able to trigger kernel undefined behavior (which could lead to
> memory corruption or crashes) simply by writing to module parameters
> concurrently.
>
> Should the underlying race condition in DAMON_RECLAIM be fixed with proper
> synchronization rather than relying on userspace adherence to a documentation
> warning?
Good callout. In short, I agree for mainline kernel, but I'd argue this may be
enough for stable kernels.
That is, I was also thinking in a way similar to sashiko. But, from the work I
realized the amount of changes for fixing those in stable-backporting-easy way
is not small. Also, given the age of the broken commits (5.19!), I don't think
this is urgent. And again arguably, as long as it is well documented, letting
users break kernel when they want (e.g., sysrq-trigger) is ok...? Let me know
if other humans have different opinion, though.
But for future (mainline), surely this have to be fixed in the code. And
Liew's patch [1] was initially started not for exactly this patch, but will fix
this together. Cc-ing Liew.
So, I'm suggesting to add this documentation for stable kernels, and continue
helping Liew's patch for cleanly removing this awkward behavior in the mianline
and future kernels.
>
> This isn't a bug, but the phrasing "can do undefined behaviors" is slightly
> awkward. Rephrasing to "may exhibit undefined behavior" might be more natural.
Good catch. I will update so in the next version.
[1] https://lore.kernel.org/20260328084524.5451-1-aethernet65535@gmail.com
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-03-28 17:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-28 17:24 [RFC PATCH 0/2] Docs/admin-guide/mm/damon: warn commit_inputs vs other params race SeongJae Park
2026-03-28 17:24 ` [RFC PATCH 1/2] Docs/admin-guide/mm/damon/reclaim: warn commit_inputs vs param updates race SeongJae Park
2026-03-28 17:34 ` (sashiko review) " SeongJae Park
2026-03-28 17:48 ` SeongJae Park [this message]
2026-03-28 17:24 ` [RFC PATCH 2/2] Docs/admin-guide/mm/damon/lru_sort: " SeongJae Park
2026-03-28 17:35 ` (sashiko review) " SeongJae Park
2026-03-28 17:51 ` SeongJae Park
2026-03-28 17:34 ` (sashiko status) [RFC PATCH 0/2] Docs/admin-guide/mm/damon: warn commit_inputs vs other params race SeongJae Park
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=20260328174852.53338-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=aethernet65535@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=damon@lists.linux.dev \
--cc=david@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/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