Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10585961rwp; Fri, 21 Jul 2023 01:21:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlH3DTgF3zFsyEbCZzwU8tIFcRE3aFqq33WJ8+/jSg3aWyCHdopdueelyY2r7ggFi8zLkCvu X-Received: by 2002:a17:907:7750:b0:992:4250:5462 with SMTP id kx16-20020a170907775000b0099242505462mr1194351ejc.50.1689927691147; Fri, 21 Jul 2023 01:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689927691; cv=none; d=google.com; s=arc-20160816; b=sorti9SES5/WYqWk/AtHHXfVesDJrc/cnQgnvTYQggq0ganNRyp6rZHaP+oupfgghw SB07noy+YRAKOTxXqcNxpVZJDwLGpO5uxuzWJE7egFblhFzAFxgzoCJhw8R93tXvrjpi /s7hOkLJbvPWFhpOJx90T0vfrkGO1kfXWv0TKTKl+3X+aGzW/OkKjoDiukaxoGJNiTAQ S8LIauFls73f7X1OWWsVJQyHp1dv8SAKu23FshfR0ZFrOAH2BOl9pTWD3n91kUCLC/bp 0SX6GNTx6uFmZ1X2XirGHDF8YFyhyEk0KLBPzVvuOWyrmlreU88Sv2lHoXAzT4KKmIeL egeg== 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; bh=DL5icHQRDk9V00z6G1W1vkIAiop4nRlmgRzm01xdTbY=; fh=dqyPVSEtrTzyolOhNoD5isrr7S2Tn6sjznP8KmpBFJA=; b=o5iYphbkrHBER1s6QMVuRuPOdRCetb1eAEW0sJJaU4uileBESQFtlnWoxrxbNMrWeB 8Xupt6sxBtsEe/ajr18WnmMecLvLlkzICcX1HFCCS2gMGgYH4NBQk71Hzt87I0EATMLT O+A1Shrlwg0hX0ypZsvToUtKdTrEhjYyp0jBukFiveCiRnM+N9tlW1b2YcVIKk8YWAGH mqMl6wrpWcTDXvhA42vNp3meovqOCqPGvXy73khNjW6ll+gr1vD8zEkxLrQvxLbTWWoZ S0tSQT08BehFOF+HTW8l/psf6pv7ov0yy6YJFQKHhbFMkDYBymFfG2wbkJPpkVGPcNSU imfQ== ARC-Authentication-Results: i=1; mx.google.com; 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 ks14-20020a170906f84e00b00986441fe930si1833497ejb.103.2023.07.21.01.21.06; Fri, 21 Jul 2023 01:21:31 -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; 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 S231315AbjGUIE0 (ORCPT + 99 others); Fri, 21 Jul 2023 04:04:26 -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 Content-Transfer-Encoding: 8bit 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: 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); } -- 2.25.1