linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qian Cai <cai@lca.pw>
To: Valentin Schneider <valentin.schneider@arm.com>
Cc: Mel Gorman <mgorman@techsingularity.net>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Juri Lelli <juri.lelli@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	paulmck@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: suspicious RCU due to "Prefer using an idle CPU as a migration target instead of comparing tasks"
Date: Thu, 27 Feb 2020 11:47:04 -0500	[thread overview]
Message-ID: <1582822024.7365.139.camel@lca.pw> (raw)
In-Reply-To: <1582821327.7365.137.camel@lca.pw>

On Thu, 2020-02-27 at 11:35 -0500, Qian Cai wrote:
> On Thu, 2020-02-27 at 15:26 +0000, Valentin Schneider wrote:
> > On Thu, Feb 27 2020, Qian Cai wrote:
> > 
> > > On Thu, 2020-02-27 at 09:09 -0500, Qian Cai wrote:
> > > > The linux-next commit ff7db0bf24db ("sched/numa: Prefer using an idle CPU as a
> > > > migration target instead of comparing tasks") introduced a boot warning,
> > > 
> > > This?
> > > 
> > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > > index a61d83ea2930..ca780cd1eae2 100644
> > > --- a/kernel/sched/fair.c
> > > +++ b/kernel/sched/fair.c
> > > @@ -1607,7 +1607,9 @@ static void update_numa_stats(struct task_numa_env *env,
> > > if (ns->idle_cpu == -1)
> > > ns->idle_cpu = cpu;
> > > 
> > > +rcu_read_lock();
> > > idle_core = numa_idle_core(idle_core, cpu);
> > > +rcu_read_unlock();
> > > }
> > > }
> > > 
> > 
> > 
> > Hmph right, we have
> > numa_idle_core()->test_idle_cores()->rcu_dereference().
> > 
> > Dunno if it's preferable to wrap the entirety of update_numa_stats() or
> > if that fine-grained read-side section is ok.
> 
> I could not come up with a better fine-grained one than this.

Correction -- this one,

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a61d83ea2930..580d56f9c10b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1561,10 +1561,18 @@ numa_type numa_classify(unsigned int imbalance_pct,
 static inline int numa_idle_core(int idle_core, int cpu)
 {
 #ifdef CONFIG_SCHED_SMT
+	bool idle;
+
 	if (!static_branch_likely(&sched_smt_present) ||
-	    idle_core >= 0 || !test_idle_cores(cpu, false))
+	    idle_core >= 0)
 		return idle_core;
 
+	rcu_read_lock();
+	idle = test_idle_cores(cpu, false);
+	rcu_read_unlock();
+
+	if (!idle)
+		return idle_core;
 	/*
 	 * Prefer cores instead of packing HT siblings
 	 * and triggering future load balancing.

  reply	other threads:[~2020-02-27 16:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-27 14:09 suspicious RCU due to "Prefer using an idle CPU as a migration target instead of comparing tasks" Qian Cai
2020-02-27 14:47 ` Qian Cai
2020-02-27 15:26   ` Valentin Schneider
2020-02-27 16:35     ` Qian Cai
2020-02-27 16:47       ` Qian Cai [this message]
2020-02-27 17:19         ` Mel Gorman
2020-02-27 17:30           ` Valentin Schneider
2020-02-27 18:56           ` Paul E. McKenney

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=1582822024.7365.139.camel@lca.pw \
    --to=cai@lca.pw \
    --cc=a.p.zijlstra@chello.nl \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=mingo@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=valentin.schneider@arm.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;
as well as URLs for NNTP newsgroup(s).