The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	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>,
	Christian Loehle <christian.loehle@arm.com>,
	Shrikanth Hegde <sshegde@linux.ibm.com>,
	Phil Auld <pauld@redhat.com>, Mete Durlu <meted@linux.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] sched/fair: Prefer fully idle cores for NOHZ balancing
Date: Tue, 4 Aug 2026 14:16:51 +0200	[thread overview]
Message-ID: <anHYM_yrg3fbjgaF@gpd4> (raw)
In-Reply-To: <CAKfTPtBot57=uXCFGODnF_AtaH9g+GMZrpJc1BGGKwPHCvqS6A@mail.gmail.com>

Hi Vincent and Prateek,

On Tue, Aug 04, 2026 at 12:30:22PM +0200, Vincent Guittot wrote:
> On Tue, 4 Aug 2026 at 11:49, K Prateek Nayak <kprateek.nayak@amd.com> wrote:
> >
> > Hello Vincent,
> >
> > On 8/4/2026 2:12 PM, Vincent Guittot wrote:
> > >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > >> index 37001c63452e5..574b6b3ee922a 100644
> > >> --- a/kernel/sched/fair.c
> > >> +++ b/kernel/sched/fair.c
> > >> @@ -13965,28 +13965,66 @@ static inline int on_null_domain(struct rq *rq)
> > >>  static inline int find_new_ilb(void)
> > >>  {
> > >>         int this_cpu = smp_processor_id();
> > >> -       const struct cpumask *hk_mask;
> > >> -       int ilb_cpu;
> > >> +       struct cpumask *ilb_cpus;
> > >> +       int ilb_cpu, fallback = -1;
> > >> +
> > >> +       lockdep_assert_irqs_disabled();
> > >>
> > >> -       hk_mask = housekeeping_cpumask(HK_TYPE_KERNEL_NOISE);
> > >> +       /*
> > >> +        * Reuse the per-CPU select_rq_mask, which is protected from concurrent
> > >> +        * use on this CPU by having interrupts disabled.
> > >> +        */
> > >> +       ilb_cpus = this_cpu_cpumask_var_ptr(select_rq_mask);
> > >> +       cpumask_and(ilb_cpus, nohz.idle_cpus_mask,
> > >> +                   housekeeping_cpumask(HK_TYPE_KERNEL_NOISE));
> > >>
> > >> -       for_each_cpu_and(ilb_cpu, nohz.idle_cpus_mask, hk_mask) {
> > >> +       for_each_cpu(ilb_cpu, ilb_cpus) {
> > >>                 if (ilb_cpu == this_cpu)
> > >
> > > this_cpu is not idle so you can apply the same as below
> >
> > Dumb question: nohz_balancer_kick() already does a
> > nohz_balance_exit_idle(rq) before trying to find the ilb_cpu via
> > find_new_ilb() so is it even possible for this_cpu to be set on the
> > nohz.idle_cpus_mask here?
> 
> Yes that's a good point, the test is useless
> 
> >
> > Even on weakly ordered systems, reads and writes to the same location
> > (nohz.idle_cpus_mask) cannot get reordered right?
> 
> Yes

Right, checking this_cpu is redundant, I'll remove it and send a v4.

Thanks!
-Andrea

> 
> >
> > >
> > > Other than that looks good to me
> > >
> > >>                         continue;
> > >>
> > >> -               if (idle_cpu(ilb_cpu))
> > >> -                       return ilb_cpu;
> > >> +               if (!idle_cpu(ilb_cpu)) {
> > >
> > > +               if (ilb_cpu == this_cpu || !idle_cpu(ilb_cpu)) {
> >
> > Otherwise, this makes sense.
> >
> > --
> > Thanks and Regards,
> > Prateek
> >

  reply	other threads:[~2026-08-04 12:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 19:19 [PATCH v3] sched/fair: Prefer fully idle cores for NOHZ balancing Andrea Righi
2026-08-04  8:42 ` Vincent Guittot
2026-08-04  9:48   ` K Prateek Nayak
2026-08-04 10:30     ` Vincent Guittot
2026-08-04 12:16       ` Andrea Righi [this message]
2026-08-04 12:36 ` Mete Durlu
2026-08-04 14:58   ` Andrea Righi
2026-08-05  8:59 ` K Prateek Nayak

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=anHYM_yrg3fbjgaF@gpd4 \
    --to=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=christian.loehle@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=meted@linux.ibm.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=pauld@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sshegde@linux.ibm.com \
    --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