Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1354006ybf; Thu, 27 Feb 2020 09:21:26 -0800 (PST) X-Google-Smtp-Source: APXvYqz5VMGrcHg71Gnx4IG3PMQHX4i7Zldeq/wUMdf2E4b7xGgfa21Q3m9ghqnP2sK8Zr5eEADs X-Received: by 2002:a9d:7509:: with SMTP id r9mr646075otk.270.1582824085948; Thu, 27 Feb 2020 09:21:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582824085; cv=none; d=google.com; s=arc-20160816; b=UYFnxf47YTmpibWNTiL2seCQF6i+tKTjNEhw/H1K7+7B31Y9ZhvUP5cPHHsMH7DBQ1 FB5RmRLcXB8iMN/QiqIg5ZyrFayPX1TA8op6ZEejfe4vSfYMDR7cq6fnzD6i4AOh0pnV KqE3zjsnHVlEVgicFIZ7FjrNnY4TmQTyPu137guRat4jYRZMyuSPLg1xnW7r8sDDX9wR 1Mw2TzrA5W6NyMpA0R7p5PLwLLHN5KuX7kw/xDl5bSR97Jopw4hWGUFL5+MxiTwdPH2J IOzm7JGTwjC/AcBW4mYuT44OfpoFWv3/oZontVW8GZhsx7O8RLLIpZjKGH4P+ivOkt5F ZZXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8yCpbm88LaUiz7E9L3nD3mXW5xoRg7MZnhyAl4kYHbk=; b=s4isSaLCUBG51Wk0miodb828okdPvS1BwWybNIehPgp9oSwRFZpg3oH1NMFnC/fKoU YHf/jQ87VDs2vjW1hel0wBxyimsYBIMn/Vl3hJPyKbX4KZKS56Efde8Y2QNz7ixuCroq iKIImSl6FL5A0bsAka22EDEhYZN/TQW2auijIHpfNZAiW72KCCBkxoB/tQJ4/4jxjggH oCpagws6qWeYSE340LAN+476qKLE4LUTy1+Gqpk/qbnLXA0UvLXi/j62YvATyTZAAdBV K7cw+1H5j/+6zFokMYtivmgf557vPlL01hOwWv8AwyncR1jNeChzEB0e/KrRdLx4GHK6 e9xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7si206272oie.265.2020.02.27.09.21.11; Thu, 27 Feb 2020 09:21:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729863AbgB0RTj (ORCPT + 99 others); Thu, 27 Feb 2020 12:19:39 -0500 Received: from outbound-smtp24.blacknight.com ([81.17.249.192]:51229 "EHLO outbound-smtp24.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728413AbgB0RTi (ORCPT ); Thu, 27 Feb 2020 12:19:38 -0500 Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp24.blacknight.com (Postfix) with ESMTPS id B2210C0ABC for ; Thu, 27 Feb 2020 17:19:36 +0000 (GMT) Received: (qmail 25326 invoked from network); 27 Feb 2020 17:19:36 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.18.57]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 27 Feb 2020 17:19:36 -0000 Date: Thu, 27 Feb 2020 17:19:34 +0000 From: Mel Gorman To: Qian Cai Cc: Valentin Schneider , Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , 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" Message-ID: <20200227171934.GI3818@techsingularity.net> References: <1582812549.7365.134.camel@lca.pw> <1582814862.7365.135.camel@lca.pw> <1582821327.7365.137.camel@lca.pw> <1582822024.7365.139.camel@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1582822024.7365.139.camel@lca.pw> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 27, 2020 at 11:47:04AM -0500, Qian Cai wrote: > 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, > Thanks for reporting this! The proposed fix would be a lot of rcu locks and unlocks. While they are cheap, they're not free and it's a fairly standard pattern to acquire the rcu lock when scanning CPUs during a domain search (load balancing, nohz balance, idle balance etc). While in this context the lock is only needed for SMT, I do not think it's worthwhile fine-graining this or conditionally acquiring the rcu lock so will we keep it simple? diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 11cdba201425..d34ac4ea5cee 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1592,6 +1592,7 @@ static void update_numa_stats(struct task_numa_env *env, memset(ns, 0, sizeof(*ns)); ns->idle_cpu = -1; + rcu_read_lock(); for_each_cpu(cpu, cpumask_of_node(nid)) { struct rq *rq = cpu_rq(cpu); @@ -1611,6 +1612,7 @@ static void update_numa_stats(struct task_numa_env *env, idle_core = numa_idle_core(idle_core, cpu); } } + rcu_read_unlock(); ns->weight = cpumask_weight(cpumask_of_node(nid));