Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1083941rwb; Thu, 19 Jan 2023 06:29:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXsdJZvMO4LzEbCmwynOy8bret15elTo0WHXToSH037n3WyH4Pvtb7sxnfHpk1XA2UlONZgy X-Received: by 2002:a05:6a00:26f2:b0:58d:e099:8cb1 with SMTP id p50-20020a056a0026f200b0058de0998cb1mr8368898pfw.33.1674138576484; Thu, 19 Jan 2023 06:29:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674138576; cv=none; d=google.com; s=arc-20160816; b=cWlpi506qZ085K6TZQ1CU/aYmpnYPbBcM/qsZZJKyzsWbO+h7l4qPkYUo46PQ5fB/K 0rCwjmBWl5swlReRGWSS4WbN5oIIc8LEuRFQtt2hlk8ZOvNtAw1zYW2ML2HXt/MO312a wwEhdJ/AthGgQ9L7E38hs/MOu0iNgXnchcFUvlGC31UHKb1pr5BT2jlDc5B5oFhcbKD/ LoeU5Bp5zltlf0u+vHOddC1+S8s++PoY0hV0J99tw1bgBRbVdkgglbx5eTWef+SFzbuw Xurr/5ZbDvts2OI83PK0FXaPsaxrnFWOnBos8kUcQ8FvMo1Tk1Pc1uIzk/8WnSzW77B1 W5Fg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=5CUmTqPmjX52enUmPCwB57zqNOP1mICFHsQFfZwCDbQ=; b=zmCZHWIA6soR6JQcLMdtCEvpAQJ/HHFPgy10u5N336LJBjrYsQV1D0bmUwwo9kZ9cc QKKRwoAivgBfNfEPloGsRz0C8mzQxSiLA+sXZ9XjR1mihoz/Gc/cd1RE52F9ETkC7saa /gVRjHmKo4NnkfLYiOL0hnlajBSYH1lnJvdOx/+0dmVs8wSZsqFfpo0za5HqeCyRZ+qn h2CpulWb8h7j21WkGgh4J7oA6dkf5ZC6Z6bOGisilsxrSzaKesVCc4hldVAc6L4oz1w4 cF6RlBMSx9Yvt+27uUmVzly5P/FnN1o2CzegiwEsaAkl6rTFcEuI4gfwrtFguQZkECC9 +sYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Rt8odT85; 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 y18-20020a056a00191200b00587df49bfa6si35823935pfi.75.2023.01.19.06.29.30; Thu, 19 Jan 2023 06:29:36 -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=Rt8odT85; 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 S231530AbjASONm (ORCPT + 45 others); Thu, 19 Jan 2023 09:13:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbjASONA (ORCPT ); Thu, 19 Jan 2023 09:13:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C1537A516; Thu, 19 Jan 2023 06:11:53 -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 dfw.source.kernel.org (Postfix) with ESMTPS id ABA8D6193C; Thu, 19 Jan 2023 14:11:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80185C433D2; Thu, 19 Jan 2023 14:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674137512; bh=OKFnPlamVIGxATjd1NpoI9TS3nc4OBBm0WxpbHl6GTQ=; h=From:To:Cc:Subject:Date:From; b=Rt8odT8545D3qVYinjspDEh3rgwBB4ANkAKDVJEm+jJN78EnbxHQmkHc3jSEAv7ie 6d+nWx12nnO/t1PlG5MiAVUauHLIf6SwoPGNVVeWzUADhNBkkVs3FbbW8AyTj7EkKc FM6T6iEvhnxgeufAUtD75tvqhZFCFFSGCmptQmFr71vNPgQdI6uBc7H3iCdMLWemNT XkJSnTt9+AhdmESNN357rcyZNfJZVqnOoJB7QT3p11rt2m9Y9yq9j5McHgBACnlUqk 1EfWxnLOk6TKT1355FNci4vOY3W9WeQSfXYahhQ+B2t/iti3DlIGXw3QcL+tK+RmDL X0PCcw+ISdlIQ== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , rcu , Joel Fernandes , quic_neeraju@quicinc.com, Uladzislau Rezki Subject: [PATCH] rcu: Further comment and explain the state space of GP sequences Date: Thu, 19 Jan 2023 15:11:35 +0100 Message-Id: <20230119141134.686626-1-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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