Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2165873rwb; Thu, 19 Jan 2023 22:18:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXu8JIxmbRpCMM04u6Fv6iFyRLX+3f+3TAzwrogPedoAx3YMqiSRUKOr6JfakJ57OqUQ0kI9 X-Received: by 2002:a17:906:7f0d:b0:844:c651:ce4b with SMTP id d13-20020a1709067f0d00b00844c651ce4bmr14220421ejr.33.1674195496883; Thu, 19 Jan 2023 22:18:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674195496; cv=none; d=google.com; s=arc-20160816; b=zygwTyMplkN1KHg7O9MCokPc/g4dLUQV1yy65JWoJn4gB3lD0JvjxjfOVvAUWiouiZ uvSHCYzcRJa9rYLS3K8e0/UHWUNmRxMMOcFLDzOJ+eRwQqfHM1Lu6KLPsFgZYcHHdM4w JB8gfwi3Pe5tJmz4So9ws/8vVCIt7iwgWA53gB/mjKIYKwjfKbnwiQArBB3wuaOWdG6I JAJKIVMayD1GqaKRYDZ63mA10sKdi/HEAqly2aW/xXhRSSNoZXcMNnjp/t6RjOlxwvx4 WZKa0noQwYqBcgmUbufOO91sOsluwkQOjD0oEgLbEBfxylCNr9P9VyCjfExtJIKE7ZVm mmqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Ekhpow5WC/7I3h4rdf9mK6L2QY1YPYEnKLYg7L/65mw=; b=qtgxgj3O0gL4ZMDF9vzsjx+CMVMH0Eb2HvJpGee2RuGV7xJ9UFX2l7GRwXW2PQDGop Z7Z9Bpw3tQWfz/4ZSXBL/LzGFiSRndcrIT15PR0YYKGCG2ck5PdVMD6VFBoQNDa72n1S NJ82ei/IvscNUH18MogI2yiH1iryNrqrBwioFESLSi9nbayjVr7peQhiZ8X1TiNpOMYY JC1RarpBojktTdn27I51F8hoWO82svQBYA5pK/ZpoOF/GdeWYV45STYymK3HFvBA/sn+ DfXKVLunFGQSfzX+FYYgO6J4Gsqy5sg8BoFbLXDYnNjwuazK9Y20IH/O0AMhGG+aQVrS wHiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="g/jk/087"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs30-20020a1709073e9e00b0087771101f29si5580152ejc.102.2023.01.19.22.18.05; Thu, 19 Jan 2023 22:18:16 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b="g/jk/087"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbjATFhX (ORCPT + 47 others); Fri, 20 Jan 2023 00:37:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjATFgr (ORCPT ); Fri, 20 Jan 2023 00:36:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAEFC3EFED; Thu, 19 Jan 2023 21:33:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4CFBEB82487; Thu, 19 Jan 2023 14:15:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D4A2C433EF; Thu, 19 Jan 2023 14:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674137743; bh=y0t6GNF97oojUan/jaNoYS+HcnhPuwYYN6KZoLbCUaM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g/jk/087duO+/BTUotk2esK9d/IyI7KDNb/PVilAxFldVI1vWXTGjKIQ6jhcq94BZ oVKUKykGi1vXyd3Cj3gH94op4ijiFpHwDv93aF5GVreNjiY3p4yzysjc+XTNnl6C2p ZJW6Q5z00CI1D60gm/i7XiQ03JbM4Y47gGMc82cI0w9VcFf/Vf0Qzjh8lcGoXs7APw 7omYmPOQ3yC9ZS994xuNnZxEkwV7mJFnH9yLJpLHV7C0xqZNWE0XCBTCZdr4OfwT4f fxWEoEJ1RsAkpDSW5V6spvIcDjimilw4sn95KCxQkmWsYAR+FCjnNVnh7f1fN/Omvu MGOPXOktQatqw== Date: Thu, 19 Jan 2023 15:15:40 +0100 From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , rcu , Joel Fernandes , quic_neeraju@quicinc.com, Uladzislau Rezki Subject: Re: [PATCH] rcu: Further comment and explain the state space of GP sequences Message-ID: References: <20230119141134.686626-1-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230119141134.686626-1-frederic@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Thu, Jan 19, 2023 at 03:11:35PM +0100, Frederic Weisbecker wrote: > The state space of the GP sequence number isn't documented and the > definitions of its special values are scattered. Try to gather some > common knowledge near the GP seq headers. > > Signed-off-by: Frederic Weisbecker > --- > kernel/rcu/rcu.h | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h > index 115616ac3bfa..fb95de039596 100644 > --- a/kernel/rcu/rcu.h > +++ b/kernel/rcu/rcu.h > @@ -14,6 +14,39 @@ > > /* > * Grace-period counter management. > + * > + * The two lowest significant bits gather the control flags. > + * The higher bits form the RCU sequence counter. > + * > + * About the control flags, a common value of 0 means that no GP is in progress. > + * A value of 1 means that a grace period has started and is in progress. When > + * the grace period completes, the control flags are reset to 0 and the sequence > + * counter is incremented. > + * > + * However some specific RCU usages make use of custom values. > + * > + * SRCU special control values: > + * > + * SRCU_SNP_INIT_SEQ : Invalid/init value set when SRCU node > + * is initialized. > + * > + * SRCU_STATE_IDLE : No SRCU gp is in progress > + * > + * SRCU_STATE_SCAN1 : State set by rcu_seq_start(). Indicates > + * we are scanning the inactive readers > + * index. > + * > + * SRCU_STATE_SCAN2 : State set manually via rcu_seq_set_state() > + * Indicates we are flipping the readers > + * index and then scanning the newly inactive > + * readers index. > + * > + * RCU polled GP special control value: > + * > + * RCU_GET_STATE_COMPLETED : State value indicating that a polled GP > + * has completed. It's an absolute value > + * covering both the state and the counter of > + * the GP sequence. > */ > > #define RCU_SEQ_CTR_SHIFT 2 > -- > 2.34.1 > Ok perhaps this one got the tabs right: --- From: Frederic Weisbecker Date: Thu, 19 Jan 2023 14:29:34 +0100 Subject: [PATCH v2] rcu: Further comment and explain the state space of GP sequences The state space of the GP sequence number isn't documented and the definitions of its special values are scattered. Try to gather some common knowledge near the GP seq headers. Signed-off-by: Frederic Weisbecker --- kernel/rcu/rcu.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h index 115616ac3bfa..fb95de039596 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -14,6 +14,39 @@ /* * Grace-period counter management. + * + * The two lowest significant bits gather the control flags. + * The higher bits form the RCU sequence counter. + * + * About the control flags, a common value of 0 means that no GP is in progress. + * A value of 1 means that a grace period has started and is in progress. When + * the grace period completes, the control flags are reset to 0 and the sequence + * counter is incremented. + * + * However some specific RCU usages make use of custom values. + * + * SRCU special control values: + * + * SRCU_SNP_INIT_SEQ : Invalid/init value set when SRCU node + * is initialized. + * + * SRCU_STATE_IDLE : No SRCU gp is in progress + * + * SRCU_STATE_SCAN1 : State set by rcu_seq_start(). Indicates + * we are scanning the inactive readers + * index. + * + * SRCU_STATE_SCAN2 : State set manually via rcu_seq_set_state() + * Indicates we are flipping the readers + * index and then scanning the newly inactive + * readers index. + * + * RCU polled GP special control value: + * + * RCU_GET_STATE_COMPLETED : State value indicating that a polled GP + * has completed. It's an absolute value + * covering both the state and the counter of + * the GP sequence. */ #define RCU_SEQ_CTR_SHIFT 2 -- 2.34.1