Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3296997lqo; Wed, 15 May 2024 05:54:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWzXxIJ9r8VbUlT/z6xHyIoIRgxENfYYoaaVBko6pDpQh5slsUkARw9LCPBIlOUYtP13OPk7/Ylu0O13BeWii9m/njqvYJ2n2Gw7vpefg== X-Google-Smtp-Source: AGHT+IEhoYi4GxUMdytYrVVahDmzn3r6vHJ1rxf3SsmGr9WGEhedrB5K+3cag3c7gbFC1DaELMkK X-Received: by 2002:a50:bb05:0:b0:572:9dbf:1de5 with SMTP id 4fb4d7f45d1cf-5734d6b2945mr9452528a12.40.1715777687942; Wed, 15 May 2024 05:54:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715777687; cv=pass; d=google.com; s=arc-20160816; b=pE8KBCDBsGb9JAfcDr4SZ5LwelwZ3hJxRCa78mxvRpZbTbUWPl0Sld0UtbqnIs6M0Z qqZVxpa1R7yB+3Nn52CkP6O1Fapm6GWEnQnLAAA+QviKQRE2KWdFyeGSAy13TiZg7KIR pbXwgtRMxmFoAkUDSPeH9iCvZnhKMBRnEQQiBWSPU3I8xM/W3QMHJ56phcorCf2T7+qH +UbjaavG8qUnOUfreQFlkbpViWUfFLXJTGd6h+eCYB2JiSma//REIU9aFrisn/CezzVP g2sv2bNcve2geADzvGHk/jI4Z74fLhzIzN0W6nnpc+n+YcJz/Iv3y2lWor5akDA9mq70 4rrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=stGSfHocprnkPsYYWS2hmd3lCAxQ0Iq59LAtdoRb14k=; fh=y7YWp49TGn1SKctwYHNRFImp1RqPEFQizTwe3vKGdPo=; b=KZ1BWUzLQbti7cVUNsOe7O0+LQntVtRy3FfoGfbANm9+l22xz9+OE/0zrJ12oZdg5F Cm59j6rj3aSQ9/BXqDF/lxJIqnsVUbJJq8LoRpUgwr1nl7rMKwL97Eo42EkN7V+Oxw0t J8+/uixZxnQjOxIwlR1zOzGo2qvLJ/YuGx1aa3DR2CKXqsTOkR2bf13OmgtGY3x+oOg7 YbaVfMVtpJhyeQGSS9ONvNtYaOZzzej3tKD9h6APhBeuctqHPnfj2cLJEslkm4htOPvF xtNscpDwbjzG1w3eIxFqNoP68Wm2t/l2pdNQnvZwvdA1onRjgEYxKp2SwCLizYNEpODt hGnA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sOP210ma; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733beac53fsi7534458a12.20.2024.05.15.05.54.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 05:54:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sOP210ma; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 71F601F227E8 for ; Wed, 15 May 2024 12:54:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78FEC12B16E; Wed, 15 May 2024 12:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sOP210ma" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E45212AAD3; Wed, 15 May 2024 12:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715777632; cv=none; b=YYwV/A3FgOGabnHZ9/1PlyFtxK/pMaAoaJUuVOki5ToqwGJKWJSHeiHqBXYVF9wPBRugvrHjkrawfO/YELj877t7+I1PkPHrECI/h3TLnLZYLWErLRmLv4YXrOZ7jUE/MBvYZbPFL0d4FY0fKbdZvosteHXhI8zfLl90D848DfM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715777632; c=relaxed/simple; bh=61n4BvWS+RKXfIV6Crmix3uFCPd3dUP3naHmOjOk0/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uXkjGAX4+I7udrtJJyFk/6HeSZCKt1sYF0J9sGW0+fuDaASWn0WNZuyO2bqZeuhCQ4tvvj9+vyV8Y3biAJw978lyE2dLr/rM/MNlawFccTLlJ1JjnTtA7IBgOx7wyMycKwHGdVcqnoLuCA8SoeTdrH8DcmX+3jgCp/omW4uq5gk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sOP210ma; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DB15C4AF07; Wed, 15 May 2024 12:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715777632; bh=61n4BvWS+RKXfIV6Crmix3uFCPd3dUP3naHmOjOk0/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sOP210ma84aHUIqjdbTezTc6vStV8NonefdGSCfvpWLsE+X/49qBJg38k8b6KCPPC lafQb+1GJQ1YHBEHgkD5uSdi+Oify/E7brJF2l/rkO0jBjb65iFO+8mx++JcJW31p1 MQDBjBGo+4HIF+BnHwBN0IU3QH/Zbva8io9toYEj6gWMuAcRP2O07erl1db3Ke++Z+ U4U5WPdsBJeMysx67cBHP/UeS6pZ3+lK7zL8nIZNYN8mueyTCOgahEkkpMlgPbgBlp nBeVVCmzMdesWIkdMF1ODbtYpt62MqamVbmYM941LWarhvXdEEoH2a4atEx9KUNiwU gvJk320hR2TCw== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Valentin Schneider , "Paul E . McKenney" , Boqun Feng , Joel Fernandes , Neeraj Upadhyay , Uladzislau Rezki , Zqiang , rcu Subject: [PATCH 6/6] rcu/exp: Remove redundant full memory barrier at the end of GP Date: Wed, 15 May 2024 14:53:32 +0200 Message-ID: <20240515125332.9306-7-frederic@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240515125332.9306-1-frederic@kernel.org> References: <20240515125332.9306-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A full memory barrier is necessary at the end of the expedited grace period to order: 1) The grace period completion (pictured by the GP sequence number) with all preceding accesses. This pairs with rcu_seq_end() performed by the concurrent kworker. 2) The grace period completion and subsequent post-GP update side accesses. Pairs again against rcu_seq_end(). This full barrier is already provided by the final sync_exp_work_done() test, making the subsequent explicit one redundant. Remove it and improve comments. Signed-off-by: Frederic Weisbecker --- kernel/rcu/tree_exp.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index bec24ea6777e..721cb93b1fec 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -265,7 +265,12 @@ static bool sync_exp_work_done(unsigned long s) { if (rcu_exp_gp_seq_done(s)) { trace_rcu_exp_grace_period(rcu_state.name, s, TPS("done")); - smp_mb(); /* Ensure test happens before caller kfree(). */ + /* + * Order GP completion with preceding accesses. Order also GP + * completion with post GP update side accesses. Pairs with + * rcu_seq_end(). + */ + smp_mb(); return true; } return false; @@ -959,7 +964,6 @@ void synchronize_rcu_expedited(void) rnp = rcu_get_root(); wait_event(rnp->exp_wq[rcu_seq_ctr(s) & 0x3], sync_exp_work_done(s)); - smp_mb(); /* Work actions happen before return. */ /* Let the next expedited grace period start. */ mutex_unlock(&rcu_state.exp_mutex); -- 2.44.0