Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp167068imm; Thu, 30 Aug 2018 19:29:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbDrwD9PX4hNStlbos5zka2KZH0si/WMZVJqqBQXcnsArlYybyhg6LKlAKicPw1d8C/zYoA X-Received: by 2002:a62:50c3:: with SMTP id g64-v6mr13323924pfj.244.1535682590510; Thu, 30 Aug 2018 19:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535682590; cv=none; d=google.com; s=arc-20160816; b=IntvBx7pmbzPqK3a2xiXUY2YiuuQqFFOEITnDqlghbWgPqWD58uGHJWJ2+BRcaqCSs /Q3E0J5+NI/xrwEMH0ZwMNJ60BufrauzncqP81fEvksjjHqV/Tev/HUJR5iKuDaQvIFB FXuLUp6ED28DRA7j3xJ84u99V3CfmWjP5mDn5AKocsPDd+MIL7yTtKBDwqk12w55X8r/ pQoDU0Pqe5mlJpf6ioDFynAFjXgyvEbwIdFCACIZ4tV5PkzqgmXge9pBX04ckcCHG4Bj 6xxF7NaCp1Hq/u/lf3LB0vVT6R78Q41Zl67nMY/tHKECHF1N0+nwcWYEbiVhCHONSlJ8 j+Ng== 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:arc-authentication-results; bh=ecRYZaAbNhz638pc576SsaIOupnMcymYekfmT6Qr5zE=; b=vBJbbmpYfVX36lQy4Cr7nyeVpisl4n3zKEErHNRXvzDX6s5KxZEd+4dPX5A33JGz80 vbZpOv3Gxy46yh/s314PfGQth6bJ2xtQnJzXkcvK+k0tQBjRUxAnVA9DDJaChHMJYI96 O2U8+Vgj7QzJO8oXZOj20kPawO70iHxX/vz3iAJC25Wi2IA/dLYUESajFfKsPXUcxWbl za8Unyo+JhAJQpAKUdZItfH3ytlfdleJ/cDqtPH6i+Ze4iw029kBH990Gp6RV0XSgyui HhbMqkgx16dtxMJ5wy34vrzaE/L2b8LSYs4R4rXI3Jf5Ng4dnlePT6ZOAsW1EhNogoSP suFg== 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 o4-v6si8148764pfh.168.2018.08.30.19.29.02; Thu, 30 Aug 2018 19:29:50 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727173AbeHaGas (ORCPT + 99 others); Fri, 31 Aug 2018 02:30:48 -0400 Received: from lgeamrelo12.lge.com ([156.147.23.52]:37299 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726660AbeHaGar (ORCPT ); Fri, 31 Aug 2018 02:30:47 -0400 Received: from unknown (HELO lgemrelse7q.lge.com) (156.147.1.151) by 156.147.23.52 with ESMTP; 31 Aug 2018 11:25:37 +0900 X-Original-SENDERIP: 156.147.1.151 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO X58A-UD3R) (10.177.222.33) by 156.147.1.151 with ESMTP; 31 Aug 2018 11:25:37 +0900 X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Fri, 31 Aug 2018 11:25:32 +0900 From: Byungchul Park To: Steven Rostedt Cc: "Paul E. McKenney" , linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, kernel-team@lge.com Subject: Re: [PATCH tip/core/rcu 01/19] rcu: Refactor rcu_{nmi,irq}_{enter,exit}() Message-ID: <20180831022532.GA24115@X58A-UD3R> References: <20180829222021.GA29944@linux.vnet.ibm.com> <20180829222047.319-1-paulmck@linux.vnet.ibm.com> <20180830141032.76efd12c@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180830141032.76efd12c@gandalf.local.home> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 30, 2018 at 02:10:32PM -0400, Steven Rostedt wrote: > On Wed, 29 Aug 2018 15:20:29 -0700 > "Paul E. McKenney" wrote: > > > This commit also changes order of execution from this: > > > > rcu_dynticks_task_exit(); > > rcu_dynticks_eqs_exit(); > > trace_rcu_dyntick(); > > rcu_cleanup_after_idle(); > > > > To this: > > > > rcu_dynticks_task_exit(); > > rcu_dynticks_eqs_exit(); > > rcu_cleanup_after_idle(); > > trace_rcu_dyntick(); > > > > In other words, the calls to trace_rcu_dyntick() and trace_rcu_dyntick() > > How is trace_rcu_dyntick() and trace_rcu_dyntick reversed ? ;-) > > > are reversed. This has no functional effect because the real > > concern is whether a given call is before or after the call to > > rcu_dynticks_eqs_exit(), and this patch does not change that. Before the > > call to rcu_dynticks_eqs_exit(), RCU is not yet watching the current > > CPU and after that call RCU is watching. > > > > A similar switch in calling order happens on the idle-entry path, with > > similar lack of effect for the same reasons. > > > > Suggested-by: Paul E. McKenney > > Signed-off-by: Byungchul Park > > Signed-off-by: Paul E. McKenney > > --- > > kernel/rcu/tree.c | 61 +++++++++++++++++++++++++++++++---------------- > > 1 file changed, 41 insertions(+), 20 deletions(-) > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index 0b760c1369f7..0adf77923e8b 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -771,17 +771,18 @@ void rcu_user_enter(void) > > #endif /* CONFIG_NO_HZ_FULL */ > > > > /** > > - * rcu_nmi_exit - inform RCU of exit from NMI context > > + * rcu_nmi_exit_common - inform RCU of exit from NMI context > > + * @irq: Is this call from rcu_irq_exit? > > * > > * If we are returning from the outermost NMI handler that interrupted an > > * RCU-idle period, update rdtp->dynticks and rdtp->dynticks_nmi_nesting > > * to let the RCU grace-period handling know that the CPU is back to > > * being RCU-idle. > > * > > - * If you add or remove a call to rcu_nmi_exit(), be sure to test > > + * If you add or remove a call to rcu_nmi_exit_common(), be sure to test > > * with CONFIG_RCU_EQS_DEBUG=y. > > As this is a static function, this description doesn't make sense. You > need to move the description down to the new rcu_nmi_exit() below. Right.. I should've done that. Thanks you Steve. Byungchul > Other than that... > > Reviewed-by: Steven Rostedt (VMware) > > -- Steve > > > > */ > > -void rcu_nmi_exit(void) > > +static __always_inline void rcu_nmi_exit_common(bool irq) > > { > > struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); > > > > @@ -807,7 +808,22 @@ void rcu_nmi_exit(void) > > /* This NMI interrupted an RCU-idle CPU, restore RCU-idleness. */ > > trace_rcu_dyntick(TPS("Startirq"), rdtp->dynticks_nmi_nesting, 0, rdtp->dynticks); > > WRITE_ONCE(rdtp->dynticks_nmi_nesting, 0); /* Avoid store tearing. */ > > + > > + if (irq) > > + rcu_prepare_for_idle(); > > + > > rcu_dynticks_eqs_enter(); > > + > > + if (irq) > > + rcu_dynticks_task_enter(); > > +} > > + > > +/** > > + * rcu_nmi_exit - inform RCU of exit from NMI context > > + */ > > +void rcu_nmi_exit(void) > > +{ > > + rcu_nmi_exit_common(false); > > } > > > > /** > > @@ -831,14 +847,8 @@ void rcu_nmi_exit(void) > > */ > > void rcu_irq_exit(void) > > { > > - struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); > > - > > lockdep_assert_irqs_disabled(); > > - if (rdtp->dynticks_nmi_nesting == 1) > > - rcu_prepare_for_idle(); > > - rcu_nmi_exit(); > > - if (rdtp->dynticks_nmi_nesting == 0) > > - rcu_dynticks_task_enter(); > > + rcu_nmi_exit_common(true); > > } > > > > /* > > @@ -921,7 +931,8 @@ void rcu_user_exit(void) > > #endif /* CONFIG_NO_HZ_FULL */ > > > > /** > > - * rcu_nmi_enter - inform RCU of entry to NMI context > > + * rcu_nmi_enter_common - inform RCU of entry to NMI context > > + * @irq: Is this call from rcu_irq_enter? > > * > > * If the CPU was idle from RCU's viewpoint, update rdtp->dynticks and > > * rdtp->dynticks_nmi_nesting to let the RCU grace-period handling know > > @@ -929,10 +940,10 @@ void rcu_user_exit(void) > > * long as the nesting level does not overflow an int. (You will probably > > * run out of stack space first.) > > * > > - * If you add or remove a call to rcu_nmi_enter(), be sure to test > > + * If you add or remove a call to rcu_nmi_enter_common(), be sure to test > > * with CONFIG_RCU_EQS_DEBUG=y. > > */ > > -void rcu_nmi_enter(void) > > +static __always_inline void rcu_nmi_enter_common(bool irq) > > { > > struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); > > long incby = 2; > > @@ -949,7 +960,15 @@ void rcu_nmi_enter(void) > > * period (observation due to Andy Lutomirski). > > */ > > if (rcu_dynticks_curr_cpu_in_eqs()) { > > + > > + if (irq) > > + rcu_dynticks_task_exit(); > > + > > rcu_dynticks_eqs_exit(); > > + > > + if (irq) > > + rcu_cleanup_after_idle(); > > + > > incby = 1; > > } > > trace_rcu_dyntick(incby == 1 ? TPS("Endirq") : TPS("++="), > > @@ -960,6 +979,14 @@ void rcu_nmi_enter(void) > > barrier(); > > } > > > > +/** > > + * rcu_nmi_enter - inform RCU of entry to NMI context > > + */ > > +void rcu_nmi_enter(void) > > +{ > > + rcu_nmi_enter_common(false); > > +} > > + > > /** > > * rcu_irq_enter - inform RCU that current CPU is entering irq away from idle > > * > > @@ -984,14 +1011,8 @@ void rcu_nmi_enter(void) > > */ > > void rcu_irq_enter(void) > > { > > - struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); > > - > > lockdep_assert_irqs_disabled(); > > - if (rdtp->dynticks_nmi_nesting == 0) > > - rcu_dynticks_task_exit(); > > - rcu_nmi_enter(); > > - if (rdtp->dynticks_nmi_nesting == 1) > > - rcu_cleanup_after_idle(); > > + rcu_nmi_enter_common(true); > > } > > > > /*