Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5186123rwb; Mon, 21 Nov 2022 18:17:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf74JdNepLXGCk/N5VPBIbO3+Kc+A7E4Jbkbsp2CeVhWc6AnUk3ucqBBn5f6HQo7px1hT8C3 X-Received: by 2002:a65:5b0c:0:b0:477:a17d:5fe1 with SMTP id y12-20020a655b0c000000b00477a17d5fe1mr638084pgq.437.1669083421727; Mon, 21 Nov 2022 18:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669083421; cv=none; d=google.com; s=arc-20160816; b=K3Nwz+MF2XXpp0YWYg+oy1q7azfb0y5mtF1mJMthdBxn1AxkRBf1LnInRTCPSbq3ea 4k0MbE+/QzoGc0qzsx0YXJQKy33x5v2APtcZC5sJVsVF+1i6kJkd+/EWhnpQjizFrwn6 Vs6o3EZ8X5wS0kUEUx0X9GiiOCU4i2ttoUNdWVseuTD0djWehgBbrlV57xAUbupZhxhy 2vCX5jhTCAk8IvuTFPld6Hppo3H0liJNGBCxsbekiLCJ7+4xIx/ot8ZT8VqjMqFZ5tbw zx6AEMGaY6hm/6aa+liTwTm1Mnkw76ltu1fYRdrfZaLAey/deofuAp0JvlSrF0MguTWj 6GmQ== 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=ZtA1/GcSFcFiU1ppp5Q4H/NERsG7tztvT92JiROd1mE=; b=bUswySyl/rETOtc8qRPeg2eNGGPGqC0as0bMbp3i3WWR6lN07GdPxKamp/EbDt09by 4paOo7EmV6KGa/dpbGnPxQcCMOZs5CSxv3Dh+u4qQbMGlDeh4Zq9Eo0LyadB+6ec7LD5 0Wshk80AuPjGekoER8xqMCk2PqSR8BqpSc7V9/lGAJiT3BR+OOsZ/jbdI9VlSGG1F7Rt 3+GETW1KyIJQyIJJ0ce2y5G/hrwbmI58cySGdvkHO/oryHoZUyIZ9ABSaXjrDK6khf6s vof+Ty62oVHVs6FV2dQd4JZPMBqnd9zcn0p5jiFQUZ+bJ6gnIpn7hD19XnM4sqWhsXNY Rd/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=msgDCNIf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020a170902ecce00b00178431e09bdsi12427655plh.230.2022.11.21.18.16.48; Mon, 21 Nov 2022 18:17:01 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=msgDCNIf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232127AbiKVBFJ (ORCPT + 91 others); Mon, 21 Nov 2022 20:05:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231970AbiKVBE0 (ORCPT ); Mon, 21 Nov 2022 20:04:26 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D8F615804; Mon, 21 Nov 2022 17:04:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 36A14B818E6; Tue, 22 Nov 2022 01:04:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C09FDC433C1; Tue, 22 Nov 2022 01:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669079062; bh=U3+4ieL/lmCXWeRZRiLB8u0S5rhXMcyArw0nT7Mm3tc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=msgDCNIf5wTHEMiqK1Oby1Kv9Mul5DyWDroLunYs3RPd6Q4u0lEwQZKrTci5eEb8g D3NdwkLIwRwI6jk7mIMqe8ZH/iMBjQIKoUAxKYnVJxFFjzd/gWwAgFKUW+BQiIcMaQ fMA6510Y+gWdcIfhQK17+Bh0yKljOgZ4RhZXP/BL/VD8U3Jr2whVpiM6gHRbs1wXoy z2JnJ8viIApXCPsicuQ8+9JM+QwsBoDnbkMs+M0qlwfhT8kx1/XcJFyAp8uKEcLGuL yWRCMfiBG4xzWEkPbjr8rXkELND3r3n7zETP0DjxmeBfT34P2t0T6klB+V7PgdumKq mNb4lVjLFgKCA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 799CB5C116D; Mon, 21 Nov 2022 17:04:22 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Joel Fernandes (Google)" , "Paul E . McKenney" Subject: [PATCH v2 rcu 05/16] rcu: Refactor code a bit in rcu_nocb_do_flush_bypass() Date: Mon, 21 Nov 2022 17:04:10 -0800 Message-Id: <20221122010421.3799681-5-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221122010408.GA3799268@paulmck-ThinkPad-P17-Gen-1> References: <20221122010408.GA3799268@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 From: "Joel Fernandes (Google)" This consolidates the code a bit and makes it cleaner. Functionally it is the same. Reported-by: Paul E. McKenney Signed-off-by: Joel Fernandes (Google) Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_nocb.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index d6e4c076b0515..213daf81c057f 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -327,10 +327,11 @@ static void wake_nocb_gp_defer(struct rcu_data *rdp, int waketype, * * Note that this function always returns true if rhp is NULL. */ -static bool rcu_nocb_do_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp, +static bool rcu_nocb_do_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp_in, unsigned long j, bool lazy) { struct rcu_cblist rcl; + struct rcu_head *rhp = rhp_in; WARN_ON_ONCE(!rcu_rdp_is_offloaded(rdp)); rcu_lockdep_assert_cblist_protected(rdp); @@ -345,16 +346,16 @@ static bool rcu_nocb_do_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp, /* * If the new CB requested was a lazy one, queue it onto the main - * ->cblist so we can take advantage of a sooner grade period. + * ->cblist so that we can take advantage of the grace-period that will + * happen regardless. But queue it onto the bypass list first so that + * the lazy CB is ordered with the existing CBs in the bypass list. */ if (lazy && rhp) { - rcu_cblist_flush_enqueue(&rcl, &rdp->nocb_bypass, NULL); - rcu_cblist_enqueue(&rcl, rhp); - WRITE_ONCE(rdp->lazy_len, 0); - } else { - rcu_cblist_flush_enqueue(&rcl, &rdp->nocb_bypass, rhp); - WRITE_ONCE(rdp->lazy_len, 0); + rcu_cblist_enqueue(&rdp->nocb_bypass, rhp); + rhp = NULL; } + rcu_cblist_flush_enqueue(&rcl, &rdp->nocb_bypass, rhp); + WRITE_ONCE(rdp->lazy_len, 0); rcu_segcblist_insert_pend_cbs(&rdp->cblist, &rcl); WRITE_ONCE(rdp->nocb_bypass_first, j); -- 2.31.1.189.g2e36527f23