Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3349310imm; Thu, 17 May 2018 07:25:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZowz+rYphSHge6QfcInansCWHXzVLeXAWytyjwuKUdcguXyZ2tZFAz/prsQW4aPUzI0Hz3c X-Received: by 2002:a65:6182:: with SMTP id c2-v6mr4354626pgv.219.1526567122117; Thu, 17 May 2018 07:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526567122; cv=none; d=google.com; s=arc-20160816; b=cRER3B2RZnjkBzvdFq0bG0Zb0YTE9no5C9zuwpFJSXBCh+0wPwqx8kxDTQxl6HwRHf UsdURF3TjUrDmt5chE8DP7q+gYxWNlYpyMoA1nlgj/VXYyvH24Yn3qSCNxLyoQhBBfho QA30RqVX/dFJUwQW94XMW+Vikp0iVRT3eyYUMqAyCME4/HV3eid6PKVFjt1LtHfGkXts 4kt7+0YZSN+A6jLD1YTZ9o5rWsA8E5KZ0v4Y42f9yL2yClGCCJPLtrVYRZ4691Rfh3l2 q/WGyw5siO5T7ANaBb10hmpoTWiatugf+QjUJNi7/fn6m8NFs+iiWZllvbYZQRh0ZF91 pPvg== 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:dkim-signature:arc-authentication-results; bh=njhp+GvniPZVryoDHsUAjWzdV5ej1EtDbarLXHc0jW8=; b=KFqddVhBgrZHkjqQOMBVZxeUmTqf96IIHyKxLRayzXw7tbAuWoZoqBT2X6EeEUJkfy 441JqeXM84J2cTf4h/prE1pBqlGTqvdK+6XY1NA+kKIxZqXZGkZEUuTUEFORdcZCs0gX 3Y2mu4/8DH+EdSz+UjCVGtdfIFiGt482dclrvL48ioxrBRkk8qZ217kpgfIrrwBM96vY ZYqteD7oSscrxy3PmMJF9dFrpb38jEFgr5H48hkjdZH3dSx5R0Oy4JA0FFVn2qpWLpIe NFjoPl7VJyXjlHmQb5WcRyx30Vup7WMxzT3YlHH1M5M5LEG333DR7b0nLOsBuaNI4xq1 DCCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lS0+/fTr; 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 bb5-v6si5004892plb.80.2018.05.17.07.25.08; Thu, 17 May 2018 07:25:22 -0700 (PDT) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lS0+/fTr; 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 S1752457AbeEQOXs (ORCPT + 99 others); Thu, 17 May 2018 10:23:48 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:60768 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752408AbeEQOXg (ORCPT ); Thu, 17 May 2018 10:23:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=njhp+GvniPZVryoDHsUAjWzdV5ej1EtDbarLXHc0jW8=; b=lS0+/fTrXLBE0VEp6gH2fUIH3 4b+HYpN1wuYWWLs5R9a3NS/hc6OlqX99rmvMeUKtNwKS3SpTRA4XVKsQRN0aL+uMk4wHoQ1kfA+P/ RTaJIXNy+a7u/WXR1F4JgWvzp0YbtffcskiN8yQpnGTzQbJNiahkkap9UaHrlv1nHzcV7TuC/9pfs w34xSeEGUjjKfL/emqi3z7HgYR2ZRs5DEQtxSf1uTwPdFQaQkx99Cct4L8Int3AEBh6Atb/dVGLwy ZwJnF5g8VFYBnys0OX9Caic6l9y6StSHWMIEguOd+8HtSvdeKU1bm6DrHTzJ48UhkXE8ip4yVGXQ/ btFWYPvBQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJJoS-0006cl-GY; Thu, 17 May 2018 14:23:25 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4806D2029F1C1; Thu, 17 May 2018 16:23:22 +0200 (CEST) Date: Thu, 17 May 2018 16:23:22 +0200 From: Peter Zijlstra To: "Paul E. McKenney" Cc: Mike Galbraith , Matt Fleming , Ingo Molnar , linux-kernel@vger.kernel.org, Michal Hocko Subject: Re: cpu stopper threads and load balancing leads to deadlock Message-ID: <20180517142322.GU12217@hirez.programming.kicks-ass.net> References: <1525351221.9956.4.camel@gmx.de> <20180503124943.GB12217@hirez.programming.kicks-ass.net> <1525354359.5576.1.camel@gmx.de> <20180503135617.GC12217@hirez.programming.kicks-ass.net> <1525357015.5577.2.camel@gmx.de> <20180503144450.GD12217@hirez.programming.kicks-ass.net> <20180503161231.GI26088@linux.vnet.ibm.com> <20180503164508.GG12217@hirez.programming.kicks-ass.net> <1526358626.19125.0.camel@gmx.de> <20180517140345.GI3803@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180517140345.GI3803@linux.vnet.ibm.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 17, 2018 at 07:03:45AM -0700, Paul E. McKenney wrote: > On Tue, May 15, 2018 at 06:30:26AM +0200, Mike Galbraith wrote: > I have not queued it, but given Peter's Signed-off-by and your Tested-by > I would be happy to do so. And a Changelog of course :-) --- From: Peter Zijlstra Subject: rcu/x86: Provide early rcu_cpu_starting() callback The x86/mtrr code does horrific things because hardware. It uses stop_machine_from_inactive_cpu(), which does a wakeup (of the stopper thread on another CPU), which uses RCU, all before the CPU is onlined. RCU complains about this, because wakeups use RCU and RCU does (rightfully) not consider offline CPUs for grace-periods. Fix this by initializing RCU way early in the MTRR case. Tested-by: Mike Galbraith Signed-off-by: Peter Zijlstra (Intel) --- > > > diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c > > > index 7468de429087..07360523c3ce 100644 > > > --- a/arch/x86/kernel/cpu/mtrr/main.c > > > +++ b/arch/x86/kernel/cpu/mtrr/main.c > > > @@ -793,6 +793,9 @@ void mtrr_ap_init(void) > > > > > > if (!use_intel() || mtrr_aps_delayed_init) > > > return; > > > + > > > + rcu_cpu_starting(smp_processor_id()); > > > + > > > /* > > > * Ideally we should hold mtrr_mutex here to avoid mtrr entries > > > * changed, but this routine will be called in cpu boot time, > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > > index 2a734692a581..4dab46950fdb 100644 > > > --- a/kernel/rcu/tree.c > > > +++ b/kernel/rcu/tree.c > > > @@ -3775,6 +3775,8 @@ int rcutree_dead_cpu(unsigned int cpu) > > > return 0; > > > } > > > > > > +static DEFINE_PER_CPU(int, rcu_cpu_started); > > > + > > > /* > > > * Mark the specified CPU as being online so that subsequent grace periods > > > * (both expedited and normal) will wait on it. Note that this means that > > > @@ -3796,6 +3798,11 @@ void rcu_cpu_starting(unsigned int cpu) > > > struct rcu_node *rnp; > > > struct rcu_state *rsp; > > > > > > + if (per_cpu(rcu_cpu_started, cpu)) > > > + return; > > > + > > > + per_cpu(rcu_cpu_started, cpu) = 1; > > > + > > > for_each_rcu_flavor(rsp) { > > > rdp = per_cpu_ptr(rsp->rda, cpu); > > > rnp = rdp->mynode; > > > @@ -3852,6 +3859,8 @@ void rcu_report_dead(unsigned int cpu) > > > preempt_enable(); > > > for_each_rcu_flavor(rsp) > > > rcu_cleanup_dying_idle_cpu(cpu, rsp); > > > + > > > + per_cpu(rcu_cpu_started, cpu) = 0; > > > } > > > > > > /* Migrate the dead CPU's callbacks to the current CPU. */ > > >