From patchwork Fri Jul 21 07:57:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 13321542 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 136B9C001DC for ; Fri, 21 Jul 2023 08:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231310AbjGUIEY (ORCPT ); Fri, 21 Jul 2023 04:04:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbjGUIEX (ORCPT ); Fri, 21 Jul 2023 04:04:23 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60BAB273C; Fri, 21 Jul 2023 01:04:21 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4R6hsY60zxz4f3lfH; Fri, 21 Jul 2023 16:04:17 +0800 (CST) Received: from huaweicloud.com (unknown [10.174.178.55]) by APP4 (Coremail) with SMTP id gCh0CgA34qX_O7pk9KzbOQ--.39718S5; Fri, 21 Jul 2023 16:04:18 +0800 (CST) From: thunder.leizhen@huaweicloud.com To: "Paul E . McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , rcu@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Zhen Lei Subject: [PATCH 1/2] rcu: Delete a redundant check in check_cpu_stall() Date: Fri, 21 Jul 2023 15:57:15 +0800 Message-Id: <20230721075716.857-2-thunder.leizhen@huaweicloud.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20230721075716.857-1-thunder.leizhen@huaweicloud.com> References: <20230721075716.857-1-thunder.leizhen@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgA34qX_O7pk9KzbOQ--.39718S5 X-Coremail-Antispam: 1UD129KBjvJXoWxJr17trWfCryxGw1UGFyUJrb_yoW8Xw17pF WDAw47Ka1rGF1IkwnFy3W8JryUuan8WFyUJ3WDXrnYva9rAF1fKF98ZFy5Ga4rZr93Jw4a q3Wktw17Cw4UKFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBCb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6r106r1rM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV WxJr0_GcWl84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwAKzVCY07xG64k0F2 4l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWU JVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7V AKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42 IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU46wZUUUUU X-CM-SenderInfo: hwkx0vthuozvpl2kv046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: Zhen Lei j = jiffies; js = READ_ONCE(rcu_state.jiffies_stall); (1) if (ULONG_CMP_LT(j, js)) (2) return; if (cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) (3) didstall = true; if (didstall && READ_ONCE(rcu_state.jiffies_stall) == jn) { (4) jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3; WRITE_ONCE(rcu_state.jiffies_stall, jn); } For ease of description, the pseudo code is extracted as above. First, assume that only one CPU is operating, the condition 'didstall' is true means that (3) succeeds. That is, the value of rcu_state.jiffies_stall must be 'jn'. Then, assuming that another CPU is also operating at the same time, there are two cases: 1. That CPU sees the updated result at (1), it returns at (2). 2. That CPU does not see the updated result at (1), it fails at (3) and cmpxchg returns jn. So that, didstall cannot be true. Signed-off-by: Zhen Lei --- kernel/rcu/tree_stall.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index cc884cd49e026a3..371713f3f7d15d9 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -794,7 +794,7 @@ static void check_cpu_stall(struct rcu_data *rdp) rcu_ftrace_dump(DUMP_ALL); didstall = true; } - if (didstall && READ_ONCE(rcu_state.jiffies_stall) == jn) { + if (didstall) { jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3; WRITE_ONCE(rcu_state.jiffies_stall, jn); }