From: Yury Norov <yury.norov@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Thorsten Blum <thorsten.blum@linux.dev>,
Zqiang <qiang.zhang1211@gmail.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] smp: Defer check for local execution in smp_call_function_many_cond()
Date: Tue, 10 Jun 2025 14:59:06 -0400 [thread overview]
Message-ID: <aEiAepW_zRYtC1Is@yury> (raw)
In-Reply-To: <20250606202732.426551-5-yury.norov@gmail.com>
On Fri, Jun 06, 2025 at 04:27:31PM -0400, Yury Norov wrote:
> From: "Yury Norov [NVIDIA]" <yury.norov@gmail.com>
>
> Defer check for local execution to the actual place where it is needed,
> and save some stack on a useless local variable.
>
> Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
> ---
> kernel/smp.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/smp.c b/kernel/smp.c
> index 715190669e94..867f79689684 100644
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -779,7 +779,6 @@ static void smp_call_function_many_cond(const struct cpumask *mask,
> bool wait = scf_flags & SCF_WAIT;
> int nr_cpus = 0;
> bool run_remote = false;
> - bool run_local = false;
>
> lockdep_assert_preemption_disabled();
>
> @@ -801,11 +800,6 @@ static void smp_call_function_many_cond(const struct cpumask *mask,
> */
> WARN_ON_ONCE(!in_task());
>
> - /* Check if we need local execution. */
> - if ((scf_flags & SCF_RUN_LOCAL) && cpumask_test_cpu(this_cpu, mask) &&
> - (!cond_func || cond_func(this_cpu, info)))
> - run_local = true;
> -
> /* Check if we need remote execution, i.e., any CPU excluding this one. */
> if (cpumask_any_and_but(mask, cpu_online_mask, this_cpu) < nr_cpu_ids) {
> run_remote = true;
> @@ -853,7 +847,9 @@ static void smp_call_function_many_cond(const struct cpumask *mask,
> run_remote = false;
> }
>
> - if (run_local) {
> + /* Check if we need local execution. */
> + if ((scf_flags & SCF_RUN_LOCAL) & cpumask_test_cpu(this_cpu, mask) &&
> + (!cond_func || cond_func(this_cpu, info))) {
Dan Carpenter's robot pointed the bug here: it should be:
(scf_flags & SCF_RUN_LOCAL) && cpumask_test_cpu(this_cpu, mask)
I'll resend it shortly.
Thanks, Dan!
> unsigned long flags;
>
> local_irq_save(flags);
> --
> 2.43.0
prev parent reply other threads:[~2025-06-10 18:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-06 20:27 [PATCH 0/4] smp: Improve on cpumasks handling Yury Norov
2025-06-06 20:27 ` [PATCH 1/4] smp: Improve locality in smp_call_function_any() Yury Norov
2025-06-06 20:27 ` [PATCH 2/4] smp: Use cpumask_any_but() in smp_call_function_many_cond() Yury Norov
2025-06-06 20:27 ` [PATCH 3/4] smp: Don't wait until remote work done if not needed " Yury Norov
2025-06-06 20:27 ` [PATCH 4/4] smp: Defer check for local execution " Yury Norov
2025-06-10 18:59 ` Yury Norov [this message]
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=aEiAepW_zRYtC1Is@yury \
--to=yury.norov@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang1211@gmail.com \
--cc=tglx@linutronix.de \
--cc=thorsten.blum@linux.dev \
/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