Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp812066ybm; Wed, 27 May 2020 08:35:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYgEQAJ/gpUrveltcr/zoo3sTceQ484H/6K78NxSzt1EvOyYrh/jDf+ZWxUDoTEEYuZ2Cz X-Received: by 2002:a17:906:4d45:: with SMTP id b5mr6414859ejv.146.1590593731689; Wed, 27 May 2020 08:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590593731; cv=none; d=google.com; s=arc-20160816; b=OuVBJd/CW+aMT76LLwiNAuDfTS8MMYpEs+c5EbxfFra034zqJyxjJwh0fVL2kEGvJ6 i6+cOCZHvzNNXqBx5xU8nN3i6n1ci44uzIqBOWMlpZr9r5Om40EyT5IWvHczDXjUp32D ePSIMhfGUiHYv0jn/wZzHM6hLpFacNaz8pZWFvxfL2BFZTrUa9m3tLjb5bfohB1Q+BIi 7AqyqK2PISEMFTu8a64ipY3cmMo+G0aJh2QrODRjo8upTuI6Oz3XA0Pf2pE4qnwDVOAb QrfAGFLq2ZbzE3G/nHovnuJzUKiVE5d6gOsq+i5NB5VisBbrZl8HrvynRJSIG2QlIwHF QIew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=iKY4vjyoS0+YT9NdstlMwtWCWyiGdldVFQTqjCKizzg=; b=rDv4f1FquBuye1HKzNU/PV/UQHoA+A7e+LKOnZIvgPAgsDrFaPdbRbIUspxyPOYRg4 BRg5I3/ezvhtbqr1+WBwC5fhznsD4tAKgqlfkLeSprB6QoRp1ANvR8kX0pc5WCoMLd0G nh0BjSX0AVAW1AN4YP7BXOFbBPMzAoLiJA3a98fOXTsUFfOYmRPbBidJoo8cSYSdJtoG w1FQUAYMDIuTj/quXJjVhwHek4C3R3JYgltOs1KQBaTNRmiz7udsJrd9oZmH/AmyJgOG XOKrdmp1V6mzdIP2oFvSdrch7RNywehQYI4MM5HhMh0dZPYKi5axXWutRf53Vrwwv9Cf mZXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=A8k7USeU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr16si2898623ejc.320.2020.05.27.08.35.07; Wed, 27 May 2020 08:35:31 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=A8k7USeU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729722AbgE0KUM (ORCPT + 99 others); Wed, 27 May 2020 06:20:12 -0400 Received: from merlin.infradead.org ([205.233.59.134]:52498 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725294AbgE0KUI (ORCPT ); Wed, 27 May 2020 06:20:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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; bh=iKY4vjyoS0+YT9NdstlMwtWCWyiGdldVFQTqjCKizzg=; b=A8k7USeUVsSoGYLpMTrMMwNOWR cNOPAHGBVka0GW/mMPLTWsdzvO4R1jopMT4aq2DSM/Z0H4AYMv7hfQj9ktxoG7If2pFS8GrOsv7nE busjA9T+fxaN/36CH2hAjjFRk1mKRwE6/HWK8gMGQnRTEQOJ1Dn/dkJwodfw9EBgqa4rPQaokkfve nyFdAgy/9IXWblmO0mYEVwqtOH6vEOGyX9GsienJ3+ICE0m2ZCG5vvMkFnFMyDLmsYAHxpNrhqlwU +X+FGnpO6O1vyoscyfWx3wFjwuNoNUzPLdUhGnN0e4i6pYg+uPjuQibnbt3nYO4Iwb8Lm7qhTMnIL CKwMVtQA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jdt5m-0000oi-8n; Wed, 27 May 2020 10:15:22 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E7AC6304BDF; Wed, 27 May 2020 12:15:13 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B065E2BD9C2AA; Wed, 27 May 2020 12:15:13 +0200 (CEST) Date: Wed, 27 May 2020 12:15:13 +0200 From: Peter Zijlstra To: tglx@linutronix.de, frederic@kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, cai@lca.pw, mgorman@techsingularity.net, paulmck@kernel.org, joel@joelfernandes.org Subject: Re: [RFC][PATCH 4/7] smp: Optimize send_call_function_single_ipi() Message-ID: <20200527101513.GJ325303@hirez.programming.kicks-ass.net> References: <20200526161057.531933155@infradead.org> <20200526161907.953304789@infradead.org> <20200527095645.GH325280@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200527095645.GH325280@hirez.programming.kicks-ass.net> 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 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 :-) --- 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); */ 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) return false; /* Does CPU appear to be idle from an RCU standpoint? */