Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp953803ybm; Wed, 27 May 2020 12:04:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvhZvVFkQmnp1E0+lpzOiWqnBXRTtH+h79z300NRBjRt+EbbEbSJnlXkuNVkaiD6SFShnM X-Received: by 2002:a50:b961:: with SMTP id m88mr25735539ede.4.1590606259080; Wed, 27 May 2020 12:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590606259; cv=none; d=google.com; s=arc-20160816; b=Mno2K9UXdv5qLPT48Fll4Nyg7ACuFSm6EXJ9xauYmYFLGw/GZj121/j0ifHiFnuwyb Mv5jwYzXm89chTgJ2xxWUdPSkyt1sdyUljLtuOEgUr3+JOhVAV6Hkobg2MlcZhAwXEO6 X5lY60KaHnl2HijoeX04405LX5sXC9/LnA/3oGS9JPYWG50FD0Ct+UGtAPT44OJagbdp 6PZy5WvIxb6bAi20bO99/77Tt3FWqsno7hrPJmF1qJHZsuMZvYabs7+erpq0S0ydm3jr U4ACwWDSeSlzJkEKRp14g3X8/HNrAmorqsi/rrZ25ViEBL3qICLQuB6RHAgWV2vsuImk 94dg== 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=V8c9CKPPtZTotoRSO3kw7/ISrQ+/y50LUn0q4yH81/Y=; b=F7eOhpSxyMc/jfpOshEk58/5AKTwfCB9A+UqJbtihKjFewb5Q7fNWpf8z+pkEM+/mV AIj4g5kOOPc9uw/d3FdIYJK04P7ceFr/eygFR2wuge/aSbr9Hfn6JEIAHzmXXOrbCjHa BSOV6u/uWeYrt8SoR4ejUAUZDkhm0io8MARu76mwuViT16D2zzBVXSHuGWaPIg3DQSNL 2NHKyH477hJUJXWuHjU4yoTpUErFOpoUBGCqlxF6Lzsf2XPV8bmYb/gVprEe/jxZ4y1s Ye1soQJQFIAtSlxmdiKELcwcr6RsGeb/KyCe3NB2qbIzDZxoYPgpX5yQmKhm0EPr6OMk J5yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ooaILInh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id b21si2370101eju.737.2020.05.27.12.03.55; Wed, 27 May 2020 12:04:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ooaILInh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730883AbgE0P5D (ORCPT + 98 others); Wed, 27 May 2020 11:57:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:41252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730870AbgE0P45 (ORCPT ); Wed, 27 May 2020 11:56:57 -0400 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (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 1682320776; Wed, 27 May 2020 15:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590595017; bh=Ik6t3kw79TqNezTHS+OiIuNo2tlFgr4eybIwx61pe/8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=ooaILInhRblQrCFPRyWa/J6/8OQCLqzd3B+W0MH4F3bJu7mCY5F7RVJzR++paYS+6 mAxqnYdkYb5zDA5FlQYjrOE4JounVdJ88UBifHr/S6Vx9GUKBZRRx3P8fvR0Ae02QS /TR5lXbcf2etddptyx08Pq6Bbad0r8xzRHhD8R40= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id DA74F3522839; Wed, 27 May 2020 08:56:56 -0700 (PDT) Date: Wed, 27 May 2020 08:56:56 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: tglx@linutronix.de, frederic@kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, cai@lca.pw, mgorman@techsingularity.net, joel@joelfernandes.org Subject: Re: [RFC][PATCH 4/7] smp: Optimize send_call_function_single_ipi() Message-ID: <20200527155656.GU2869@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200526161057.531933155@infradead.org> <20200526161907.953304789@infradead.org> <20200527095645.GH325280@hirez.programming.kicks-ass.net> <20200527101513.GJ325303@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200527101513.GJ325303@hirez.programming.kicks-ass.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 Wed, May 27, 2020 at 12:15:13PM +0200, Peter Zijlstra wrote: > On Wed, May 27, 2020 at 11:56:45AM +0200, Peter Zijlstra wrote: > > > This is rcu_is_cpu_rrupt_from_idle()'s lockdep_assert_in_irq() tripping > > up (it's comment is obviously a bit antiquated). > > > > Now, if I read that code correctly, it actually relies on > > rcu_irq_enter() and thus really wants to be in an interrupt. Is there > > any way this code can be made to work from the new context too? > > > > After all, all that really is different is not having gone throught he > > bother of setting up the IRQ context, nothing else changed -- it just so > > happens you actually relied on that ;/ > > At first glance, something like the below could work. But obviously I > might have overlooked something more subtle than a brick :-) This can work, but only if the call from the idle loop is a place where either RCU isn't watching on the one hand or that cannot be in an RCU read-side critical section on the other. Because rcu_exp_handler() assumes that if this function returns true, we are not in an RCU read-side critical section. (I would expect this to be the case, but I figured that I should make it explicit.) > --- > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 90c8be22d57a..0792c032a972 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -426,8 +426,11 @@ EXPORT_SYMBOL_GPL(rcu_momentary_dyntick_idle); > */ Could we please have a comment noting the change in semantics and the reason? > static int rcu_is_cpu_rrupt_from_idle(void) > { > - /* Called only from within the scheduling-clock interrupt */ > - lockdep_assert_in_irq(); > + /* > + * Usually called from the tick; but also used from smp_call_function() > + * for expedited grace periods. > + */ > + lockdep_assert_irqs_disabled(); > > /* Check for counter underflows */ > RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nesting) < 0, > @@ -435,8 +438,11 @@ static int rcu_is_cpu_rrupt_from_idle(void) > RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nmi_nesting) <= 0, > "RCU dynticks_nmi_nesting counter underflow/zero!"); > > - /* Are we at first interrupt nesting level? */ > - if (__this_cpu_read(rcu_data.dynticks_nmi_nesting) != 1) > + /* > + * Are we at first interrupt nesting level? -- or below, when running > + * directly from the idle loop itself. > + */ > + if (__this_cpu_read(rcu_data.dynticks_nmi_nesting) > 1) Wouldn't it also be a good idea to check that we are in the context of an idle thread? Just in case some idiot like me drops a call to this function in the wrong place, for example, if I were to mistakenly remember the old semantics where it would return false from process context? Maybe something like this? nesting = __this_cpu_read(rcu_data.dynticks_nmi_nesting; if (nesting > 1) return false; WARN_ON_ONCE(!nesting && !is_idle_task(current)); > return false; > > /* Does CPU appear to be idle from an RCU standpoint? */ And let's check the other callers: rcu_sched_clock_irq(): This will always be called from IRQ (right?), so no problem. rcu_pending(): Only called from rcu_sched_clock_irq(), so still no problem. rcu_flavor_sched_clock_irq(): Ditto for both definitions. Thanx, Paul