Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10587011rwp; Fri, 21 Jul 2023 01:23:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlHfwUGrrSYx0SbDnG4z5UKlOLoPtn8qml8M8bKBsi2TgwoJQQVQQ+ccWuLdRIz/LUtHRNoO X-Received: by 2002:a17:906:7a13:b0:993:eddd:6df9 with SMTP id d19-20020a1709067a1300b00993eddd6df9mr1061149ejo.2.1689927782295; Fri, 21 Jul 2023 01:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689927782; cv=none; d=google.com; s=arc-20160816; b=USUyVEZPr1+Syvpvahu6uigJD+qT1XXcl1fYGDqQsGzXxMLULfXJcuRwyqKY+z54Jv EBoZwYTzxQFv4Qe+yKlgikG4n7bpla7ay4BDuwMdU8Ukggt3hPzzxz1R8t/19sEDVmKN gIOyoqg278mO6Xj/LCmVGj7eWNQtzAqlCMRLIyGZREom42Mk1/N6lQLkZVimJFySL7ak Lsq2VUSGwx4A3yZ4uP8fqY/dVEHwp8E4bvbwVdKsL82l7WHnGIhLQFbk3UiJuGrBeIKH XMJ91wSxJgKhWIyrC2FyhJymAaeKRr7+MjVD0mJiQ2EUrLN7aigeMw3/vaPUaJE3JiSV oV1Q== 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=3QMG8EbtslXBMam3KsFBnVr/MBTCa2kx4Iir0vqd6oY=; fh=dqyPVSEtrTzyolOhNoD5isrr7S2Tn6sjznP8KmpBFJA=; b=fP0dDqy0ngsqj3+74HbWiYgj11gvcDbPqUfOQbACKK2PaL2DaLz9FUiWbZzUtdJ5Bf qUOQsAqr0qILEEWibwnHGe8Fk38qHoSTJy3JwQZ2k7EI7aHoonviZ27BPCTXocFBPZSX TcUM2whuId3PxDQa+yIMcxwnm3NyqTsZ57kXxRTb0/fgA7+9pCGrLxrelfRpxvOFdBn4 zPGrfameIPQdE/BrQiOIuS2EF2JSIkYTkKf29ovrLz4Eutxv6PwDcIkcLYrxsYBKIdiR 3AvbrKX2tpxg/Lr2XOBpde6VHBKXhaLVilSEowdTJ6eXmGgGLoKdjagPVho1i45amj2V Ibzg== 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 md12-20020a170906ae8c00b0096fe1a56de3si1836534ejb.1048.2023.07.21.01.22.37; Fri, 21 Jul 2023 01:23:02 -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 S231325AbjGUIE2 (ORCPT + 99 others); Fri, 21 Jul 2023 04:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231273AbjGUIEX (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 760512707; Fri, 21 Jul 2023 01:04:22 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4R6hsZ65jTz4f403c; Fri, 21 Jul 2023 16:04:18 +0800 (CST) Received: from huaweicloud.com (unknown [10.174.178.55]) by APP4 (Coremail) with SMTP id gCh0CgA34qX_O7pk9KzbOQ--.39718S6; Fri, 21 Jul 2023 16:04:19 +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 2/2] rcu: Simplify check_cpu_stall() Date: Fri, 21 Jul 2023 15:57:16 +0800 Message-Id: <20230721075716.857-3-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--.39718S6 X-Coremail-Antispam: 1UD129KBjvJXoWxWw1xuF4xWFy8Cry3WFykXwb_yoW5Gr4Upa 9xJa42gan8JFs29392q34kJr15Ar4kXFy7Jasrtw1Fya9rAF1Fgas09ryfGFy5ur93Xr4S vFyFqr1UCa1DtFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBCb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6r106r1rM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV WxJr0_GcWl84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwAKzVCY07xG64k0F2 4l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWU JVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7V AKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42 IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU7g4SUUUUU 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 The code and comments of self detected and other detected are the same except the output function. Combine the same parts to avoid duplication. Signed-off-by: Zhen Lei --- kernel/rcu/tree_stall.h | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 371713f3f7d15d9..0ade7f9dcaa18da 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -711,7 +711,7 @@ static void print_cpu_stall(unsigned long gps) static void check_cpu_stall(struct rcu_data *rdp) { - bool didstall = false; + bool self_detected; unsigned long gs1; unsigned long gs2; unsigned long gps; @@ -758,10 +758,10 @@ static void check_cpu_stall(struct rcu_data *rdp) return; /* No stall or GP completed since entering function. */ rnp = rdp->mynode; jn = jiffies + ULONG_MAX / 2; + self_detected = READ_ONCE(rnp->qsmask) & rdp->grpmask; if (rcu_gp_in_progress() && - (READ_ONCE(rnp->qsmask) & rdp->grpmask) && + (self_detected || ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY)) && cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) { - /* * If a virtual machine is stopped by the host it can look to * the watchdog like an RCU stall. Check to see if the host @@ -770,31 +770,17 @@ static void check_cpu_stall(struct rcu_data *rdp) if (kvm_check_and_clear_guest_paused()) return; - /* We haven't checked in, so go dump stack. */ - print_cpu_stall(gps); - if (READ_ONCE(rcu_cpu_stall_ftrace_dump)) - rcu_ftrace_dump(DUMP_ALL); - didstall = true; - - } else if (rcu_gp_in_progress() && - ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY) && - cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) { - - /* - * If a virtual machine is stopped by the host it can look to - * the watchdog like an RCU stall. Check to see if the host - * stopped the vm. - */ - if (kvm_check_and_clear_guest_paused()) - return; + if (self_detected) { + /* We haven't checked in, so go dump stack. */ + print_cpu_stall(gps); + } else { + /* They had a few time units to dump stack, so complain. */ + print_other_cpu_stall(gs2, gps); + } - /* They had a few time units to dump stack, so complain. */ - print_other_cpu_stall(gs2, gps); if (READ_ONCE(rcu_cpu_stall_ftrace_dump)) rcu_ftrace_dump(DUMP_ALL); - didstall = true; - } - if (didstall) { + jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3; WRITE_ONCE(rcu_state.jiffies_stall, jn); } -- 2.25.1