Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2624770rwo; Sun, 23 Jul 2023 20:47:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlGNVngVeO4fiR/AnRXQJrhCMDnGsP/LrjL8uJA3rygGc58FEBM5zE5gL5mZF+Flb9+yyn6F X-Received: by 2002:a17:906:1d9:b0:973:ca9c:3e43 with SMTP id 25-20020a17090601d900b00973ca9c3e43mr8504803ejj.45.1690170476017; Sun, 23 Jul 2023 20:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690170476; cv=none; d=google.com; s=arc-20160816; b=xuO8jTf4uw9xVcvMtlUOd3SRcKF8L0+ZYH6w6XTD7d/OL03K2JbG+XrOJamA0QXA0o MiStbj9WJjZtqkkD69Dg9XyWbH1eaDcouxTQDNtyLhHvnpt5pS6L2PRV/sTozGKiPZs7 NKej7BXlqxf7YQcHBPH3H1ehA601mGpke5k8WlkSO82IA29G4FkMUoT1UUcpCmobtq8j CdDRm/f4Lh1KatmV3K0cuKkI/zCaNCLSbgxEFVL0coRVnciDTEIkiQqh3hsHvAJxe3FY Enhcjr6mzTWH2uY9XqfiIT0lp3Bt7ehcgsE7VQUPv4KIIojS7uAGemAqrK2mJnmUi76Y ADZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/vh+lK1Kh/jWqDSpT68Nj187KVXpeHhtW55C4KVCYTk=; fh=0rnhE/zTO5jJrapQtiGxHWUHqy9BigHXhn1AL1AgfCY=; b=l54v9457U26ve/EhYc9r61biIO+rT83vD2Tu+NSCwBTbeq+jBwk/Yd9f8cICU7IibK g8DO7vT9RjpZ/aBowwwSwdSg6jgOb/U352v6oSwwaopqkeed7OdjmKBbqGbcDg8PSk7m JcZZqY+seZ5oHI7o2j/5tjD5IswnTb2GAZQWy0+tl32ZzYSlzi/qozn7w0vGLuuHjSdO HXMnxKm66M3ke/Q5StMOFDg084FKdx7HJ+DuElsY6eRPmS0a671CKblg1oZx8a+i4hJo jIDThmFy6JgyqdMGeFrHm+yznwgGc8jtE9401ZaAxaE4zZLax0OgH9z7Km6AEGgGdtS8 YXWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="iA/Ir/yG"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a170906354400b0098df1cbe2aesi5934793eja.1008.2023.07.23.20.47.32; Sun, 23 Jul 2023 20:47:55 -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; dkim=pass header.i=@gmail.com header.s=20221208 header.b="iA/Ir/yG"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbjGXDVU (ORCPT + 99 others); Sun, 23 Jul 2023 23:21:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjGXDVS (ORCPT ); Sun, 23 Jul 2023 23:21:18 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C57313D; Sun, 23 Jul 2023 20:21:17 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-262d33fa37cso1907953a91.3; Sun, 23 Jul 2023 20:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690168876; x=1690773676; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/vh+lK1Kh/jWqDSpT68Nj187KVXpeHhtW55C4KVCYTk=; b=iA/Ir/yGS0vqXQZi4NOyNhedqIeJhPp3btHk7G1v9ThEQtt7OtrG8tJURqt+Li4WyW Qauzg9aBt5YDzl+qInTFWzgjGTB8sSeSQgVEIePQugCQtTANxP1ilXT2APH3niscwpxY D0JxS8xqEHc9HUCPWdqUQ95Zb72o3v+T/oj/y6YB1hmANQE9IEQriSnAsFQ7GiraGy+1 6tMA+020gpkM47AAsrglLQQgS5bz5iKGUOMCE2cFT3DqqxBJB0/dlSg+PGzMDz95P2+H Jq23+GTpr4fDuOGHOpxaF7XLez72wPqEK4s+M7w36g81E8Vo339tixNgPo8S9bzekE6d JRwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690168876; x=1690773676; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/vh+lK1Kh/jWqDSpT68Nj187KVXpeHhtW55C4KVCYTk=; b=OK2SzRUFogeH9rZKxNhc+KS6tOGklJTKvPVZn/KQJNdCO4cwAjfijZQC1OXXNUNZHJ h3ou+4W+jY2EspX5sNdit0DfvOjv2ilh3NEPa9V8C3pmx1XqB1e/YoVUG8M6Mx8zEi+g MbawDfHU1axQU/bXw06Xevw/XCYcqNgbUjy4t0Fuxosrauaf/dGGv6iVe5NkXLmGHbkG 5/P3cabEOX5Tp1N33TdBy0TUMkvVXU24GG5/4TUcJW8JDH0nWleBQhHrTzxBg8rWzrot kmjC0DleunX+s86dBo6kZSdr5zCR2KzIuyxzVNZX98qXy8Ptsabdx6Mmst47Xf3/7fZ+ 2PwQ== X-Gm-Message-State: ABy/qLa+jR6AqXxPt/7PNuwDNU03iw7E3IGirXC7eX55A8/MWMbPFRTh u7PolZ/S+q3+PDwafd8c3SAy4aTWF7dzGbinyMtY3nnSEck= X-Received: by 2002:a17:90a:f2d3:b0:267:ce35:2f10 with SMTP id gt19-20020a17090af2d300b00267ce352f10mr7398282pjb.4.1690168876417; Sun, 23 Jul 2023 20:21:16 -0700 (PDT) MIME-Version: 1.0 References: <20230721121534.44328-1-ppbuk5246@gmail.com> <05e98227-77f4-4918-8f8e-2170a158e350@paulmck-laptop> <31070aab-8665-44c4-8950-0631a777ef44@paulmck-laptop> In-Reply-To: From: Z qiang Date: Mon, 24 Jul 2023 11:21:04 +0800 Message-ID: Subject: Re: [PATCH] rcu: remove unnecessary check cpu_no_qs.norm on rcu_report_qs_rdp To: Yun Levi Cc: paulmck@kernel.org, frederic@kernel.org, quic_neeraju@quicinc.com, joel@joelfernandes.org, osh@joshtriplett.org, boqun.feng@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, 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 > > Thanks for replying to reply Paul :) > > > And try testing with CONFIG_RCU_STRICT_GRACE_PERIOD=y and CONFIG_PREEMPT=n. > > Though there might be better Kconfig options to use. Those two come > > immediately to mind. > > I've tested with this option via rcu torture. > and it doesn't report any problems. > and after commit 6d60ea03ac2d3 ("rcu: Report QS for outermost > PREEMPT=n rcu_read_unlock() for strict GPs") > it always makes cpu_no_qs.b.norm false whenever it calls > rcu_report_qs_rdp in rcu_read_unlock. > > > But one critical piece is that softirq handlers, including the RCU_SOFTIRQ > > handler rcu_core_si(), can be invoked upon return from interrupts. > > I think in that case, no problem because if it reports qs already, > rcu_check_quiescent_state wouldn't call rcu_report_qs_rdp again. > And if RCU_SOFTIRQ is called as soon as RCU interrupt is finished, > it seems the fastest one to notify qs to related tree. > > > Another critical piece is that if a CPU is idle during any part of a > > grace period, the grace-period kthread can report a quiescent state on > > its behalf. > > I think > 1) If timer interrupt is still programed, > - when rcu_sched_clock_irq first reports qs, no problem > - If qs is reported via grace period thread first, > note_gp_chagned in rcu interrupt > will recognize this situation by setting core_needs_qs as false, > it doesn't call rcu_report_qs_rdp thou cpu_no_qs.b.norm is true. > > 2) If the timer interrupt isn't programmed, > - rcu_gp_kthreaad reports its qs, no problem. > > So, I think there's no problem removing > "rdp->cpu_no_qs.b.norm" check in rcu_report_qs_rdp. > or wrap this condition check as WARN_ON_ONCE. > > > Does that help? > Many thanks always :) > Hi Levi For built with CONFIG_RCU_STRICT_GRACE_PERIOD=y and CONFIG_PREEMPT=n kernels Consider the following scenario: __rcu_read_unlock() -> rcu_read_unlock_strict() ->rdp = this_cpu_ptr(&rcu_data); ->rdp->cpu_no_qs.b.norm = false; by interrupt and return invoke rcu_core(): ->rcu_check_quiescent_state() ->rdp = raw_cpu_ptr(&rcu_data); -> rcu_check_quiescent_state(rdp); ->note_gp_changes(rdp); -> __note_gp_changes(rnp, rdp) start new gp ->rdp->cpu_no_qs.b.norm = true; ->rcu_report_qs_rdp(rdp); ->if (rdp->cpu_no_qs.b.norm || ...) Thanks Zqiang > > -------- > SIncerely, > Levi.