Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1178745ybl; Fri, 16 Aug 2019 10:09:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1qh3TkofFbrP0ABYSegBf2ZVulk6Qt9OPq5XmCZq0eJt63Y/wAggZqSQXrHSeciu6ctOb X-Received: by 2002:a62:1444:: with SMTP id 65mr11602050pfu.145.1565975372477; Fri, 16 Aug 2019 10:09:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565975372; cv=none; d=google.com; s=arc-20160816; b=DXswZz6AdIEK+DT6elRBN1Wn2xh++VhOSBj6eI5/lcb4jFKzUB73i7ntawDkVR0F9q Jq6uQGMaB6gpXNpKhM7KvQ6mKZillp1jEIKRdlMfZTK1XYyECN2h846c4dXg0zh3vxtg hAx+IJw4e/cPyuiKD4lVRx/FHZowEhVtzhYOYuh/LpcQ7Uc9mRH/FTwiO6sXWPA3jT73 HHUUIXPlS49FN4O0MML4RlM6uZ2uwNXTA/NCY4pu7aRaA3OSoawklLVSkohuSNh/TUkf PWl5dYJ7vLgoVBBL4WwhZWbHWookSs4No+sufOuKfGr1w/hskXPnflMLeytXtx4Y/Y2W KWig== 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; bh=LpUuiFdJ32bsLuaVeOaUL0Sj18GW8SOj2J5Gd+ou2Cw=; b=kjuBDYLbrYSHndxyZ+DY6uviPm5yLf0rT2gtc5N5kSp5HkQ80xzM6xqpGTDVfV0OdL AdM+zl/OOa072x7Tmdk8akPH1lgZKm/jE3TUSYgHgk8tafXWnz04rc5/pp/aIpDBCaju zRXLK3+CJSQOrwdcSCxFo6PEkezW23KScQVElK3732pgJNbAqHMSJPd5S41pvN7de8zB nn6wPVaqoHI37gbBJNH68nvwcQJqaqUX/kqMY3n0R1KvH8DfcmO6IbWM6VCyldfwu/GV pC6MFenMmHiG8tMIGIqi4FBrP0tgH/3dhwBDpsXB7U1xE6/hwSyYEYJWe9PCgjj4UzcP Mx+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=oaP05HQi; 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 z5si4307068plo.434.2019.08.16.10.09.17; Fri, 16 Aug 2019 10:09:32 -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=pass header.i=@joelfernandes.org header.s=google header.b=oaP05HQi; 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 S1726947AbfHPRHT (ORCPT + 99 others); Fri, 16 Aug 2019 13:07:19 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46273 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbfHPRHT (ORCPT ); Fri, 16 Aug 2019 13:07:19 -0400 Received: by mail-pf1-f194.google.com with SMTP id q139so3395794pfc.13 for ; Fri, 16 Aug 2019 10:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=LpUuiFdJ32bsLuaVeOaUL0Sj18GW8SOj2J5Gd+ou2Cw=; b=oaP05HQi1/o/sS5vyxx+usc0U+bhRSL/a0YiS/kKGOh0mjRXmh0AwvW10N5DkvNgBg E/1Z2bYOSj2WVy+3EMKNmnqor/mF4ltvwR0TMhCOZWrYDHws4CSU3Hsj9cYmKx6qk8ww Ux5GaggXWtGv1olsSkZGo5zrZWsa2FeMDJ0Vk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=LpUuiFdJ32bsLuaVeOaUL0Sj18GW8SOj2J5Gd+ou2Cw=; b=AV/pmstojmN/SzEcYWUGiz/QFVxSl6kcRczzKXQLPEc4pdjDWskychku6vopB6Y7w7 Y78Q1UcMlSABh3TgtHiv7/IzdgWRzLTdNGzrDsvjMN1TEfZpWHON06Jny+RKuiiWe65W a35e8sQ+FcfR5Q48mFZBTg0QEs/5o1aLjlCIIxV9fgF+D3TtucdZrI+Ub6RpnquoZKgI yVBVigq5J/AW0aLqlJRFwatHddGmZsZRaAAQUKBMVszn6orgS7LwsbKSr6K/EijRnPb7 Ay7raB6ABj2d4UXsG3J1TS1ti99sRdsxswEaX7yaOgKDS1gjGm7XeTl4noNTSSW0wTI0 L/ww== X-Gm-Message-State: APjAAAUdihgfT1TBMlHHhXD0yGDu5/DjOl8Ax/48DQ9yCTJsR00opHM8 LXC2VzTTf3BujST/JBBYmc6yPg== X-Received: by 2002:aa7:9293:: with SMTP id j19mr12164537pfa.90.1565975238300; Fri, 16 Aug 2019 10:07:18 -0700 (PDT) Received: from localhost ([172.19.216.18]) by smtp.gmail.com with ESMTPSA id w9sm6699237pfn.19.2019.08.16.10.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2019 10:07:17 -0700 (PDT) Date: Fri, 16 Aug 2019 13:07:00 -0400 From: Joel Fernandes To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, frederic@kernel.org Subject: Re: [PATCH -rcu dev 3/3] RFC: rcu/tree: Read dynticks_nmi_nesting in advance Message-ID: <20190816170700.GC10481@google.com> References: <20190816025311.241257-1-joel@joelfernandes.org> <20190816025311.241257-3-joel@joelfernandes.org> <20190816162404.GB10481@google.com> <20190816165242.GS28441@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190816165242.GS28441@linux.ibm.com> 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 Fri, Aug 16, 2019 at 09:52:42AM -0700, Paul E. McKenney wrote: > On Fri, Aug 16, 2019 at 12:24:04PM -0400, Joel Fernandes wrote: > > On Thu, Aug 15, 2019 at 10:53:11PM -0400, Joel Fernandes (Google) wrote: > > > I really cannot explain this patch, but without it, the "else if" block > > > just doesn't execute thus causing the tick's dep mask to not be set and > > > causes the tick to be turned off. > > > > > > I tried various _ONCE() macros but the only thing that works is this > > > patch. > > > > > > Signed-off-by: Joel Fernandes (Google) > > > --- > > > kernel/rcu/tree.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > > index 856d3c9f1955..ac6bcf7614d7 100644 > > > --- a/kernel/rcu/tree.c > > > +++ b/kernel/rcu/tree.c > > > @@ -802,6 +802,7 @@ static __always_inline void rcu_nmi_enter_common(bool irq) > > > { > > > struct rcu_data *rdp = this_cpu_ptr(&rcu_data); > > > long incby = 2; > > > + int dnn = rdp->dynticks_nmi_nesting; > > > > I believe the accidental sign extension / conversion from long to int was > > giving me an illusion since things started working well. Changing the 'int > > dnn' to 'long dnn' gives similar behavior as without this patch! At least I > > know now. Please feel free to ignore this particular RFC patch while I debug > > this more (over the weekend or early next week). The first 2 patches are > > good, just ignore this one. > > Ah, good point on the type! So you were ending up with zero due to the > low-order 32 bits of DYNTICK_IRQ_NONIDLE being zero, correct? If so, > the "!rdp->dynticks_nmi_nesting" instead needs to be something like > "rdp->dynticks_nmi_nesting == DYNTICK_IRQ_NONIDLE", which sounds like > it is actually worse then the earlier comparison against the constant 2. > > Sounds like I should revert the -rcu commit 805a16eaefc3 ("rcu: Force > nohz_full tick on upon irq enter instead of exit"). I think just using doing " == DYNTICK_IRQ_NONIDLE" as you mentioned should make it work. I'll test that soon, thanks! I would prefer not to revert that commit, and just make the above change. Just because I feel this is safer. Since the tick is turned off in the IRQ exit path, I am a bit worried about timing (does the tick turn off before RCU sees the IRQ exit, or after it?). Either way, doing it on IRQ entry makes the question irrelevant and immune to future changes in the timing. Would you think the check for the nesting variable is more expensive to do on IRQ entry than exit? If so, we could discuss doing it in the exit path, otherwise we could doing on entry with just the above change in the equality condition. thanks, - Joel > > Thanx, Paul > > > thanks, > > > > - Joel > > > > > > > > > > /* Complain about underflow. */ > > > WARN_ON_ONCE(rdp->dynticks_nmi_nesting < 0); > > > @@ -826,7 +827,7 @@ static __always_inline void rcu_nmi_enter_common(bool irq) > > > > > > incby = 1; > > > } else if (tick_nohz_full_cpu(rdp->cpu) && > > > - !rdp->dynticks_nmi_nesting && > > > + !dnn && > > > rdp->rcu_urgent_qs && !rdp->rcu_forced_tick) { > > > rdp->rcu_forced_tick = true; > > > tick_dep_set_cpu(rdp->cpu, TICK_DEP_BIT_RCU); > > > -- > > > 2.23.0.rc1.153.gdeed80330f-goog > > > > >