Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp261343ybm; Thu, 28 May 2020 02:01:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAju+UxEv8KAChCA66CY/DxWBjzPCX2RvAHiUzHHTwMPCMRk1B0F3wncsnTT9M60GmsLCh X-Received: by 2002:a50:eb84:: with SMTP id y4mr1930397edr.374.1590656510690; Thu, 28 May 2020 02:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590656510; cv=none; d=google.com; s=arc-20160816; b=zWpgv4sfnnAs6v0NHic920JpsMsOt6JzHRENklpLg3ZQuBZ+HtrUNDi+Pj7EECOHwT 7yH+UFSSrAUdaIdqzQoUxpljjdYL4IMzxQDUPEMp0MIItQzEMbUVHh6lVGdMtB7n4B6M YmSkhAKMBYFA5lEYh9Fr4mpbSaVhBtji5YwiRFujHHO6xn0TTmENhzZS98VK6SR2GT7/ 2Ej9qrL0TiO9CGg5D/YhmRK08EwGkHtY8ov10srf87+ato4A4BFugcZ+JjWlb98MWhYt 3XEcXMwNUpcpnAkQLPTUx0DNaN4pFPLdUqwECjJr0oaxb1jUb7+eKy8nViZv/I78jTXy 8Btg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=L7806bWwZtGxBg80jrCKm9qMEoKDOud5BSZ2Xrdw41s=; b=rJ471aWKVJRP6y2kmkziLwq4AIDsJMA8Ifvw8lNmE/Yb/LlBMT+QO2/6arFfH+RcTw pd2ibwAn0OQs+v4QOo0n+nFzkIc8dw1ecq50Up19jftVibuUkNY8I8F+9d7k1AcdaLxX Ne+oltlrAM4DfEEWJHlX01g/YtbICt0ayuAO0TqY3IZnWVQKGQ4qL0UjflbwKt2ztWfa Xx7SPh6HWg01zM/MCbZ7mi7ZmAsbWAoltl3OpnuPpqtdwyr8XqRok7qFMVTz6AFlKMNu SLx6temwL7Wp/uRmPO4lvU53+cFqQR103DJCM1u+tVZelynJUy9c8D7AK/FD18HNKMHi JSgw== ARC-Authentication-Results: i=1; mx.google.com; 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 m28si2043584edb.7.2020.05.28.02.01.27; Thu, 28 May 2020 02:01:50 -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; 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 S1728074AbgE1I7l (ORCPT + 99 others); Thu, 28 May 2020 04:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727991AbgE1I7i (ORCPT ); Thu, 28 May 2020 04:59:38 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46430C05BD1E; Thu, 28 May 2020 01:59:37 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jeENw-0002Pa-E8; Thu, 28 May 2020 10:59:32 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id B38601C0051; Thu, 28 May 2020 10:59:31 +0200 (CEST) Date: Thu, 28 May 2020 08:59:31 -0000 From: "tip-bot2 for Peter Zijlstra" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/rcu] rcu: Allow for smp_call_function() running callbacks from idle Cc: "Peter Zijlstra (Intel)" , Ingo Molnar , "Paul E. McKenney" , "Joel Fernandes (Google)" , x86 , LKML In-Reply-To: <20200527171236.GC706495@hirez.programming.kicks-ass.net> References: <20200527171236.GC706495@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Message-ID: <159065637151.17951.5845770654849565519.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the core/rcu branch of tip: Commit-ID: 806f04e9fd2c6ad1e39bc2dba77155be0e4becde Gitweb: https://git.kernel.org/tip/806f04e9fd2c6ad1e39bc2dba77155be0e4becde Author: Peter Zijlstra AuthorDate: Wed, 27 May 2020 19:12:36 +02:00 Committer: Ingo Molnar CommitterDate: Thu, 28 May 2020 10:50:12 +02:00 rcu: Allow for smp_call_function() running callbacks from idle Current RCU hard relies on smp_call_function() callbacks running from interrupt context. A pending optimization is going to break that, it will allow idle CPUs to run the callbacks from the idle loop. This avoids raising the IPI on the requesting CPU and avoids handling an exception on the receiving CPU. Change rcu_is_cpu_rrupt_from_idle() to also accept task context, provided it is the idle task. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Reviewed-by: Paul E. McKenney Reviewed-by: Joel Fernandes (Google) Link: https://lore.kernel.org/r/20200527171236.GC706495@hirez.programming.kicks-ass.net --- kernel/rcu/tree.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 90c8be2..f51385b 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -418,16 +418,23 @@ void rcu_momentary_dyntick_idle(void) EXPORT_SYMBOL_GPL(rcu_momentary_dyntick_idle); /** - * rcu_is_cpu_rrupt_from_idle - see if interrupted from idle + * rcu_is_cpu_rrupt_from_idle - see if 'interrupted' from idle * * If the current CPU is idle and running at a first-level (not nested) - * interrupt from idle, return true. The caller must have at least - * disabled preemption. + * interrupt, or directly, from idle, return true. + * + * The caller must have at least disabled IRQs. */ static int rcu_is_cpu_rrupt_from_idle(void) { - /* Called only from within the scheduling-clock interrupt */ - lockdep_assert_in_irq(); + long nesting; + + /* + * Usually called from the tick; but also used from smp_function_call() + * for expedited grace periods. This latter can result in running from + * the idle task, instead of an actual IPI. + */ + lockdep_assert_irqs_disabled(); /* Check for counter underflows */ RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nesting) < 0, @@ -436,9 +443,15 @@ static int rcu_is_cpu_rrupt_from_idle(void) "RCU dynticks_nmi_nesting counter underflow/zero!"); /* Are we at first interrupt nesting level? */ - if (__this_cpu_read(rcu_data.dynticks_nmi_nesting) != 1) + nesting = __this_cpu_read(rcu_data.dynticks_nmi_nesting); + if (nesting > 1) return false; + /* + * If we're not in an interrupt, we must be in the idle task! + */ + WARN_ON_ONCE(!nesting && !is_idle_task(current)); + /* Does CPU appear to be idle from an RCU standpoint? */ return __this_cpu_read(rcu_data.dynticks_nesting) == 0; }