From: K Prateek Nayak <kprateek.nayak@amd.com>
To: chenjinghuang <chenjinghuang2@huawei.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched/numa: Prevent race on sysctl_numa_balancing static key
Date: Tue, 4 Aug 2026 14:14:59 +0530 [thread overview]
Message-ID: <7bf9d48c-2a74-45b6-bfdc-faf10830f3f1@amd.com> (raw)
In-Reply-To: <a16b82df-1e2f-4378-9d55-03b4988d5c3d@huawei.com>
Hello Chen,
On 8/4/2026 2:05 PM, chenjinghuang wrote:
> You're right - my mistake, I'll move numabalancing_mutex into sysctl_numa_balancing()
> and drop it from the early-init path. No one races during init, so the lock is only
> needed for sysfs writes:
>
> +static DEFINE_MUTEX(numabalancing_mutex);
> +
> static int sysctl_numa_balancing(const struct ctl_table *table, int write,
> void *buffer, size_t *lenp, loff_t *ppos)
> {
> @@ -4666,11 +4668,13 @@ static int sysctl_numa_balancing(const struct ctl_table *table, int write,
> if (err < 0)
> return err;
> if (write) {
> + mutex_lock(&numabalancing_mutex);
nit. You can just use a:
guard(mutex)(&numabalancing_mutex);
> if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) &&
> (state & NUMA_BALANCING_MEMORY_TIERING))
> reset_memory_tiering();
> sysctl_numa_balancing_mode = state;
> __set_numabalancing_state(state);
> + mutex_unlock(&numabalancing_mutex);
... and save on the need to explicitly call unlock here.
> }
> return err;
> }
--
Thanks and Regards,
Prateek
next prev parent reply other threads:[~2026-08-04 8:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 12:30 Chen Jinghuang
2026-08-04 5:09 ` K Prateek Nayak
2026-08-04 8:35 ` chenjinghuang
2026-08-04 8:44 ` K Prateek Nayak [this message]
2026-08-04 8:52 ` chenjinghuang
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=7bf9d48c-2a74-45b6-bfdc-faf10830f3f1@amd.com \
--to=kprateek.nayak@amd.com \
--cc=bsegall@google.com \
--cc=chenjinghuang2@huawei.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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
all inboxes | Powered by JetHome®