Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp579708rwb; Sat, 17 Sep 2022 10:24:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66t2KxQQQ3f+IHgHeJ47eEF21thlivW5v6QWfpG1jqEGhj3gIccCtrWeSIoDokIHk8HXGx X-Received: by 2002:a17:907:6e8f:b0:77f:d1d3:2d3e with SMTP id sh15-20020a1709076e8f00b0077fd1d32d3emr7465612ejc.398.1663435446509; Sat, 17 Sep 2022 10:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663435446; cv=none; d=google.com; s=arc-20160816; b=DdPKJ2DVkAo6PQwxYBiiUa5ATMuNE2PaxZXzSha126BbP7ZGNGlwbOm0goCwazdey8 aeY1l79QdVblK8gcVfQdhmJavqjNbkuKi8M2LpdSeeyVSdmO+3+jhO5/EpFtT0cQFdtU x2SCpCZResGf5HURDplhdxftb0FBQvPFveg3DFXLbDGihnJg2CG3iwxRAFwA3oroRC9T 7ncS58FG76OLxC9UT8SUDdaPnMxbPyLbZWbaCQog/IvO9Om808K5IfMjrE+FbIuLYhBU onwYG6ANOQ1o2Ncr9jAVCkBtb+2X3Ypr7iBfTY6S89vaHmGd7lJSHQVPRbKmNd47NveP WOnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W20sVr4rHsYJL/FKcEAa6dXGu1RHDwQdwaDFAlx3ULo=; b=jAzQdZeKVH0LC3e8WqaeFR18JFkm5Sh4v/24nuz2wntaGYF2Efzd8pY+xGeN0+yKvL H+nP9LWq4nreaNtPoD6TUtX8Yucb1n1NNKU/AeFnrHLsRWbcpITXlq/O2Uvcz7b7+Xrl M2kk3Aj1A31lTk02L5RbkU6l+M311aEYEm3qWaB6f2mLOOCb6xZ/sHw2dMLNSzNDHQ/d eXAEc1YnGcQZOAvyyRkjX0CPVUyfQNeVNYH2H0ZwZHmmPqA6ppmyE1jPpCGMcBQ7BIej s9n0nM1fuzw6PSJrKwaUDuUN+nfQhug7Z2Km2rko/y8xkW+QNaJ+dBdwYeIHNr7ZUBOd 5oNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=uHIj9ohx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a056402268400b00451e1aae675si5121678edd.547.2022.09.17.10.23.40; Sat, 17 Sep 2022 10:24:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=uHIj9ohx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbiIQQmo (ORCPT + 99 others); Sat, 17 Sep 2022 12:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbiIQQmg (ORCPT ); Sat, 17 Sep 2022 12:42:36 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23B7B2F678 for ; Sat, 17 Sep 2022 09:42:34 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id l14so10485462qvq.8 for ; Sat, 17 Sep 2022 09:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=W20sVr4rHsYJL/FKcEAa6dXGu1RHDwQdwaDFAlx3ULo=; b=uHIj9ohx6d/ikjQUH9MJsZfu/j/LooTs088y2mOsZ7N/UW6p5VqrtfTdkxJu4dTLO9 dI+OHDQizo/UIdP8y7bRLnQMGJcr0bulMfrIjDxsnsn1rINWrRQ7Qc7W+R6iba6C9DUL /mZGnML0/7+6LWpSZGZC5FgZlRWwDkLl3avUQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=W20sVr4rHsYJL/FKcEAa6dXGu1RHDwQdwaDFAlx3ULo=; b=qhVbgU/+ZmqiydsJNW7XbTREgZTDQLGGZRI31JUQmjz5EFSx2w/bsr93NMMgtQp6Ny nyfYgAuRFxOZAFjSFDZcuReAJZCN8VGflhqZ3p8zp6cuDM+qiPGWFFOBpUNJhA3b/c0c AZzJttzggdg+AL8AlTUWNcv04NFlt92Lzsovo5eQ1aKRTxQ1IbI7naQnkcmX4C0qX2GI 1A/YEok2EAU8IK1+Bo7J4bs33TrybTTaLxBE3ChmKe/e6adsB8IjQUMExQjJ5Ni/Uc7N qHQNwRT9fQRWhRq7Ba5EPeVL9jnxzo8p1nyjXgi0AYXMoKtsmthn5cYbSO2/qp6sTrhf mZig== X-Gm-Message-State: ACrzQf02ZBr07z7k8Y2zLqViRBVCA1eFeM4A+ZJVEW0yakU0jy5RaS4B Xysj1oIeyTZozkFrlKvV3fzxcA== X-Received: by 2002:a0c:f084:0:b0:49e:7bc1:26a3 with SMTP id g4-20020a0cf084000000b0049e7bc126a3mr8842257qvk.107.1663432953226; Sat, 17 Sep 2022 09:42:33 -0700 (PDT) Received: from joelboxx.c.googlers.com.com (228.221.150.34.bc.googleusercontent.com. [34.150.221.228]) by smtp.gmail.com with ESMTPSA id q31-20020a05620a2a5f00b006bb0e5ca4bbsm9479239qkp.85.2022.09.17.09.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Sep 2022 09:42:32 -0700 (PDT) From: "Joel Fernandes (Google)" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, rushikesh.s.kadam@intel.com, urezki@gmail.com, neeraj.iitr10@gmail.com, frederic@kernel.org, paulmck@kernel.org, rostedt@goodmis.org, "Joel Fernandes (Google)" Subject: [PATCH rcu/next 2/3] rcu: Fix late wakeup when flush of bypass cblist happens (v6) Date: Sat, 17 Sep 2022 16:41:59 +0000 Message-Id: <20220917164200.511783-3-joel@joelfernandes.org> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog In-Reply-To: <20220917164200.511783-1-joel@joelfernandes.org> References: <20220917164200.511783-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the bypass cblist gets too big or its timeout has occurred, it is flushed into the main cblist. However, the bypass timer is still running and the behavior is that it would eventually expire and wake the GP thread. Since we are going to use the bypass cblist for lazy CBs, do the wakeup soon as the flush for "too big or too long" bypass list happens. Otherwise, long delays can happen for callbacks which get promoted from lazy to non-lazy. This is a good thing to do anyway (regardless of future lazy patches), since it makes the behavior consistent with behavior of other code paths where flushing into the ->cblist makes the GP kthread into a non-sleeping state quickly. [ Frederic Weisbec: changes to not do wake up GP thread unless needed, comment changes ]. Reviewed-by: Frederic Weisbecker Signed-off-by: Joel Fernandes (Google) --- kernel/rcu/tree_nocb.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 0a5f0ef41484..04c87f250e01 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -433,8 +433,9 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp, if ((ncbs && j != READ_ONCE(rdp->nocb_bypass_first)) || ncbs >= qhimark) { rcu_nocb_lock(rdp); + *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist); + if (!rcu_nocb_flush_bypass(rdp, rhp, j)) { - *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist); if (*was_alldone) trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, TPS("FirstQ")); @@ -447,7 +448,12 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp, rcu_advance_cbs_nowake(rdp->mynode, rdp); rdp->nocb_gp_adv_time = j; } - rcu_nocb_unlock_irqrestore(rdp, flags); + + // The flush succeeded and we moved CBs into the regular list. + // Don't wait for the wake up timer as it may be too far ahead. + // Wake up the GP thread now instead, if the cblist was empty. + __call_rcu_nocb_wake(rdp, *was_alldone, flags); + return true; // Callback already enqueued. } -- 2.37.3.968.ga6b4b080e4-goog