Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp116728ybl; Thu, 29 Aug 2019 19:48:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkAJf4SAYkTCuzsENsrt46HWyb7CIq6wi3zkAHq1BI0/RzdpSckZKK3C1cLs1QTyMC8eIy X-Received: by 2002:a62:5501:: with SMTP id j1mr15132470pfb.166.1567133290058; Thu, 29 Aug 2019 19:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567133290; cv=none; d=google.com; s=arc-20160816; b=v/vxesd4ZrWqx89MVyEu32xIdnhz1gLqbFddnPoaEuSJJuFxUMKo9zwdeYhxoouho8 itCUu/FFMw2uAlmph8vjCv4tGy9060/Dp6C8C/JPOmqh+7Tvsbmvp+CTCpTyI4l540Op 4Tjp/z0yaZVbiNMlLKIEoujOvfPZ80XHm3//JbA5mWLSYuLD1qPkPaham6EG5l2/J0Gw AgIsy7uDSVQOzb6eiqt6GtuPkbE2VI1aYy0MTUf9Db5Ddsw/52fKKGXZxTR0JboeBYb0 ykq/EPaExvnivRqUQx+89eTeCLEnq2ru7wkWLkvqoz+eALL2iYXmJ4NUh4QUuC7uyxJa 6o4w== 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; bh=ILSPdVaQt6z7Jwwr6J+4ZPjhUB1SWgt0r4JtulPGWZM=; b=BzfHdteRfxdywg9tsbwaR8FcwJnEA1gTuTEFGNxH0+DE8hCAOtASOLkhbqBMc2Cnlh n9NdUlbvxv1Uoty2F/1Ge+tEjbezYiYBDvKH1pugk8bz96JiMZjgTuYv3nWm14C5PnEp 38L/k7QNJIiGKocTk695x2A+5drVxwYKHtq/QLP7uZABQ1wSu2JgEvC4qqfB49fxw3tb ZQHBsXSjC5KyegQHx2e9kDe6kdW0mAqkwOx9uLAKnh8nysEMwlI2XbamGuUmKKIK83y3 3CO+x82NIfuGAqwa+vD6M4IYqfJvmPHOZRdHWb0VQ4EKrXq4K8T4/8RrtzbHDKmRR3iF 4D1A== 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; dmarc=fail (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 n184si3323111pgn.399.2019.08.29.19.47.46; Thu, 29 Aug 2019 19:48:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727410AbfH3Cqe (ORCPT + 99 others); Thu, 29 Aug 2019 22:46:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55452 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727066AbfH3Cqd (ORCPT ); Thu, 29 Aug 2019 22:46:33 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7U2fliL024217; Thu, 29 Aug 2019 22:45:59 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2uppvcfjnc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 22:45:59 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x7U2fwJn024344; Thu, 29 Aug 2019 22:45:59 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2uppvcfjmu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 22:45:59 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x7U2iZpW009104; Fri, 30 Aug 2019 02:45:58 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma04wdc.us.ibm.com with ESMTP id 2ujvv709n8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Aug 2019 02:45:58 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7U2jvcR48496946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2019 02:45:57 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B89AB2065; Fri, 30 Aug 2019 02:45:57 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 557BBB205F; Fri, 30 Aug 2019 02:45:57 +0000 (GMT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.159.7]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 30 Aug 2019 02:45:57 +0000 (GMT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id EF33C16C1D7F; Thu, 29 Aug 2019 19:45:56 -0700 (PDT) Date: Thu, 29 Aug 2019 19:45:56 -0700 From: "Paul E. McKenney" To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, Frederic Weisbecker , Jonathan Corbet , Josh Triplett , kernel-team@android.com, Lai Jiangshan , linux-doc@vger.kernel.org, Mathieu Desnoyers , Mauro Carvalho Chehab , rcu@vger.kernel.org, Steven Rostedt Subject: Re: [RFC v1 2/2] rcu/tree: Remove dynticks_nmi_nesting counter Message-ID: <20190830024556.GZ4125@linux.ibm.com> Reply-To: paulmck@kernel.org References: <20190828221444.GA100789@google.com> <20190828231247.GE26530@linux.ibm.com> <20190829015155.GB100789@google.com> <20190829034336.GD4125@linux.ibm.com> <20190829144355.GE63638@google.com> <20190829151325.GF63638@google.com> <20190829161301.GQ4125@linux.ibm.com> <20190829171454.GA115245@google.com> <20190830004756.GW4125@linux.ibm.com> <20190830012036.GA184995@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190830012036.GA184995@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-30_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908300026 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 29, 2019 at 09:20:36PM -0400, Joel Fernandes wrote: > On Thu, Aug 29, 2019 at 05:47:56PM -0700, Paul E. McKenney wrote: > [snip] > > > > > Paul, also what what happens in the following scenario: > > > > > > > > > > CPU0 CPU1 > > > > > > > > > > A syscall causes rcu_eqs_exit() > > > > > rcu_read_lock(); > > > > > ---> FQS loop waiting on > > > > > dyntick_snap > > > > > usermode-upcall entry -->causes rcu_eqs_enter(); > > > > > > > > > > usermode-upcall exit -->causes rcu_eqs_exit(); > > > > > > > > > > ---> FQS loop sees > > > > > dyntick snap > > > > > increment and > > > > > declares CPU0 is > > > > > in a QS state > > > > > before the > > > > > rcu_read_unlock! > > > > > > > > > > rcu_read_unlock(); > > > > > --- > > > > > > > > > > Does the context tracking not call rcu_user_enter() in this case, or did I > > > > > really miss something? > > > > > > > > Holding rcu_read_lock() across usermode execution (in this case, > > > > the usermode upcall) is a bad idea. Why is CPU 0 doing that? > > > > > > Oh, ok. I was just hypothesizing that since usermode upcalls from > > > something as heavy as interrupts, it could also mean we had the same from > > > some path that held an rcu_read_lock() as well. It was just a theoretical > > > concern, if it is not an issue, no problem. > > > > Are there the usual lockdep checks in the upcall code? Holding a spinlock > > across them would seem to be at least as bad as holding an rcu_read_lock() > > across them. > > Great point, I'll take a look. > > > > The other question I had was, in which cases would dyntick_nesting in current > > > RCU code be > 1 (after removing the lower bit and any crowbarring) ? In the > > > scenarios I worked out on paper, I can only see this as 1 or 0. But the > > > wording of it is 'dynticks_nesting'. May be I am missing a nesting scenario? > > > We can exit RCU-idleness into process context only once (either exiting idle > > > mode or user mode). Both cases would imply a value of 1. > > > > Interrrupt -> NMI -> certain types of tracing. I believe that can get > > it to 5. There might be even more elaborate sequences of events. > > I am only talking about dynticks_nesting, not dynticks_nmi_nesting. In > current mainline, I see this only 0 or 1. I am running the below patch > overnight on all RCU configurations to see if it is ever any other value. Ah! Then yes, we never enter non-idle/non-user process-level mode twice without having exited it. There would have been a splat, I believe. > And, please feel free to ignore my emails as you mentioned you are supposed > to be out next 2 days! Thanks for the replies though! Actually this day and next. ;-) Thanx, Paul > ---8<----------------------- > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 68ebf0eb64c8..8c8ddb6457d5 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -571,6 +571,9 @@ static void rcu_eqs_enter(bool user) > WRITE_ONCE(rdp->dynticks_nmi_nesting, 0); > WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && > rdp->dynticks_nesting == 0); > + > + WARN_ON_ONCE(rdp->dynticks_nesting != 1); > + > if (rdp->dynticks_nesting != 1) { > rdp->dynticks_nesting--; > return; > @@ -736,6 +739,9 @@ static void rcu_eqs_exit(bool user) > lockdep_assert_irqs_disabled(); > rdp = this_cpu_ptr(&rcu_data); > oldval = rdp->dynticks_nesting; > + > + WARN_ON_ONCE(rdp->dynticks_nesting != 0); > + > WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && oldval < 0); > if (oldval) { > rdp->dynticks_nesting++; > -- > 2.23.0.187.g17f5b7556c-goog >