Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1434816ybf; Thu, 27 Feb 2020 10:56:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxcOweLmZwQokoOc9GVEg95p5L7Y4t++6D/hpCj0N4tAIbUA4oy25FM9AheTsEzfGj6SLlD X-Received: by 2002:a9d:750b:: with SMTP id r11mr284058otk.310.1582829811119; Thu, 27 Feb 2020 10:56:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582829811; cv=none; d=google.com; s=arc-20160816; b=aIZntooGOgt4SWflpaBmZHhxF5t4XsgonBoE8nXv4fnjlOMloO3vteluEtiPSZWjha ZMeTTHsm2X8qEDKJY42q3BxdsAGjEYDpogBmdoZUfEO4CpjlQxgX2pzyzT3yr8gsA4QR +IK8ZpGAbl1DbQhC0oVfhp1+aKOc5vQnmcgTKP1L/uqW7nsrUMeqX/n8NBeCPUm7yc9h XqPUdRIZyZg7EaDN4OEuCmlOpPTqUOudP/QdJ4GzF6aWxEJBlFK7fTizlMucBZiIe7W2 wzE3LW86IBCbGtUYhlUcPthQqtjIR7gBT3HH0/ZcrEfNoMhcgeb+diIZW+wtLZSO/aKG ccAg== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=M15DG/eqbwk9x0tI7DbIhtY0b9XNccWT+qeR2s1YpQI=; b=if6tn8SSN3vG6Wl/p6ZyUnOIwIbI31SiYoyOzj76lp+nyhdrwJ1CB9HKsRrMzNxP3g ch0VjCeY9o0Y4lwEFn4QEk4mnEdRBSlq2LXEC9jujfm+xt97EigWlKQ2YuxhgO5b8kN9 B2KxLQs0+tyhUq+q2ZnUUa8q6QtKgbE+7DkJIbHsDogaktBIrKqlrMLrAhmM1NnbEVfN jLqM54jawRO+8K5Or849nT7daj30wyqMHVJ40n2DHczBIg8Sl+hVX0gCbWXJrL4NowLd IyZdvP5AaQa5ll4c3iyvNNfbeZhrJkme0wbMsVCfjG5c54LOayhjjI5i8TuNL7x7n2/H lx1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Zj1TBHwt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7si65307ote.49.2020.02.27.10.56.37; Thu, 27 Feb 2020 10:56:51 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Zj1TBHwt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730433AbgB0S4J (ORCPT + 99 others); Thu, 27 Feb 2020 13:56:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:39996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729564AbgB0S4I (ORCPT ); Thu, 27 Feb 2020 13:56:08 -0500 Received: from paulmck-ThinkPad-P72.home (unknown [163.114.132.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A8EE1246A0; Thu, 27 Feb 2020 18:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582829767; bh=LQ0WXpCM8stTZwuekeWBvrZIpMZ4vMG09DgE+tW0alM=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Zj1TBHwtCe6lsfbnWxvbU9UjcbNrn6iznIUA8E4IBU6un3v8UopUr252wzDqsvqYG R8NM6i01gs9TCU5zwnIk75Ynfz90tuKlgqKEhjXhIywHyp0SuA7SWWhNKGbdFQsO9m IzmVAUtIBpUu4kzLBqeU6PR9HQl1GkjXBsq1oD80= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 16BCD35211EA; Thu, 27 Feb 2020 10:56:07 -0800 (PST) Date: Thu, 27 Feb 2020 10:56:07 -0800 From: "Paul E. McKenney" To: Mel Gorman Cc: Qian Cai , Valentin Schneider , Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , 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: <20200227185607.GK2935@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org 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> <20200227171934.GI3818@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200227171934.GI3818@techsingularity.net> User-Agent: Mutt/1.9.4 (2018-02-28) 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 05:19:34PM +0000, Mel Gorman wrote: > 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? Indeed, scanning CPUs within a single RCU read-side critical section should be OK. As long as each CPU isn't burning too much time. ;-) Thanx, Paul > 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)); >