From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8ACAA41DEF7 for ; Mon, 7 Sep 2026 07:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767931; cv=none; b=lRlxLGWqmRxLR6te4drsxfFxFHXVX5baxuFVIWpUo5Zs4DjwfT5jYHwp1wnJT0N8q6NSMUwKl/CMagD/RLcFq1WMenx8pChxVpMiJ9uNqCKg84FiyjXLgl6EiBbUuaPtAw2SzYHhR2XWCkhZS4eRcrsJOG5XN9OKzcjunOIjVfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767931; c=relaxed/simple; bh=TCCpXwnmodeVmKo1E6y7S918XFzRwDxpNrXxJ9AKFVc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QKelLs9A5ngp4MtJkaSeAT/65IsOF8wbqrYuTJ+TnH3dJO6fYoG53PnTf88oW17le/9TaSsEnoCOyFqT4NmRFeLNuIv4K0IkAloId9WK6TP4FvJwVBX3jcrdoAWUbCvJ/LTVLuz5agJ+6YGnNdNyUsjmxuNPsa4t4x4VyLfOHYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SG1bOGsB; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SG1bOGsB" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2d6d28aa26cso18961335ad.2 for ; Mon, 07 Sep 2026 00:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767927; x=1789372727; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=kkKaVITt+/rz08+YgC0jvTu5c22naN5LQ082iYcixrU=; b=SG1bOGsBqe8CnfPDXvaR6Qj4r+mDvEJoZMa9O2M+gLVJ7ZY2308DAh0NvCM4ntJMW/ j1ugl2zMkmizJtVEr4fQQZNRUaqikpEFbYIvsG9X+rZt94v6ZZBATyNFfhsKcmgvK7H6 yBGOHkrIENzwALIheKqd0lsRh6pmnXLonLqARhh8UoXgb28NODO/rLYOrBTXqV2uF2wl j7CXxx6bB7ME2nVGDegZCdbpcsF0Q+l1tgmZ2aLoLfrB9uDPCvTUJun/9KoZjHJngbfD Xbf9E9o0L3VimHI3Y/MHJcwhTuzCHli++grhfDm2OE8D6+IO4sK23who2PQF4eVce3AK m1KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767927; x=1789372727; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=kkKaVITt+/rz08+YgC0jvTu5c22naN5LQ082iYcixrU=; b=X/Zpb5z19YeoG2e0PpU4gP8qCR+AGSk8Cj8/N+qNcBvpLlRVnkhZvpZwdK4M+n070E 35RTP7zF1is/OvCAmBgZu2kvSx4Pi3T3OZkI8sEe9gwNEXQGKzCNQEtpcaPIlYAU3Yse 2ibApcf6zJXfqKYMSOgp764ybyaA5x/h+3mikIKmvcSs9a86jElVD7O9xwOMB/aaYOqB PI+oo1Dewsr45gLh5N4UDKTwqETFLea8ntji4A76a4jU7XpnU1f8NPzHYwTf+xR8VQOl i9TrETXRmaZq65fgFTVZ1sF/7ufBZPc1tivyE+C4ro1si1audEh379eneFiLCNyOMLRT RRDQ== X-Forwarded-Encrypted: i=1; AKwUvBw4nIIjiRvgRyf2Uj30mF29mJTL6wL1wqsd4eaQ8GfBU8oUSGeXMWhjTf1byN3G5msMzUFbemCA27cRHaI=@vger.kernel.org X-Gm-Message-State: AFuF++llLw3rf1ciZOi71MW6MRmxibrAP3n1y+Fgi1ap8++OyzMDrtwq 4WU3SLALMzLLb0TPTWkwzLbFTVrooAqS59KkPI0/ySYjlfQyV797sq4p X-Gm-Gg: AYBFou200TcEPgGzJzsjBxpTspZnc2rjCGp57oL4aXaS163tXK/8wLY4bL4Ns6QwU9d 6wXFTylc0FIx6wQxe1WSInP3j9SLSD/KFloD1KEaLVp1dzoKPgDp7HExNoIC1oiKzpBiREIUJzb ClHcYKAtgPOsWFsKmKhwtR5QTnb5kSuBmVG6VXlAnC9esXTm60Mwa/jA2GbHb/HPiy9077QYnhE qZO0CQ+8zSjXGxOvygE4Dvlm6FNoY3Q1bo+w7kSo1knwtFcaKkB3fFVCvITB5G0uowPs+cqc2v+ 7rh4j90MKsjkw3TuZMEkEsvyeJDbTFvbDsnFXUtV2tm1+QjoIJ1dvYtpWbWTbqxEpOhpdYMsH9x keL5zE5As0yTNAWppymyZzpEapLCiCzcRQvGL/L4q2U7BQWRVU34TcZL2ELlXmA6xN8bQkq3zzF sN6gpu00HakdnDERY0G+sylctiw4wLM8tDhGrK3LdqWD6BdGqd/jr0vzewX/aiJnRpo8ChGRZRx eRTZhgw X-Received: by 2002:a17:903:2383:b0:2d8:d4ce:9f35 with SMTP id d9443c01a7336-2db12757af4mr288425665ad.19.1788767926938; Mon, 07 Sep 2026 00:58:46 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:58:46 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 01/13] litmus: Add SRCU fastpath anchor-before-scan test Date: Mon, 7 Sep 2026 15:58:17 +0800 Message-ID: <20260907075829.2073224-2-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan synchronize_srcu_atomic() may end its grace period immediately when its scan of the per-CPU lock counters finds no readers. Correctness requires the grace-period anchor written by srcu_gp_start() to precede the smp_mb() ordering the lock scan. This ordering ensures that any reader whose lock increment is missed by the scan cannot have incremented its lock counter before the grace-period anchor, and therefore cannot be a pre-existing reader of this grace period. This litmus test models the key ordering between the grace-period anchor and the lock counter scan, where "seq" models the grace-period anchor in ->srcu_gp_seq and "ctr" models the per-CPU ->srcu_ctrs[].srcu_locks counter. P0 writes the anchor before the smp_mb() and the lock scan. P1 models the reader-side counter increment, with the smp_mb() of __srcu_read_lock() following the increment. P2 models an observer that sees the reader's increment before seeing the anchor. The outcome is forbidden by LKMM, and herd7 reports "Never". See SRCU-fastpath-scan-before-anchor.litmus for the reversed ordering, which permits this outcome. Tested with herd7 7.58 using linux-kernel.cfg. Signed-off-by: Kunwu Chan --- .../SRCU-fastpath-anchor-before-scan.litmus | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tools/memory-model/litmus-tests/SRCU-fastpath-anchor-be= fore-scan.litmus diff --git a/tools/memory-model/litmus-tests/SRCU-fastpath-anchor-before-sc= an.litmus b/tools/memory-model/litmus-tests/SRCU-fastpath-anchor-before-sca= n.litmus new file mode 100644 index 000000000000..8200a75e15ef --- /dev/null +++ b/tools/memory-model/litmus-tests/SRCU-fastpath-anchor-before-scan.litm= us @@ -0,0 +1,56 @@ +C SRCU-fastpath-anchor-before-scan + +(* + * Result: Never + * + * The synchronize_srcu_atomic() fastpath may end its grace period + * immediately when its scan of the per-CPU lock counters finds no + * readers. Correctness requires the grace-period anchor written by + * srcu_gp_start() to precede the smp_mb() ordering the lock scan. + * This ordering ensures that any reader whose lock increment is missed + * by the scan cannot have incremented its lock counter before the + * grace-period anchor, and therefore cannot be a pre-existing reader + * of this grace period. + * + * This litmus test models the key ordering between the grace-period + * anchor and the lock counter scan, where "seq" models the + * grace-period anchor in ->srcu_gp_seq and "ctr" models the per-CPU + * ->srcu_ctrs[].srcu_locks counter. P0 writes the anchor before the + * smp_mb() and the lock scan. P1 models the reader-side counter + * increment, with the smp_mb() of __srcu_read_lock() following the + * increment. P2 models an observer that sees the reader's increment + * before seeing the anchor. + * + * The outcome is forbidden by LKMM, and herd7 reports "Never". See + * SRCU-fastpath-scan-before-anchor.litmus for the reversed ordering, + * which permits this outcome. + *) + +{} + +P0(int *seq, int *ctr) +{ + int r2; + + WRITE_ONCE(*seq, 1); + smp_mb(); + r2 =3D READ_ONCE(*ctr); +} + +P1(int *ctr) +{ + WRITE_ONCE(*ctr, 1); + smp_mb(); +} + +P2(int *seq, int *ctr) +{ + int r3; + int r4; + + r3 =3D READ_ONCE(*ctr); + smp_mb(); + r4 =3D READ_ONCE(*seq); +} + +exists (0:r2 =3D 0 /\ 2:r3 =3D 1 /\ 2:r4 =3D 0) --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8E2A424D5A for ; Mon, 7 Sep 2026 07:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767933; cv=none; b=HqPJ9GJJiKJbwFj7zOG4mfWHy4nS2wHV7Rq3ltCphI43giBB809/uZHYn9QPJpUDuwolRZPfEbGicr1qEG8AfyISjIAMZoNM1nD7eue03JTF94km/M2BI2S/hpnd61oVbyc+x7N7Oni+EnbjPfExQImAnF4DhFvT5X8avOwpNn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767933; c=relaxed/simple; bh=mxf0oO1tznDF9cRWAuZoopNyrJAvMa4wUwk5Nu5DUh4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MywZ+Vc2oM6thj8fC/SSc4FDzc7xSTjtWTywwSTQls+6XRQ5uTk36u6CQoocDbKx/e3oCshl3tP7doxClmyArfQLIhZmmP6CH8Z43b9+y7yJAtkkIVgBqPVV64sli3XlfRBP90MK7vIRNaFOuMgsuCD7PG8CRKxtwQ8pKgfXpwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cvySR5mV; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cvySR5mV" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2d71ae3455aso48059835ad.1 for ; Mon, 07 Sep 2026 00:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767931; x=1789372731; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CwNQOTYYKAxRvINgOc7TCo5ZbK+NqIUlV7D1RviVpA8=; b=cvySR5mVV8FYAZO5T9LNWMbF5aaQryYNU1ItvVjm4lTFJdrgGV50wqQPKJaCcSD9Xm /vyPIKgDCOwleXmxOmASHaHjo15kn6F6JI/kGz6onn5HNe6PqGheS/SbVml38897wp4B nklQzg59EmY4PmYRZNvsSzja5pH8FqOcay4F68hPgnFCqcnNxEP9xW45TQ05aqdni2z0 Hg4dNPge9JW2oX5YWH8cizLfgcoBTKCN3zk6IaoOD5p4VyhmVAB18Z0EiJhw9kmyTpDn BkjZOhnDf1HAYpUb4B//U/rZsdiCwBb7Gy6qOOmI1j+F5J1teJBOZtS8dqxnjfKrlYMX P0uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767931; x=1789372731; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=CwNQOTYYKAxRvINgOc7TCo5ZbK+NqIUlV7D1RviVpA8=; b=eQ5jq58ZykX7JMgEFylj4E9GqjnXCO4ZjOOthDYsJxjKm2FFtMF8djviW+2JUqoXtg Sy7YwdrlJUHzFEybVKu2dVzKMOoKqLqiZkpa4VPBhzv2I4ieJYqziO5/G9urcLmcqBuP E82mD3jGMLJjTlMYLPbUqEsyAK7bwAsGren9SGmq3aLKfvEVSZbzwiH8LCC5SJhc7aYx 6IWQkIpAEw9xA94X0B37DrYr4SCSDI4osRoxEbePuPSjDdKPk1uMFmz6cxyffiPbHwnW yPu7/Rk/hZNvub7zTKPF9VycXOWYB2/Cb/2D93Na0P52kfhtJhDqVM8/7ClHkxLMkMgn q6Gw== X-Forwarded-Encrypted: i=1; AKwUvByhLZId8ByC6gKxi9M12R6NxAQ744NE/ZMTPUsO3BGwymKdWcRPDjAqyHdJwWZy0RTDtH50hex2HvAohVc=@vger.kernel.org X-Gm-Message-State: AFuF++m/Wi7coR2YJNXDhlO0+OX3npWCju7dGErEIvK9Mfh7HKYdQWGP e9PbOF0l7p/X7sUT8R4NCjV7zeB5UweGuwf+p+b0HNOVuTzosPHixDQp X-Gm-Gg: AYBFou1C/DEmTQahatrsotyKQQcldJCWojj1Ie04s1fL3HDOBiK7DFmbkd536BkHJS8 TG0K7ziL0xRku72q11Y7U3k33Ddc8Vz31aInGFhxo/ToDpjaWa8bg8eLh39d4zK5dgh2I4P2Yii ACJalcWf4gMTa+TAnvlsoPnG0hPVUQCeXgNlh0xXXOqI5yDKOGwPkSJCG0rkDn2ASwyE3SCyqqH pDxEv2qh3QsFG3PBjvxsSEuYN5X4A76TWsCI7bLsLMkdjRGzPcvqvzqE/eLk4PRI49lmwidpf1F 9PDTm8UYynAUMkhNcW9ZrT/6XeBtc7/BqCqzVP0KL7lh2cXLlzl1gpuC9+3YUMEUVaILjZ+UQ3X 9PYPjHcLtt78uu561iBxApEZJepntk2KG4c7HCGnc1dwjkbH/b89Gdm3tCXlXaWqDc27/rneMxo +ZbrflKRHUl/mfZ2B4lInmoVK05jtmK5r64lXrXYeyQLPC9w2BzWIhVrsM9PnbHFIISekvmVdWe kC5Y9E= X-Received: by 2002:a17:903:3c27:b0:2d9:b60d:7755 with SMTP id d9443c01a7336-2db125cd34bmr317335215ad.1.1788767930431; Mon, 07 Sep 2026 00:58:50 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:58:50 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 02/13] litmus: Add SRCU fastpath scan-before-anchor test Date: Mon, 7 Sep 2026 15:58:18 +0800 Message-ID: <20260907075829.2073224-3-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan If the synchronize_srcu_atomic() fastpath instead places its lock scan before the grace-period anchor, the scan can miss a reader whose increment was already visible before the anchor. That reader already existed when the grace period started, so completing the grace period without waiting for it would violate the SRCU grace-period guarantee. This litmus test models the reversed ordering, with the lock scan placed before the grace-period anchor. "seq" models the grace-period anchor in ->srcu_gp_seq and "ctr" models the per-CPU ->srcu_ctrs[].srcu_locks counter. P0 scans the lock counter before writing the anchor, with an smp_mb() between them. P1 models the reader-side counter increment, with the smp_mb() of __srcu_read_lock() following the increment. P2 models an observer that sees the reader's increment before seeing the anchor. The same outcome is allowed with this ordering, and herd7 reports "Sometimes". The litmus-tests README is also updated to describe both SRCU fastpath tests. Tested with herd7 7.58 using linux-kernel.cfg. Signed-off-by: Kunwu Chan --- tools/memory-model/litmus-tests/README | 16 ++++++ .../SRCU-fastpath-scan-before-anchor.litmus | 53 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tools/memory-model/litmus-tests/SRCU-fastpath-scan-befo= re-anchor.litmus diff --git a/tools/memory-model/litmus-tests/README b/tools/memory-model/li= tmus-tests/README index d311a0ff1ae6..449747c6db9e 100644 --- a/tools/memory-model/litmus-tests/README +++ b/tools/memory-model/litmus-tests/README @@ -137,6 +137,22 @@ S+fencewmbonceonce+poacquireonce.litmus Can a smp_wmb(), instead of a release, and an acquire order a prior store against a subsequent store? =20 +SRCU-fastpath-anchor-before-scan.litmus + This models the synchronize_srcu_atomic() fastpath with the + grace-period anchor ordered before the lock-counter scan. This + ordering prevents readers that existed before the grace period + from being missed by the scan. See + SRCU-fastpath-scan-before-anchor.litmus for the reversed + ordering. + +SRCU-fastpath-scan-before-anchor.litmus + This models the synchronize_srcu_atomic() fastpath with the + lock-counter scan ordered before the grace-period anchor. This + permits the scan to miss readers that existed before the grace + period, violating the SRCU grace-period guarantee. See + SRCU-fastpath-anchor-before-scan.litmus for the opposite + ordering. + WRC+poonceonces+Once.litmus WRC+pooncerelease+fencermbonceonce+Once.litmus These two are members of an extension of the MP litmus-test diff --git a/tools/memory-model/litmus-tests/SRCU-fastpath-scan-before-anch= or.litmus b/tools/memory-model/litmus-tests/SRCU-fastpath-scan-before-ancho= r.litmus new file mode 100644 index 000000000000..931a41014de7 --- /dev/null +++ b/tools/memory-model/litmus-tests/SRCU-fastpath-scan-before-anchor.litm= us @@ -0,0 +1,53 @@ +C SRCU-fastpath-scan-before-anchor + +(* + * Result: Sometimes + * + * If the synchronize_srcu_atomic() fastpath instead places its lock + * scan before the grace-period anchor, the scan can miss a reader whose + * increment was already visible before the anchor. That reader already + * existed when the grace period started, so completing the grace period + * without waiting for it would violate the SRCU grace-period guarantee. + * + * This litmus test models the reversed ordering, with the lock scan + * placed before the grace-period anchor. "seq" models the grace-period + * anchor in ->srcu_gp_seq and "ctr" models the per-CPU + * ->srcu_ctrs[].srcu_locks counter. P0 scans the lock counter before + * writing the anchor, with an smp_mb() between them. P1 models the + * reader-side counter increment, with the smp_mb() of __srcu_read_lock() + * following the increment. P2 models an observer that sees the reader's + * increment before seeing the anchor. + * + * The same outcome is allowed with this ordering, and herd7 reports + * "Sometimes". See SRCU-fastpath-anchor-before-scan.litmus for the + * opposite ordering, which forbids this outcome. + *) + +{} + +P0(int *seq, int *ctr) +{ + int r2; + + r2 =3D READ_ONCE(*ctr); + smp_mb(); + WRITE_ONCE(*seq, 1); +} + +P1(int *ctr) +{ + WRITE_ONCE(*ctr, 1); + smp_mb(); +} + +P2(int *seq, int *ctr) +{ + int r3; + int r4; + + r3 =3D READ_ONCE(*ctr); + smp_mb(); + r4 =3D READ_ONCE(*seq); +} + +exists (0:r2 =3D 0 /\ 2:r3 =3D 1 /\ 2:r4 =3D 0) --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6657A4279E3 for ; Mon, 7 Sep 2026 07:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767937; cv=none; b=pGTSd8MTrQloEUQhm0tZvN5/J+ioP7GbzOydeHEn4yQJpvKddfRnwhOhi3YwZ6ZfmPd2fPYjn+KRq9hdGwXzRRVSkFa/GlVmCYAlWfBNckbj2RVPQCaHlCs5xbChdHawLo9IQ64nV0hU+uTdsMYsElJJJTIURxmttLPbpwAh4fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767937; c=relaxed/simple; bh=y+BKA/RD4U8D0pkVHR30bN2c+9yOk5iGeepHr0HLGn4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f8AMX7iJKg90U37LvPNi2vTrsLF8jXGFVxHSgWF9D8LT3YzPl/tu4HswfDYstf94WN0XOsiPSxf+tPAhM21BU4KSYY94hhr+QE5BhIoB8A9gt1lqFIgBik5DrOHekpA3q+SWz7HecGNSU/6hNpbvWW/a7w43V/dvA7g0CMOlckY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i/bOgsdq; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i/bOgsdq" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2d8f265cbe6so23814175ad.0 for ; Mon, 07 Sep 2026 00:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767935; x=1789372735; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KuHltOQMtvIyLbH/3yCpfQv67OgWo+va2cml6EO5eig=; b=i/bOgsdqUnJPDVyhp+B8Er/UUqw3aAaPqy/Mhp8NjZllVUcyQu0q9wJlqS2ecdz7/D xPEQ+m2aXsEDR3twb9ZPr7f7TZl5J6THBp9s77X4gFYApSAcwucVWFbgsesAUhLYzMy4 KWfTHXBZwAWfgI2vM2ADgv2Vua7JkJ3bC3zTkCGGr2+GIqHA3mM0aDWE+QJ4x297XZXF 2xt38x00Q3Ya1ihZz4inxVXFd1J56bfoAkVBLtzIax0X2eIT5dqxuTZp8e1/wUInAxli xHoxiTJFGWx/efVcSUZpTJ088K8juqn5rS+Rb66ickN5N5QroCu0hBRrajfMmi0Pmb7s RSzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767935; x=1789372735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=KuHltOQMtvIyLbH/3yCpfQv67OgWo+va2cml6EO5eig=; b=PHCn8ikzMBMbfOalitynId/h8FTs9K9yEwmAnqx4Hwr266NqkElo8GBXiivaDHyvt9 tQJL7Zqbg3kb/HWQROjbw7eOeACK8/ewnZjLrCj2yMiaXZoWOXnTwFy/Zqn933osADF8 z7+y7HtqW3OxgIAD5I97RZnYE5yPLN+afFg//PvtqD6/6GrT+iuBQF7aUB7KmQ0vETe+ jtWEy0bKuNmBYII0qQ4K9cW4aONAtPsEvJWgTci+aH5o+OxA1QBJXAfslclt5YboOlkv Zv0QD5+7Y9UlLNpGTZkjfxdnwoac6nWWWdTd/bCrdIO+cx7lStTXZwtuhcVyfZZcvBen 4uuw== X-Forwarded-Encrypted: i=1; AKwUvBy3Bmss27QjAInUDGI4hObsguGiWx/92W1KxVONTzTHoDq5jr6vzaetLIPo61Sl4DtwnH3YtuH3quSwHRg=@vger.kernel.org X-Gm-Message-State: AFuF++nzu5bBYH4pgLcxhofFR8qgOzIDCHS85OJHKxH1zuYJCYSUzWn8 Ap0UedSRoMoOJmhRYtU6Yml6h4VQqg2LY/LjNe2On4CGvPF2z3VTpXs6 X-Gm-Gg: AYBFou108xRguE4nxr7HwFL9czp8DK250ZET067EPRysl7rffu073awgpiriD0LDzhv 3/ZWwnWnsWkASlPy6AE/lUNuIUnsXcHjLAOE5XOf3obRW608UaYq5NN8z+QqDCCs8E5DW/rZDId DGQFhu/lLf0rxcKhpwfM7uqfhQ3bN7HRA337KKMdu3tI3M7zsvJ6DQjXmc/NGB3QHt/ycfmhXhC wMck8gS/gIrclQ5bXEDuMlS7uzB7SqF3ODm5b6J0gXOEgSSCDHcb8ovOkuyt2/8RapcmgM2OAQm uSrVCs3eAmUHXAhDAE+I/9JDtSMhVacKuZQMIc95bI23ZHtO1JLUPXaRh1mHOWP+Of2AIDTDcyS uCQNhw2w7z3Yk4L9ginaD3KQhCAUXcAEZ4mY9R42GguHJAzgwmGGBvReKHL1tD3nzJIBbKPhgJ6 lTdW7IpK+e7rbzSX8o1d0fynDSIJrQrc20vTPJOsfKT5PBBoOBhonZ3FImllK3oG55K6dW5MXyr 0jRgqg= X-Received: by 2002:a17:902:b114:b0:2d9:1dee:43e3 with SMTP id d9443c01a7336-2db12757f17mr202313705ad.18.1788767934067; Mon, 07 Sep 2026 00:58:54 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:58:53 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 03/13] srcutree: Add reader-free fastpath to synchronize_srcu_atomic() Date: Mon, 7 Sep 2026 15:58:19 +0800 Message-ID: <20260907075829.2073224-4-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan synchronize_srcu_atomic() is restricted to srcu_read_lock_atomic() and srcu_read_unlock_atomic(), whose read-side critical sections disable preemption. In the common case where there are no readers at all, the grace period therefore need not do the index flip. Add a fastpath that sums both ranks of the per-CPU ->srcu_ctrs[] counters and, if the lock counts match the unlock counts on both ranks, ends the grace period immediately, skipping the srcu_advance_state() scans, mirroring the similar Tiny SRCU fastpath. Correctness requires the counter-sum proof to follow the grace-period anchor written by srcu_gp_start(); placing it before the anchor could let this grace period miss a pre-existing reader and return without waiting for it. The smp_mb() between the unlock and lock sums pairs with the smp_mb() in __srcu_read_lock(). The grace period is ended manually under ->lock and ->srcu_atomic_gp_flag. Signed-off-by: Kunwu Chan --- kernel/rcu/srcutree.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 7dd705eec573..533607de5728 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -2113,6 +2113,8 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp) { unsigned long srcu_state; struct srcu_usage *sup =3D ssp->srcu_sup; + unsigned long rdm0, rdm1; + unsigned long unlocks0, unlocks1; =20 // Initialize. Either init_srcu_struct() was invoked or // DEFINE_SRCU() or similar was used. Therefore, no allocation @@ -2149,6 +2151,52 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp) srcu_gp_start(ssp); raw_spin_unlock_irq_rcu_node(sup); =20 + // + // Fastpath: If there are no readers at all, neither grace-period + // scan need wait, so both can be satisfied at once without doing + // the index flip. The counter-sum proof is the same as that of + // srcu_readers_active_idx_check(), but spanning both indices. + // Atomic SRCU guarantees that all readers are of + // SRCU_READ_FLAVOR_ATOMIC, so the SLOWGP check never triggers and + // the ->srcu_reader_flavor masks returned by + // srcu_readers_unlock_idx() are unused. + // + // This proof must follow the grace-period anchor written by the + // srcu_gp_start() above, never precede it. With the anchor first, + // a reader whose lock increment is missed by the sums below cannot + // have incremented its lock counter before the anchor, and therefore + // cannot be a pre-existing reader of this grace period. Placing the + // proof before the anchor would let this grace period miss a + // pre-existing reader and return without waiting for it. + // + // The smp_mb() pairs with the smp_mb() in __srcu_read_lock() + // (store-buffering pattern), which guarantees that a lock is always + // counted if the corresponding unlock is counted, the same + // memory-ordering guarantee as is provided by + // srcu_readers_active_idx_check(). + // + unlocks0 =3D srcu_readers_unlock_idx(ssp, 0, &rdm0); + unlocks1 =3D srcu_readers_unlock_idx(ssp, 1, &rdm1); + smp_mb(); /* A */ + if (srcu_readers_lock_idx(ssp, 0, false, unlocks0) && + srcu_readers_lock_idx(ssp, 1, false, unlocks1)) { + // No readers, so end this grace period manually, skipping + // the index flip. Advancing the sequence number via + // rcu_seq_start() in srcu_gp_start() above and rcu_seq_end() + // below keeps get_state_synchronize_srcu() and + // poll_state_synchronize_srcu() working, all under ->lock + // and ->srcu_atomic_gp_flag, which excludes concurrent + // sequence-number updates. + raw_spin_lock_irq_rcu_node(sup); + rcu_seq_end(&sup->srcu_gp_seq); + raw_spin_unlock_irq_rcu_node(sup); + WARN_ON_ONCE(!poll_state_synchronize_srcu(ssp, srcu_state)); + atomic_set_release(&sup->srcu_atomic_gp_flag, 0); + preempt_enable(); + non_block_end(); + return; + } + // Wait for it to complete, helping it along. while (!poll_state_synchronize_srcu(ssp, srcu_state)) { cpu_relax(); --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D95D2230264 for ; Mon, 7 Sep 2026 07:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767944; cv=none; b=g1glxr1IEJ9Kf96TeVj2aox3DlA/tgSSPzQjV0EeTv5kmKYbWSlYyqURjM6gFA7P7kE9iBY9hbuoK4qIhq/0BJp0RyWM8zj4MYBIhHHyvpdouoXcyEizcXhDZm62UP051AQq/+SUUY6b9TRHs92xjqahZMaKzrG1vEBDu5i/09c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767944; c=relaxed/simple; bh=YCbEy7LvZ4zvg5lCpybvZOkKAZyBBdYj0Er77Bwz/GU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bIbcqogUL7OI34Nl512PWBl4ieGs9E+U4dKCEGdm1BnkeNAUC9+BageNzmH8hrAyx1B+/ymfNYyuqsq2BnBWwMZinJj3sBxJkTG5Sc96TanHgz74uL7tECpp5UtYfmvWBW6KQJPS9vpgbaXeAKzgNWddTs47DSiBGQpTwJ32vDU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YMfJaW3x; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YMfJaW3x" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2d94c868ea5so32931715ad.3 for ; Mon, 07 Sep 2026 00:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767938; x=1789372738; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KWQbirqnoJrko/xoiAbUUJU+D4b2sHL+OPlLYee7Yc4=; b=YMfJaW3xPWojgT0rx1bnlGosexhl8K0YxO0WFAi+mOEfpFNqcE2XD0SD7bH/uJVUtj StEuviRmP9ZGCgzO/0qtOtY/k6yqgS60GFyShfHRi1y6fn9sYchxWSpVddkXbqqC/rLQ ta0fM03WCSya4glJTHaSQhfH+VUgRQ+n/1bgLwe4gUkatk1tQ+xpy5o5Ij5yGEbw4E1F yxLMnice7htvdOwbiNEcdrOyj+Ij+kRwX+U5bkUmvu+nRE+xF4JZ6vWtyQXMUr40HexE RJxNIV2XTn5PWTGCVJM+3slxy9TGFLe3PZytYBrpSzFsuD4rFpHpwlmWnClgs3a0ODms +UEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767938; x=1789372738; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=KWQbirqnoJrko/xoiAbUUJU+D4b2sHL+OPlLYee7Yc4=; b=gxuBkrszWlGT/AcqzcYax7Pql6G7yhCSPz9tUX2bVdPAIvVpfsd3CMHummpjPNMDO0 +JtpC8Z6LSqVSBtBW7V16xm7Whyh1zvMWVU95vRHjWM0sVt64gnaD8xPixCEriyZ3n2A W231NCOBzzH66tW2sD2M/MFB+56+ntmGR1Q8u64hR7L1lrXifS4u5Gu01DJdIvTorL+6 eM8TRAQ/P1d1gqAgtig8tEOjbAglCsO+jjmL+OXRooUWPKGav3gCIgoEoFwL99KKYtQy WgRDX9E24/zNlIALMYchdwyBN/Kj346vk7vnmMBGd9uoBdXL668FvbvKmFLtHc82s6qL bU5Q== X-Forwarded-Encrypted: i=1; AKwUvBxYOK+xH5HeauWu2N5bp4zBT1QtJgtjdAvcFOlS6YUb4EG2xUF0NvOh5Q0zyoU4lIWGGNFcAGHbLZMBwUA=@vger.kernel.org X-Gm-Message-State: AFuF++nD1qaOvnhG3VdBiE5upV983Dq92nXTME8qUg4sMD3NJ4ju/36O JMWUd++TBMtPmHVul1KxB4Jgr/JE+3qclvafrAhClMzPOW2PX+n9NdWD X-Gm-Gg: AYBFou3Y8jBItZfhsqllbtgHU9pIXl46Jc0aQMuKD+TV2UW/Rg6fvycsvk15Z5Y6ZX3 pfY13DlpB5tePrtCpvazml9+N7aGPn6aYKQwVNY5/HgcYbyyfvdAMfmreKgbihs+sUMtjRy9DcZ P7vUOzAs495G4oRYaor+BBqWdZx+qVo2GBdSNPCy7a/XfIlJgxOgfJLXRdqYxfCq5dluYB5vZhv gKazRetJUc+i4SFd/6Xl6+00etMx0hPsmcIcWeLUf625GUjN0LrQVDBUXAxICW9vZwbWRS4prlQ yQIeCaAA4dCcqsE3nzUupnrOGWBeTgrjTBtV9miWOESmLCIDH1WLr8HuuYTZwvcaCNdU2bP463K LwH5UMXirZ6GT5YzvbGc5HXb4gr+t39EzGA+R1Zvi47KsnLh415L4pWVBGVZkAmsVbxQ9hn80uA N5rtYxVLe60c2jikY30nRlEcFE5FouxLyVuYIUTf9bXT1NixXxmBjM4iKU2ULlxaffr6Wf5losY gCMH4o= X-Received: by 2002:a17:903:13c8:b0:2db:56da:6a0e with SMTP id d9443c01a7336-2db56da6ea1mr65563755ad.9.1788767937845; Mon, 07 Sep 2026 00:58:57 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:58:57 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 04/13] rcutorture: Add atomic-SRCU support to torture.sh Date: Mon, 7 Sep 2026 15:58:20 +0800 Message-ID: <20260907075829.2073224-5-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan Add the --do-atomic-srcu argument to torture.sh, which runs the SRCU-N, SRCU-P, and SRCU-T scenarios, thus covering both Tree SRCU (SRCU-N and SRCU-P) and Tiny SRCU (SRCU-T), with rcutorture.reader_flavor=3D0x10 appended to the boot parameters so that it takes precedence over each scenario's own reader-flavor setting. This exercises srcu_read_lock_atomic(), srcu_read_unlock_atomic(), and synchronize_srcu_atomic(). As with other torture.sh tests, the --do-kcsan argument runs a KCSAN+PROVE_LOCKING variant of this test. Signed-off-by: Kunwu Chan --- .../selftests/rcutorture/bin/torture.sh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/test= ing/selftests/rcutorture/bin/torture.sh index f0083891ee81..8885812d866a 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -68,6 +68,7 @@ do_clocksourcewd=3D"${ifnotaarch64}" do_rt=3Dyes do_rcutasksflavors=3D"${ifnotaarch64}" # FIXME: Back to "yes" when SMP=3Dn= auto-avoided do_srcu_lockdep=3Dyes +do_atomic_srcu=3Dno do_rcu_rust=3Dno =20 # doyesno - Helper function for yes/no arguments @@ -103,6 +104,7 @@ usage () { echo " --do-rcu-rust / --do-no-rcu-rust / --no-rcu-rust" echo " --do-scftorture / --do-no-scftorture / --no-scftorture" echo " --do-srcu-lockdep / --do-no-srcu-lockdep / --no-srcu-lockdep" + echo " --do-atomic-srcu / --do-no-atomic-srcu / --no-atomic-srcu" echo " --duration [ | h | d ]" echo " --guest-cpu-limit N" echo " --kcsan-kmake-arg kernel-make-arguments" @@ -148,6 +150,7 @@ do do_kcsan=3Dyes do_clocksourcewd=3D"${ifnotaarch64}" do_srcu_lockdep=3Dyes + do_atomic_srcu=3Dyes ;; --do-allmodconfig|--do-no-allmodconfig|--no-allmodconfig) do_allmodconfig=3D`doyesno "$1" --do-allmodconfig` @@ -183,6 +186,7 @@ do do_kcsan=3Dno do_clocksourcewd=3Dno do_srcu_lockdep=3Dno + do_atomic_srcu=3Dno ;; --do-normal|--do-norm|--do-no-normal|--do-no-norm|--no-normal|--no-norm) do_normal=3D`doyesno "$1" --do-normal` @@ -212,6 +216,9 @@ do --do-srcu-lockdep|--do-no-srcu-lockdep|--no-srcu-lockdep) do_srcu_lockdep=3D`doyesno "$1" --do-srcu-lockdep` ;; + --do-atomic-srcu|--do-no-atomic-srcu|--no-atomic-srcu) + do_atomic_srcu=3D`doyesno "$1" --do-atomic-srcu` + ;; --duration) checkarg --duration "(minutes)" $# "$2" '^[0-9][0-9]*\(m\|h\|d\|\)$' '^e= rror' mult=3D1 @@ -497,6 +504,23 @@ then torture_set "rcutorture" tools/testing/selftests/rcutorture/bin/kvm.sh --= allcpus --duration "$duration_rcutorture" --configs "$configs_rcutorture" -= -trust-make fi =20 +# Test atomic SRCU across Tree SRCU (SRCU-N and SRCU-P) and Tiny SRCU +# (SRCU-T). The reader flavor selects srcu_read_lock_atomic() and +# synchronize_srcu_atomic(). Tiny SRCU requires SMP=3Dn, which aarch64 +# does not support. +if test "$do_atomic_srcu" =3D "yes" +then + torture_bootargs=3D"rcutorture.reader_flavor=3D0x10" + configs_atomic_srcu=3D"SRCU-N SRCU-P" + if test "$ifnotaarch64" =3D yes + then + configs_atomic_srcu=3D"$configs_atomic_srcu SRCU-T" + fi + torture_set "atomic-srcu" tools/testing/selftests/rcutorture/bin/kvm.sh \ + --allcpus --duration "$duration_rcutorture" \ + --configs "$configs_atomic_srcu" --trust-make +fi + if test "$do_locktorture" =3D "yes" then torture_bootargs=3D"torture.disable_onoff_at_boot" --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 211AF432304 for ; Mon, 7 Sep 2026 07:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767946; cv=none; b=L4fWDkydzRThtzvXEXmDoknNEugGacMRXhSUL8sB6JT1ZS2cfqlU+iVDsdrYANsOW1Au/YzZerXw4iuX6A9zwbqqbPxbgaFKbqVIUY6wvsCtibUuIjTLtcpUzfV2IObQFSK41N14TS6BoKIyX+dWYmk/swwu7kEWfbQlAaDx9cY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767946; c=relaxed/simple; bh=SyylDsQDIUbzKF+su1zxsOWvOHQVcOWya3vOlSyDT6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VBlgz+ovE8OVFQQZ2Ki6YXeZ/BhmLEYwrz/tOz4xZAeQQZdYMdZqP+fNCosZNQ4JLh8Ir/tP17Yf53E7PQPpA5vfvfRzSI4oDkdpc62BIp6NlURAqaqnsO9+DU6uPPajUPBR2BARMWxfYWf6T0ayqetlSda8E0Ml9YMtXtgXx34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JZJgmXW8; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JZJgmXW8" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2ce98cb8165so32169475ad.1 for ; Mon, 07 Sep 2026 00:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767942; x=1789372742; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ki/BSl1uDM28DM7EGgocp0IxhtJCInGP+RpfNAELt2Q=; b=JZJgmXW8JSdqX8cgoYgSajOQhnrPMA00kOAX+i2UddWavTzUs308C8h2e758STI2ED X5PYAarof4bLfG8ze4CzPkIO8CQVwHdSrj71WefuyObOT1JPOyWHRUKpJzWjlrGBqNfe /XaG8vsa6aul3RzMukUrSInd0g3zVW0wUxkBYTkT35sIqg2xi/gQBaP/WLZOgGaBRlVt iOEgGiPFF572PPgfx/x20gDnlj/YAp5MHK82z3MYcAg3f5u7GLc2hfsFf2VPj06IuFJn gLf34A05NVnHnHS2xiLhm2tpx4UKVOXsnqE+MW2LFvzOBqS3wq6b1awZMHp+VGnf4g6n gIgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767942; x=1789372742; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ki/BSl1uDM28DM7EGgocp0IxhtJCInGP+RpfNAELt2Q=; b=VNeMCvcwf+N8vkC7wHhywY4k6MGwawd2PezkD7dx0Y9QqEuHJMhxiDpcqTYojlq0Z5 AKDB/ZRQHwSPu+hkl09sRU6A9uoaeSVSDVOdAbJ+WRyiZVmY/ohjyllZFn3OeR4IK14k 2fWV0b4u8bWb0RGmtQZhUM9rl05VKkNwN1dIs6SWqdd2kvhNXbw0J1S3qoyxGt9fOvhB Lc12Iy/2kLIRZhTI2N6DUBjv4Tjx7DqZK+EGesx8My8TriJ7NadQFV1hxUYhgVq5VNaD 4hMnYYB2Qk+s0zZFqOw1JqDgZlxgLnUJ229HulWHKmPacWXHehK74dFlKZZ+Z+SHi3IT PGCw== X-Forwarded-Encrypted: i=1; AKwUvBz4aYvRA5WoHI4b2Yn5FWwau4dXJVDhK+D7DnvvGjqVS4splFa8TbCdDPdWBdg6iD4lKGpJ9VkSIVQc2FQ=@vger.kernel.org X-Gm-Message-State: AFuF++lYx0aC6UwRHFeQ34+uI7cpEqI5lUxGkxobqA4NYfqZFKRYF00s VtPqYo1rFaDVKzwPaSVnNTsnwhwBsWoaD+oUSjhkEwiTgUdc3sxtOspp X-Gm-Gg: AYBFou2GHMYx6WtHy/AzEkMNyD5VdctPOMBpJnwSKGtKIPBikLJAJD5mMjrGdcTc8mD RDv59PrJkrKhzpUCrmntf1+jAxMZl1fxVO2cw0Mj+qBc+t//nwYVDXkrrCJeA2yQnDp2cE9CZ77 2n/NGKwBR9Z7Q3/iAJcHzNLsfRvaBDgg9McYwT2eKY3ZQBgFEsOx9myiuzaoaqvkKz7oiw63zOz peOF+cJc8eDFmdVMSByemYmVJ3Ndq3V1ENEWsXXLoc26Ukq96UyxmBqFkakdhG2eYemo07oAQ39 SL+NoLVaolrGiV5+gULLjF+C7y2XkJYhUr1dPjgkciJAb6hlB8kMU2SKMuEwkrWmwbLrVTgReqT FcJlhfOVmIPA725ckLlxb280Wy1KVbZRefuwiaFDeoAbGogXNfZVTO0fPIEblRMhpNjEuK1w1Ms C/K5sfySIdkg1s/Ta5rTSs0BjupbJWWudCRND+liK0d8509RosJybI6uIQtulgZobkz7zD4fU3o kcWF3Y= X-Received: by 2002:a17:903:19e4:b0:2d7:1cbd:9ceb with SMTP id d9443c01a7336-2dafb0af1f3mr246588805ad.12.1788767941401; Mon, 07 Sep 2026 00:59:01 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:59:01 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 05/13] srcutree: Honor is_atomic in check_init_srcu_struct() Date: Mon, 7 Sep 2026 15:58:21 +0800 Message-ID: <20260907075829.2073224-6-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan check_init_srcu_struct() drops its is_atomic argument, passing hard-coded false to init_srcu_struct_fields(). Pass is_atomic through instead. Signed-off-by: Kunwu Chan --- kernel/rcu/srcutree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 533607de5728..2af36db37fa9 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -522,7 +522,7 @@ static void check_init_srcu_struct(struct srcu_struct *= ssp, bool is_atomic) raw_spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); return; } - init_srcu_struct_fields(ssp, true, false); + init_srcu_struct_fields(ssp, true, is_atomic); raw_spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); } =20 --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7AAA425899 for ; Mon, 7 Sep 2026 07:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767948; cv=none; b=pHaSx+Yh5UqBHEVYC63UP81UIfgeuOhCkHKR//lLWZFaQn7kpVYbstXaKDOIYsus2bULh1Q+fK2T5ylFPcDbo8NH8KJff40AFDaxhoHUrhRANbk4o6XmlngDjiXCnhI2pyhnDeePd05MrRJrFCyMy7twhEeOj0PHP+SNIuxPG5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767948; c=relaxed/simple; bh=khDfC6/LWD0Q4/Opwx8ffd/lQkWbDpCYUNN+ihTrgFU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X25CaU6VwIVsRM8pN6habfexpJJ0CumbHh47ujnZBh22DpYl4gCrMdlV9Ecz9FmhcsnVSYDXdQWh+aTP9ek1wLNArbC4I24cEpT9j66EUEAyYEZgQU1Bzn24CiF0YM4LZRmsnrb66KgaDLiUpEJSfWk8Z9K8QW/bxbhSnjxwHVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jSpatKAM; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jSpatKAM" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2d9201076b3so36887005ad.0 for ; Mon, 07 Sep 2026 00:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767945; x=1789372745; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9xsmNs6fEcfIC053Za2znwufqL6cSMJhGirj52zu9CU=; b=jSpatKAMZMsJOBsLXeuroRKLvBwPbNOnw8jrl7vBChQGx8BtBmaaq8rgWR6L4bBqt0 gQFfFFikBZP7SJcLingRaJczSE7NHpLkXvdwgq/omONk78cI5ANL5rTxJeqxD7NuAx/h glcOTVrTT/71ksL4c3+eYPhHHjda3Fz8q2IDHg52oX3CHwbekFepL6x65UDqsKcqPq9e veUr/+0+1MnUkUaIAFP3yNiIZ+59ac16me0V4Oo0ppHcU4V2/paeGWtVvhgAJCDuYprM DafQvYEQ+wV1qqISA+gjDSNAjuGP9f0zr1NBLerp1pA462/lNZznZFghzRVdRC6lHprd xgRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767945; x=1789372745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=9xsmNs6fEcfIC053Za2znwufqL6cSMJhGirj52zu9CU=; b=LDhzccB36DSnfU+SahOpDlkPgHfsIsFsR5rufER0NTmb0NdNmALTwsAsM+NDXOgOvo Q0DVBhJ8CWl4Lfq0ATiXTZUhDPtlrH62uiqmjs2pznTbV0JXn9XS/xrSbiV3WQQSjAFQ 0FC8kfBEclLSjZXT6S8MEWt/3kIQCbAruxaashxhBHoYPxkgywjusP6A4B8d13OS0jsg Z//RxncD8mM4jWYI9ZPTP9LB018mnOb629RshEjCwdGoixVOML/FToAlSX94ttACIAx1 tsFR8tmAqr1EvedUpNlDf3JRjus5g004UJe0lTTS8bXXjAzfHpqKzV29oGcDXBmDM/vI Dv6A== X-Forwarded-Encrypted: i=1; AKwUvBwcJaq7qUdHvvkrXwHOHWCpHmdQx6qAJ0S+/9VtgEX+5BZPMQQPEade2yDGdxKdmL1jHE7ZFg8Uh2pXrlU=@vger.kernel.org X-Gm-Message-State: AFuF++lb8nnsE4wNrKWTjry7WzQPa46cmrJfsAtfXLpSg44vwoFNFAqT Xxo/xB2NAGYjvXtNvIAPODO5/v4DyC1bsjSMpCEm5Uc11aU3bws0Ze0P X-Gm-Gg: AYBFou0G8fpSSqXNcTLO51DzSJb/pzS0PVaGvSmZ/BK63xqRIa4PsvrcIcxxnTFx7eb U4Y6oldo55SAoLhGSu7NinDxqKTfLFeAmFehsWb8EQJJgWBN8zIHqu3GRmSDv7HLoFzFgjwS7IL BJCWn/9N9pnjJoIWPKW45pEQIXwETC14MRSE7BZbwfUC2dxQk/zeX9HjtumoVM6HhaIQ3+7MI2r WR1n1nRiuf9CeX4hfTREsYOiL4HsVMn0nTRV2HoqbA+H9btho5R/bDYXC08zbk6hyOLARCCNSfn 3wmAduBw+geim7mGJwGGTUuo2n0KSS+UzdmdOlCTw16ECWKzF6esv7DesTc4A69fFc3CpvBLCSX oZnCZH+fYTvGLbdo9elTEXB3dxLGJRQULRFI0e8YAgzPzTj0jDQoZCXD1evjpDzScRelyeeBGjK 8NzlWynncIlxZpkzutwpwqpo+K+r+D/uwvgX6AegnUf8DaHF3tA1S+7j05AXrGWhagjXiJvlatf VpBkHo= X-Received: by 2002:a17:903:1850:b0:2d6:e9f3:9305 with SMTP id d9443c01a7336-2db1232c660mr337912645ad.5.1788767944906; Mon, 07 Sep 2026 00:59:04 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:59:04 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 06/13] srcutree: Make init_srcu_struct_atomic() prevent transition to big Date: Mon, 7 Sep 2026 15:58:22 +0800 Message-ID: <20260907075829.2073224-7-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan The is_atomic parameter of init_srcu_struct_fields() exists so that atomic SRCU never transitions to big, but neither init_srcu_struct_atomic() nor its lockdep counterpart __init_srcu_struct_atomic() sets it. On systems where srcutree.convert_to_big selects SRCU_SIZING_INIT, this needlessly allocates a full srcu_node combining tree for any dynamically initialized atomic srcu_struct, despite atomic SRCU having neither callbacks nor srcu_barrier() operations. Pass true from both atomic entry points, adding an is_atomic parameter to __init_srcu_struct_common(). Signed-off-by: Kunwu Chan --- kernel/rcu/srcutree.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 2af36db37fa9..01f224a56b41 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -305,26 +305,27 @@ static int init_srcu_struct_fields(struct srcu_struct= *ssp, bool is_static, bool #ifdef CONFIG_DEBUG_LOCK_ALLOC =20 static int -__init_srcu_struct_common(struct srcu_struct *ssp, const char *name, struc= t lock_class_key *key) +__init_srcu_struct_common(struct srcu_struct *ssp, const char *name, + struct lock_class_key *key, bool is_atomic) { /* Don't re-initialize a lock while it is held. */ debug_check_no_locks_freed((void *)ssp, sizeof(*ssp)); lockdep_init_map(&ssp->dep_map, name, key, 0); - return init_srcu_struct_fields(ssp, false, false); + return init_srcu_struct_fields(ssp, false, is_atomic); } =20 int init_srcu_struct_lockdep(struct srcu_struct *ssp, const char *name, struct lock_class_key *key) { ssp->srcu_reader_flavor =3D 0; - return __init_srcu_struct_common(ssp, name, key); + return __init_srcu_struct_common(ssp, name, key, false); } EXPORT_SYMBOL_GPL(init_srcu_struct_lockdep); =20 int __init_srcu_struct_fast(struct srcu_struct *ssp, const char *name, str= uct lock_class_key *key) { ssp->srcu_reader_flavor =3D SRCU_READ_FLAVOR_FAST; - return __init_srcu_struct_common(ssp, name, key); + return __init_srcu_struct_common(ssp, name, key, false); } EXPORT_SYMBOL_GPL(__init_srcu_struct_fast); =20 @@ -332,14 +333,14 @@ int __init_srcu_struct_fast_updown(struct srcu_struct= *ssp, const char *name, struct lock_class_key *key) { ssp->srcu_reader_flavor =3D SRCU_READ_FLAVOR_FAST_UPDOWN; - return __init_srcu_struct_common(ssp, name, key); + return __init_srcu_struct_common(ssp, name, key, false); } EXPORT_SYMBOL_GPL(__init_srcu_struct_fast_updown); =20 int __init_srcu_struct_atomic(struct srcu_struct *ssp, const char *name, s= truct lock_class_key *key) { ssp->srcu_reader_flavor =3D SRCU_READ_FLAVOR_ATOMIC; - return __init_srcu_struct_common(ssp, name, key); + return __init_srcu_struct_common(ssp, name, key, true); } EXPORT_SYMBOL_GPL(__init_srcu_struct_atomic); =20 @@ -414,7 +415,7 @@ EXPORT_SYMBOL_GPL(init_srcu_struct_fast_updown); int init_srcu_struct_atomic(struct srcu_struct *ssp) { ssp->srcu_reader_flavor =3D SRCU_READ_FLAVOR_ATOMIC; - return init_srcu_struct_fields(ssp, false, false); + return init_srcu_struct_fields(ssp, false, true); } EXPORT_SYMBOL_GPL(init_srcu_struct_atomic); =20 --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1538542E01B for ; Mon, 7 Sep 2026 07:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767952; cv=none; b=jc8+I/yKAUfv6T5JxootWr3cGl5BLieEPhJyAwTRG3933RonZYJYBgn5y/NjvtIl3QBZh/J5kX8zJ8FS8MBE1Gm0NMlsuoAofHG4TkRUwBbAe7FCphoTzp+jX3DY2VQlAhpVurKsokokYv+fanrbwW2MXyJ5EkOvXaaDdyWJq34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767952; c=relaxed/simple; bh=3OlCz+laqH6rl0bpjSr713iDWvV7K05sGtsflbnXZRY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e9QoqhZ4bcSIcS/UjHbA6WL0YEN/yfFqbHPWdImO4Jp2HrjkByFn8JIBqPd3/zFh2mdxToWge3m5wgd7Hg6GhOU+YU3CLdhwOYHCO4El8suZ40VrXGXcpJ06MQccv9omaLxwWj+4L/p9pLZS3WxATrZLrYenZ7Kzl0Wh4yDQH2M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=r9p54H6B; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="r9p54H6B" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2ceab75934dso31010275ad.2 for ; Mon, 07 Sep 2026 00:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767949; x=1789372749; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+pwFM3pOh2VpEH5TcABiF5v+6kZ668JjyW4E61muF/Q=; b=r9p54H6BzCL6eiU5WZn0eK3f5oVJls2dtSt+S1p3oiTcKQGriZ8ILD8Be4Aa4kBdNC KDc/YZyA4rpE3DYx27Ou9WXFXrE1HjtyIdMwayrTsjcarz7/1LXtXDDjSIaVDXo2v5oa KrZ+xaxXoPmL1ub9T4B1P0+alM2CtKtTNzA/cAW9z0A06Kouh/0fHG4nojaoUoBuX/iC NFDulwtWS0kNR+jDfg/FDwYBdEFvN/D5w8VSD6iF8Nq1uu7hgnjw0QRd8dGNUATGSoEc tb+nwUZeP8LuQGtzEgfrR7KN0/5exKmYidVRLBy+gN7LfaBl0WW7alYcBJudgrmmOXPq OLxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767949; x=1789372749; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=+pwFM3pOh2VpEH5TcABiF5v+6kZ668JjyW4E61muF/Q=; b=EZI2FSoRd6p1k7Kly2J8OpjLfeC2pD5ts7AMjx2X0QA3Nh41c6WDA0nb+wZt3c8pfm 2QNUT1t3CaedT40xYd7DwckwseNg8WE/x6fp9t9RqdS5+bH+vt4SdeoZwtbGPukLsITq a9zSA4kTCrtvBkvd6a+loGchjTWBi+0JYeZWgZxCSc1i6s3H6oY36xHvpOo1AkAJTcut sMIT5aOfUzeNN6dhT8POOABiruxdys4VtkPBp/w/tiT5o+3nQftsnDDm5QfrsWLkU/My U/Xjdvj+OBjWlInRN4SjzBMK/dTfazfodQMXXifMRpGH3Ri/oYw2vGYFo/3QfH6ZV1wN EeBA== X-Forwarded-Encrypted: i=1; AKwUvBwRUuKrjQVNADwPetfO6TTd9aGTbdY+nu7ud2/5MJ5pgA8wPbEwX57CuWoD86IRx14+QLdgBoRkz1YB98Y=@vger.kernel.org X-Gm-Message-State: AFuF++lwm4hzSD0VICLJNjxIbJbvM/V/zm4nIzTQzgGbsBx0v5KA0wCx 8lutBhXFbUKIbr3OB7ZQ4vJls/J5qw4XuhxR4AnOZc/CrhYCR9w2GXIU X-Gm-Gg: AYBFou2xE+tIFi/WUpyj3SWXcu1t6+iRNrFMKRhnBE9JrYMUVnP+KpXtiHTIvRoMYvC hKzQHo52+w/UjiD4wWrpiqmCjqxgaSLw6w16doJbLYsF8kIeFpQqI2/fxyOiKnT1bCySTXWPmch Hc9RMHAsucvoywtrpn0CrJk3iHBthHBsHGux6KzcmD6h4vD03azCA86Q7ZDR8SZ2Fvf+m7gDoWS 9dCEHplq15LGKBGAmG0Ehy9iWgsYyzdC17yBfojSdXtcOpmqg5+Ocyeeq0n3BLXlIM9VSC4Xs61 /zdJgfT0OS0BsTjRtLn8q3N+MpRLbZhrPdmxGn0b2UK8aRGRRbn6pi9SCuzOQy6DxCqxwgQvxBn I7Fo6XILvb0/TlsANRo+vJVo7wsTUww7b3K2icywcQ49MvrWElOdX+mz+sAyGDXb/Ej7No8YHeX I5cTybb63F01ld9AsjpmxyRcyxlvEuGICtfuzoUQf87irogPmScNoTWogdP1nSdBVyjLx3Amj1y UnCTt8= X-Received: by 2002:a17:902:d492:b0:2d9:68b7:c324 with SMTP id d9443c01a7336-2db125cce1bmr292519975ad.3.1788767948538; Mon, 07 Sep 2026 00:59:08 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:59:08 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 07/13] srcutree: Don't transition atomic SRCU to big in srcu_gp_end() Date: Mon, 7 Sep 2026 15:58:23 +0800 Message-ID: <20260907075829.2073224-8-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan The transition-to-big code path in srcu_gp_end() calls init_srcu_struct_nodes() with GFP_KERNEL, which is illegal in the atomic context reachable from synchronize_srcu_atomic(). Atomic SRCU has no use for the srcu_node combining tree: it has neither callbacks nor srcu_barrier() operations, and its grace periods are serialized by ->srcu_atomic_gp_flag instead. Skip this transition entirely for atomic SRCU, which is also defense in depth against any path that might wrongly set ->srcu_size_state for an atomic srcu_struct. Signed-off-by: Kunwu Chan --- kernel/rcu/srcutree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 01f224a56b41..74acd5645d4c 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -1074,8 +1074,9 @@ static void srcu_gp_end(struct srcu_struct *ssp, bool= is_atomic) raw_spin_unlock_irq_rcu_node(sup); } =20 - /* Transition to big if needed. */ - if (ss_state !=3D SRCU_SIZE_SMALL && ss_state !=3D SRCU_SIZE_BIG) { + /* Transition to big if needed, but never for atomic SRCU. */ + if (!is_atomic && ss_state !=3D SRCU_SIZE_SMALL && + ss_state !=3D SRCU_SIZE_BIG) { if (ss_state =3D=3D SRCU_SIZE_ALLOC) init_srcu_struct_nodes(ssp, GFP_KERNEL); else --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD7BE43C05F for ; Mon, 7 Sep 2026 07:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767955; cv=none; b=Wm9/LDZNdxE0sMng4oCNvPWZCDlHarkXmq2BIgEdG4IUJ9vMG51Vm/t2nPPRew5gjDjzcPU1IPauG9dDrX67mVZEIliLGLsbejxO9jisCmbsgs2ekVwnLAqNoeVr9ZeCHgRwM6Bvh77jqPwg0JZRIVJm3o442YEJOzvre1F7V0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767955; c=relaxed/simple; bh=VleNXxNv6kUzTW9segszUOA38jVkurmOblKAIMobB+w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZTeG43m0OkkBhCpUQJHLyEahIFFKpYRDAiXRQ0ShdiMTLDre5uRurOTSKyeTt4z/OWqsf8gh/+q/amoqB+fS53v8TB8b5UsqwM4eRyWaApNeEygrVwig+2oPRNNqyDSRdG9LIeC4Aii10EBKbyF92N6EcnFyO55nuar+DgWlFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mqXQX0Dq; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mqXQX0Dq" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2db59f54ccfso3478715ad.2 for ; Mon, 07 Sep 2026 00:59:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767953; x=1789372753; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EgnAw92EwmUeU2oW2/uLp9LZpH/LZFtVVfxD7vPweRw=; b=mqXQX0DqFx+vtaKN5HlCXUMjvHypnRiR8I+pHzisKR6VtiCIliElLnmu1vDlvKj2XZ px3DrxGto7XdfWqFJbE/60Zb6SI+C2rrLOgRFIQZ8Rs7e/NNU0PBL61TUntlNVCW1m9b ATlCtzKIzGAAraz5PVQoFu4pj95H3rp2jp7Vk9aYw3U3hZLgW1u0jOWAuaEVvAHj9uEZ yDhuSHi6wgA98TK+kGvYCuQ/EHSB5dif8ok1SxJ6R5W5Xb/EgDx1v4yi2nr8usUWLUMH K07RzPwodS8Wq++T049Y1aAmhvfkfYMyyDwI7OVyMZTgQshialaPQXR4DIeA4VFWOl9y R64g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767953; x=1789372753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=EgnAw92EwmUeU2oW2/uLp9LZpH/LZFtVVfxD7vPweRw=; b=L1tRoyCMNGS2tvudLNy0F4GAhwonZDpFxMFVL4PJNCK1UvMnbNw3RGJBSKRgvyhl+G +LhEnb4FGJHyr3V4rm3XOSf+uhsycUecqKY0WQ2eRIYhV3mSgUV+8tNPOmdd2Jex2/Qi EhP6YaV8aD1E7Wdb9Y/E3c6SsaGouch+TWuFceZ1ViN2g9uIJIpcfO0xDnTwfdBx8JiR ues84Vg2FqrlJsrRTh0AwT/wIypnz7w25uyv0PMZ2bzhfp8ArORB7t+N6XY9Q3mIWeHG 6CEr7NgAVxYTYRPbb49Kdpwo+dgnls6AMoOVYrziXSoYGo4txFvps7bsxmnnPpGAon5g Kj+A== X-Forwarded-Encrypted: i=1; AKwUvByqM5BfUPnQCimZnCSI6yu8yon4aj22Plnxnl3ELpvfZ67MIO5O3YDNm1Wl1qTVPq6ofZTu+Bza2vf4UzA=@vger.kernel.org X-Gm-Message-State: AFuF++ne2UIvyg6NnzLwPKls3Oh2fUe8CvppaypF12BuL3M8dC7xvWJO kxuENeb5OVoJ13iIRyJz60yftOMtQ8SCPosSPZ1B2cx/zXubhQmi8u4lxLipKBFwL9w= X-Gm-Gg: AYBFou1OYEyt1Ecw337/wN5QLt8zCvf9Y4gwC8+NTP3LZXiNBJbjT8gaq3GePwZ9MzG 5dtgwMaP6gUD20QxuvJyFH7QErbggou8LXjnzzq/8PGz7FjD6quhSTqgKSnnUpbK+/P+/vvG8ls TFHhrSsX080GlGIztiVLDNouLnMSB6qTwdwTrIeIiXChmTE4wi2Q/N6Ja+TirXx4x6KPd/YdItF 3JofNN0FmNAdhJi+wCL/9GcgVJGixoqfQNuQNnTysPnZiM4QL0eZtaPJV6x+zzNUgzbsEnMJQgB 3kQkLmwiefmTYt81KmHPeCfwtaQFq+iofbCVJ2PuoMj7CvFWI33Qt5SZILDD9/Vn3pTj1VuehpN biRA82qD7mjbM/SirVt99U4AUpJ/JpYE9ZNB2zyQECDB38DqjlE7BuBlaC4sutcwlsMjKHXkS+r 1WytfPL5HXbdG5OjPC7N7nWGqf+JpHrlbZY2DItlNPjJ2XrhDOVNIYi+nDPyYIShzjNEFP73Mop t7T+5E= X-Received: by 2002:a17:902:d58a:b0:2c9:e9db:8167 with SMTP id d9443c01a7336-2db124a8c93mr317203775ad.7.1788767952642; Mon, 07 Sep 2026 00:59:12 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:59:11 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 08/13] srcutree: Forbid srcu_expedite_current() on atomic SRCU Date: Mon, 7 Sep 2026 15:58:24 +0800 Message-ID: <20260907075829.2073224-9-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan srcu_expedite_current() has no early guard for atomic SRCU, so calling it on an atomic srcu_struct leaks the expediting callback in __call_srcu(), leaving ->srcu_ec_state stuck at SRCU_EC_PENDING. Add the same WARN_ON_ONCE()-guarded early return used by the other forbidden APIs, and list srcu_expedite_current() and srcu_barrier() in synchronize_srcu_atomic()'s documentation. Signed-off-by: Kunwu Chan --- kernel/rcu/srcutree.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 74acd5645d4c..2d2a12f86115 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -1972,6 +1972,9 @@ static void srcu_expedite_current_cb(struct rcu_head = *rhp) * no current grace period, one might be created. If the current grace * period is currently sleeping, that sleep will complete before expediting * will take effect. + * + * This function must not be invoked on srcu_struct structures that are + * used with srcu_read_lock_atomic() and synchronize_srcu_atomic(). */ void srcu_expedite_current(struct srcu_struct *ssp) { @@ -1979,6 +1982,9 @@ void srcu_expedite_current(struct srcu_struct *ssp) bool needcb =3D false; struct srcu_data *sdp; =20 + // Atomic SRCU has no callbacks, so there is nothing to expedite. + if (WARN_ON_ONCE(ssp->srcu_reader_flavor =3D=3D SRCU_READ_FLAVOR_ATOMIC)) + return; migrate_disable(); sdp =3D this_cpu_ptr(ssp->sda); raw_spin_lock_irqsave_sdp_contention(sdp, &flags); @@ -2104,8 +2110,9 @@ static void srcu_advance_state(struct srcu_struct *ss= p, bool is_atomic) * * If synchronize_srcu_atomic() is invoked on a given srcu_struct * structure, then none of call_srcu(), synchronize_srcu(), - * synchronize_srcu_expedited(), or start_poll_synchronize_srcu() may be - * invoked on that same structure. + * synchronize_srcu_expedited(), start_poll_synchronize_srcu(), + * srcu_barrier(), or srcu_expedite_current() may be invoked on that + * same structure. * * Because synchronize_srcu_atomic() is even more expedited than is * synchronize_srcu_expedited(), there is no expedited counterpart to --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BC7F43CE51 for ; Mon, 7 Sep 2026 07:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767958; cv=none; b=XpWY4G6HYxtqQBjXopzex/DbxC8AgaQz/MiY5ObcGEGDhdEwxrpsub6xI54vWy+FX5nnYYgg2RFMRgZ2I3XdFlb6XAmfdNwR6QhDLk9vB06gMtUUPKYfbgxscV7y3U5VHoLvp4vw5CFOW5IqbbnDWoKIpY+X8VI+NW9CK2TXJLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767958; c=relaxed/simple; bh=WMCLkI7cWCG8y30ht13Dpjq+ytj9QwWIte4gc8x98sY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B/SgzBgep/JRp7dMPXUbHEaBOFuakTyT+qZSO2Z4nS/Y1YpUzqJ6a7fMQNE5NeaTLzcnUCX7na1GSpF4rxuFv5SJZt+uXOlTGAm5h/K6W2YqZq9+T81yu7DHO5IahKMx6BohxSHknJtjWJFxFkQudF2mZJ3QL9+xjGpJXObVPgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Iyom0FQq; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Iyom0FQq" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2d6e954afbdso20250485ad.2 for ; Mon, 07 Sep 2026 00:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767956; x=1789372756; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7FLjMyTZSsmtCKr44cIMaimu0UhFxFiYLpxSbsSIK34=; b=Iyom0FQqSB39dSrpJQF3oApuYVzSfnrHbk/WEr/sl2OxcceCefVr0buF6NFJ6wUL66 /F3ztxzd115zx8eaVaXzxwIpXymM9YburDPaOY042jd3hm98ODAy3R9ThAeO6cSYTDJC eyWV0p4aUU5pTAtmB+oq9sUUXZaWW5Sp1PO3XKE1uRf5gEzd0MmBqELeLKMYufdpkQIp 9YgWgmjaPb8GYnoaf/43g+Out8/02XXAYcFZhYPrYAgoWW2cA7VbvlNea4rH13uxm0Iy i+46PsPTRi1uSL/9gJu+08yZ9YZixyg9lyhTiip6DQImd1DHBdk9/MH/M0CpMWRT9ZVm ArSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767956; x=1789372756; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7FLjMyTZSsmtCKr44cIMaimu0UhFxFiYLpxSbsSIK34=; b=TVxxIQYRcDhrrij4SDdOO8vpkyOPrBVE+mOAqZMjonqvquwpFq15ICd1DjNpr+4+X4 WTY84VknTT9NVBIUhBW/EZqpoAuJfmGviTVfQ7QFokIpgUwuINMz9FWlROfj/Sj+XI84 vi7ZjTvM6XTHVOu1a7R0AwGN6F8/o/7zlXRIKaNzlR2qcQC68wj79PXdrYnkFGy48kxl k+tVlqc0xlCNcDho43w0jrpwYLDHTMvxbhlFXHjMhdM2p3GNtrtAsdR9FE6uML3hT25j Lz7am+icDpBgwNd0FHqZ0klQxJ3PaOWQHHJ/xGm7KYWCjapHgKmFbVat+8UVgpoLzsPs fvbg== X-Forwarded-Encrypted: i=1; AKwUvBwdoHmwvyRqwTi0g4U3pnfb2MBJZk7gQoyZ9vj/oLhjsOJeJJPaYHKPGm+74+VZmke8K0ZMTRv3Cu9SWDs=@vger.kernel.org X-Gm-Message-State: AFuF++lr0DRVd49B06RezjVs142Rz6A3O2q7/MLiTJFG+06Za2eKjQsq HQQAHC3Vccp2LMF8UZb5gRa+lVLl9dA6TlFGbqZyOGcelqRVS+GoYlZU X-Gm-Gg: AYBFou01QW7N/ofSPFnpmg0DdXyBuWua5ZwEy4jl6BLrxD6UBStSsBObW4+gfaAMfrY nXf3aie7oiDUN63GQ802GjRlJ8YY4xG2AHlYgqL51VD4TgT/dIZv+XClLkrVKBM10KVDFBBmpN9 Bxm5KQvRawlBjRTZz81/ktOpOhMzjQPT/xuuPCImmB7kRKxHHOsXwt+sFogNIWr4yQFgRgJJACh 0b2PPHGNnXGF+itGmkBoUn9+1ELy8g2AT+4n6IFqjxFIeAcdSC82Zk7Hf6jAd50/CY4KuFgUaYt 8NAB65gm6QPqar155ENt2HB3+MUWFKxMwmTz/KCs9Ig6T8wkxeEkS2bx3ahQjk3zRe2GR1ziLs+ XpM1w0DXpmRjHtYOJB1ieeW0F+G2ZFVE2GgB1S6ynO08QnYtTFWfVpM2CiBnE6QGDvOK+f6CNdi eB/JjSNahPW62JfAB25vh0Uh+TIY9WfSo8oBitqL5MSlNFPXxo7o6DtWbmMLVfW7rWi36esEJb/ Zdzk/0= X-Received: by 2002:a17:903:94e:b0:2db:4bae:1ece with SMTP id d9443c01a7336-2db4bae2044mr85147475ad.3.1788767956089; Mon, 07 Sep 2026 00:59:16 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:59:15 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 09/13] rcutorture: Disable srcu_expedite_current() for atomic SRCU Date: Mon, 7 Sep 2026 15:58:25 +0800 Message-ID: <20260907075829.2073224-10-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan srcu_expedite_current() is now forbidden for atomic SRCU, so null out ->exp_current in srcu_torture_init_forbidden_apis(). Signed-off-by: Kunwu Chan --- kernel/rcu/rcutorture.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index a9672fe88cbc..d795e07a12ad 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -721,6 +721,7 @@ static void srcu_torture_init_forbidden_apis(void) cur_ops->call =3D NULL; cur_ops->cb_barrier =3D NULL; cur_ops->deferred_free =3D NULL; + cur_ops->exp_current =3D NULL; cur_ops->start_gp_poll =3D NULL; } =20 --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FB6943CE7C for ; Mon, 7 Sep 2026 07:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767961; cv=none; b=CHz+Wb63zVjwTA+ba3LvlFVprcc/S9+XecBKL5LLuE6XRgnCLBUE7fFsqXFnyOQZvB2O+Bh4hK9wome6AVqj/+msP8865BRgZWB+GvtHcw/6ZqJ4dpwNsFw5RnE8CtL2065u+Ji7tz3O3D0H+F/3EA3z372nGZ0a/0e2hQ5S9gQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767961; c=relaxed/simple; bh=RzK7kMbyNX0ub/uYwf0yfYkwe5IMNl40/Xs6NO4qP68=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CAIrsaSrO8SVUIB5Iq2jSPqAkV5IIHsPe9f98lVhSxbuuXrt58uCsEB1t0oBwNr6Lhr12e1OiVqRxK7LzxFlJ09p7ox5CZfzSr/IHW8PxngX4+gMMQhFqDYsJ2Vcv89MXiRdBAXUFNlpWFuJbVVWcfGZ5Wjxuv23LZLQ/vu7Q+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DjoTBF35; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DjoTBF35" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2db18e5cb56so29079355ad.0 for ; Mon, 07 Sep 2026 00:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767960; x=1789372760; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KKFw3PpfzfMC3bCjGChjW74mzAGePmhCsoG4uFIYkwk=; b=DjoTBF35k8pJoY/itnQ8weDS5Uya4GAjLz5kc5MU6G6/RELaAPf+poWX0MjouRCgMM RMEPIeoPXXeHtJis8HbZZ3cVDTzGQ377RBrafGgece9eUR5oWDj+fot7YH5yOUl6ZzIK Gq0Zdy+cuXzRYnGMMJYVqnRIgixD6n/StoNU13J8oiUdVTCP5XCv/2meiMAMaNxL0fPp sg2HXmU0d19sWhn22FTMmk8yuQPVz+UT0fWRo+z0wcKJMvCJEqwQTKCaLn/GL1+aYvER emVF37/ZpJzfvuKdoKo6fqY0QoSMcxFpFRSbs/aFL2wqFbWEWsfT0A4jG+myytNsqGeZ ZH7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767960; x=1789372760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=KKFw3PpfzfMC3bCjGChjW74mzAGePmhCsoG4uFIYkwk=; b=CkIe3hgQHu+03kVywvE82+t7/4oZGnpdCoW+ed60AlNpAdruK520IVdj3UteIanvmE nmqal88AafIRq4IUwuB+TbuH4ik6uS67UwRmQv2pfB6jhclEXnJLKwl+AuvhIGtLItLa D1wOP2+xNR9wh8DQ0yAcd2iOoopJ6CPZHtPLcuHTgg4bCXD5KVsOjgBKD521AzoKnRXp Y8Frq3cwvLUwMrcCF3oN7tKmDXtXFLL+OC9E1tLZ3BUwqtYKygToIagOh53qTR63x8+X dkOujoPYYqREA4343bSYv+BvLcR3gnaSovRVqlwjlQd23AOrliNmVlELV465nFOn7Ol6 nlHA== X-Forwarded-Encrypted: i=1; AKwUvByg5vAgIqX3KW+W8lZNNskZO3Rnu8cjiEhjSXaIjQgjhboDPG5kx+XvqZrK8JL6D1+/V9AY2ZZwXOOK3MY=@vger.kernel.org X-Gm-Message-State: AFuF++kTZ2gICkdFD/5qd/0xItZToUMO0+pFoXWUEYBLVsxvQ0BOCoZf 8Ib+Y39ViXJh5fwBIzKv84ru+xuY7GRO+aUYwjd8e1s0EC3ts/fs6IoN X-Gm-Gg: AYBFou3647FwgnP/FmhnsePyatIT4o38N/Ly91DxoHZT+vKG149G3EPZmjLlgxpxpvn FrsTr5O4jTjHaf6QiH9QI6oPRWZc+vKNVdg01Gh2By6RKzuS7WWzKHN2UzJdmMgePaIw2VkM74V QTK0rz6cin9XQ1mvIgDVNeA/F93PXNx0c8MIOHzIUjGL8c2r2QBMCMmO1v2FjDs+EiqhfTy3RLc 13zDNqsKmbmr901U6dC3EmSJLrg3U8AgAmiUzC5M2wshzeE4VoVJFfpCHqbTQYlEg75Mr2+lHPd bL4hYYgZo+unN9RTybb/GmDSiDS+RBdi3pWBbA5bx5xF60tzBk1XUTACxEK9eN/9r0THP5Fepij daV2obX9sxnVAoM78dtm5DV+ii/zIKcoxUUEyFV3miW1pzmWiYSkg9Xq+y++yQg+ij/rwAcFuKE 0zeFNXvVSiBgwGxVOpi5viErLrFJbWPIpGJ0J2UtCHAroxiAUiP2ou7LLABQi3U0VEBsSxUNXQb 2Hoyso= X-Received: by 2002:a17:903:1acc:b0:2d8:d4d0:7931 with SMTP id d9443c01a7336-2db128bde59mr303579055ad.21.1788767959527; Mon, 07 Sep 2026 00:59:19 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:59:19 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 10/13] srcutree: Skip callback scheduling for atomic SRCU grace periods Date: Mon, 7 Sep 2026 15:58:26 +0800 Message-ID: <20260907075829.2073224-11-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan call_srcu() is forbidden on atomic srcu_struct, so srcu_gp_end() never has callbacks to invoke for them. Yet it schedules callback invocation, which for atomic SRCU's SRCU_SIZE_SMALL state arms the boot CPU's ->delay_work timer every grace period, only for srcu_invoke_callbacks() to find nothing to do. Skip this for atomic SRCU. Signed-off-by: Kunwu Chan --- kernel/rcu/srcutree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 2d2a12f86115..c19f59725706 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -1018,10 +1018,10 @@ static void srcu_gp_end(struct srcu_struct *ssp, bo= ol is_atomic) =20 /* Initiate callback invocation as needed. */ ss_state =3D smp_load_acquire(&sup->srcu_size_state); - if (ss_state < SRCU_SIZE_WAIT_BARRIER) { + if (!is_atomic && ss_state < SRCU_SIZE_WAIT_BARRIER) { srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, get_boot_cpu_id()), cbdelay); - } else { + } else if (!is_atomic) { idx =3D rcu_seq_ctr(gpseq) % ARRAY_SIZE(snp->srcu_have_cbs); srcu_for_each_node_breadth_first(ssp, snp) { raw_spin_lock_irq_rcu_node(snp); --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E41542B33E for ; Mon, 7 Sep 2026 07:59:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767965; cv=none; b=pdvgrUi4wXEEMnca91Cbi1rBNWaQfVwHQHeVewj4mvE9BR17XJ1LGBcYLoajCkiM8GEu6gfe03QJCg4iIA9437Ni64WNITPWVwbuU4CDrx4Hju4ovzqrY/Psi3REC0Wwf6BhFXz0yS+++utAWGymAsgk6zZJH88LOO224lqa2eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767965; c=relaxed/simple; bh=dg7Xxulm0f7n3Jncso1740bE2QW01y0FbyYtuO+2rns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qSf6C9367AQ8v+qaeyk0g936iEDoiFiNBnUQjSeor6U/PIPdN0ZFzZIZVYxsTc9BFrsy0jYAY+xxwK4uWPRIVdY51cQNPEX9CpDb6NjNKvw1N+BhVGYXtlN5azyebVeklipV5c9qgJ9ah/Yu9FVOFA2fLx5QvsbYNc1y2pRlb9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A3dQKsRR; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A3dQKsRR" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2ceab75934dso31012465ad.2 for ; Mon, 07 Sep 2026 00:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767963; x=1789372763; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DX1yDb5IswgEQSYkpWQVORuzyx8T1C+zUGVpHzXErSU=; b=A3dQKsRR6bQsVkTgc1hWyIHzpvhr56LM9fIaKwZPOgKPQMVbMjU6bETbTF2C64DpXH VYazgsbVFvYIwCqCHbOIbIytWeS5oTEv4fdUS04sAVIrEhYxp+dbtfNs3lYD23hWGmmJ lylH6Ph4BJyLw2eD4lgqVIWDWEGRYe3B9THVYPrjkMNAaUhUVnlvKspsNxr5gCDcDNJi 4gFwO7Uhv1iuIXoKeuu+S2Ojp4UeISomEx9tt1kC2648NjGdX6M+UkmO3VwVf2ubjYp0 uZQKF9SOOhuKJNvucCxYMufcJlWNsKu9JTbk3ZP0yx65aIow8M0Gu8VknMTw4vjQgQk/ Nx+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767963; x=1789372763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=DX1yDb5IswgEQSYkpWQVORuzyx8T1C+zUGVpHzXErSU=; b=lHobEnIyK11g9H+rp7oYfxxpPteXfk2RLItM0rmh6ez38CkIBNS2rRNZrmxfckh3ZD 27Hr3/YauDDhCH2woHWJ2I4ReSgUFha9a0Acsraw3f3xaPdOWfLL9YI+TqXBx3yoXNUF dYmSqySRooWTeYKR7lj8XOdHiznucIDEJ3ixfo6Ob7RBpIh408G3RNcP1JsaIZCErlTg U9xFzwCrKMrWftNAR1d9Zhq8orppK2TUSagbER4V/hS/ikbV1t9tDcK4GmgyLOGOwmVA 3g5AuMJnxJ+X5Q9TfSQck9EZ2RYnQrDgEy4/VmzffdD+sZxWOuEkq3yigc7L3CzztIMa T5Ow== X-Forwarded-Encrypted: i=1; AKwUvBwnvP7ry5co5V7ll2Q39Q4vhP6Pj9WsLMzzCCnYQcDoUx2MMjEf5aUnE64Ld9Z4s4Dcofa7hRXxGT0i9t8=@vger.kernel.org X-Gm-Message-State: AFuF++kH9vPywzuuZ9SCteaI1W5Zha0gd2kpL/eqxmgncD9la27TzQt1 2QqE4OGecJQimpeTV7XSTi/KiqhahYzR6+fcOS/XNvXU1oB6hQQXIiu8hsT4iWN4nZE= X-Gm-Gg: AYBFou0em5FkeWjeebi+nbj/yBL4jDSpnKt7zeTkyyvAlA4nocYErI/9duxwNnQ8cSB jwXIClXVE+j63bKmGWE2HNcDLGl8u8J08eMT8QAj6xzMX9UceIGZrdPVue+UOr/RfgbcX/0D2Ya JpMNCgtPJUTeLPiSuz0o5McCJf1XK+ioB6btt6P8A2X366mvI5tTi10VrvHADq/9Wa2hejXonK6 AK7k8EpQe1Q0Nor02sR14qdUeR5BSx7/9q/Y6sVksqcE/G1YEWPGBdJPzs74ZMUqds8tzcxHdcU 4+WoEd53pHHiUtP5NM1TpnianNV13sncrAdSCL1cX52bvHUALdNLcJ8avlEVNM47hkRUTCYrSd1 w4tUWVEWkQtDSMjo2+FGTrDVFTS9fLmEINQ0d2fxZDogWZSj8rzO/YXAUtKWw4RW222Fl7ivG7O Kd09nQ3hJ4r4OEHA84GUXvmF4ol0h7VOd7XAXbm5r+fLMnHBbGfWG8VWQma0IftG4KPTldgFrxv GevHa0= X-Received: by 2002:a17:903:32c4:b0:2db:39dc:48af with SMTP id d9443c01a7336-2db39dc4bfdmr135589825ad.17.1788767963010; Mon, 07 Sep 2026 00:59:23 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:59:22 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 11/13] srcutree: Remove srcu_barrier() sleep for atomic SRCU Date: Mon, 7 Sep 2026 15:58:27 +0800 Message-ID: <20260907075829.2073224-12-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan The atomic-SRCU path in srcu_barrier() sleeps for 100 milliseconds just in case there are callbacks to wait for. But call_srcu() refuses atomic SRCU with a WARN_ON_ONCE() before reaching the deferred-enqueue path, so there can be no callbacks, deferred or otherwise. Drop the sleep. Signed-off-by: Kunwu Chan --- kernel/rcu/srcutree.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index c19f59725706..a93bf803e2f7 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -1895,12 +1895,9 @@ void srcu_barrier(struct srcu_struct *ssp) unsigned long s; =20 check_init_srcu_struct(ssp, false); - if (WARN_ON_ONCE(ssp->srcu_reader_flavor =3D=3D SRCU_READ_FLAVOR_ATOMIC))= { - // There shouldn't be any callbacks for atomic SRCU, - // but just in case. - schedule_timeout_uninterruptible(HZ/10); + // Atomic SRCU has no callbacks, so there is nothing to wait on. + if (WARN_ON_ONCE(ssp->srcu_reader_flavor =3D=3D SRCU_READ_FLAVOR_ATOMIC)) return; - } =20 /* * Register any deferred callbacks before snapshotting the sequence. The --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD7AF43DA2C for ; Mon, 7 Sep 2026 07:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767969; cv=none; b=Dsby8PlHPhOUfzGGpa7fbLLNdgzSpMYsvzKEtVk8GqLXe0DhSC8G+rCgKCEW+fJNvJXi5OgbZi3Nfqn8IcaDvlbrJlLoi+F+Lwgg5E8w9cK+MAcfK6E08EiGBQT0XB8tM1eBDgTfKUeo2t+sFv8mElUgruIfkru070kZfJ/ybBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767969; c=relaxed/simple; bh=CY0SGZKkWGBgKFAKz+DqhuTW6aotEarWwAXGLJcyfqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N+uOCIbyLKCY73quV58Uh/DzbUiA3XHLhD94tuWpUwEEHkMpbbq4FhWUNEuorF4WgfxvhnLNxhGqVzzb5qZMYMHsZzoCa1DND3V313bquSDT1QIWdDB+pyRxyFo6D/wElMIkS0Y5tjxCsTnjZfCZt8K9qkRDj+k4JpKG3U/B+18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZlczcLJ/; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZlczcLJ/" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2d91ded8174so24758225ad.1 for ; Mon, 07 Sep 2026 00:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767967; x=1789372767; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rknn3+6TS+aLNZFIltiGpSi2IYKIP8ZCdc2t7DJkt98=; b=ZlczcLJ/b25uKxe47Zb1+5Rr69MFn6lsDS07k1AsDeHmvonMSHsT4ZGPO1SIRaeY+d 75Usme2oHOuM9FwevXhlmemtMQ/Okrgz2JsdnRq1IJZXOMx4Pg3d4KjO7g9QC/tUDgQK /DAMmXuKV2dxO4YGaIX7Cl4DETxCN0d5Q54x3vqR8r6C9B0Wx0JbknmG9LDgdYaVX0Ht 93GS6TO1mEoIBlRDY0csiZvOFtbQWZmEdF1pfRkXtwb+dBbLfygTql9JUm661TbdgrRc 3qMZ1y0ktCEKRLoXNd6//wVADz/GHgUOJdZp5B8vn/AYjw7zLzs9+4gJKlToGwUY7XHa 0xGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767967; x=1789372767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=rknn3+6TS+aLNZFIltiGpSi2IYKIP8ZCdc2t7DJkt98=; b=qMeExU3EcwKRl0IPfJWQ1vXuH6WboxfMOMVwV3+BXi69qNMqC/JrL5cMRmFW82BqXi nbiEMnS/ni0e4SdAKHmEl3pSOMLMEyjI/Yo8P4AcRW6WQZI/zvgzUBEd4eT3O8OIcI3V bGz92L8x4DOf5Yv0t+Vm63Wk4Ztzr8zKKUmHzfPRKCt+SgQADPx2lD4EpW3mwik9pSFk WviyJllV1MFnR91PvqAYruOR45wjw0hzQKnAdI0k4EHV+pn2A5OttggXgNoXiSf1QMhW awp09z8tOy2TuadL54aqckt1TzLLNlXocIDTrfJLfx3eL5OTbUi2BUKXnD7FHLIdLfyt naNA== X-Forwarded-Encrypted: i=1; AKwUvBxsDZRcRcgwIU/PjH6VYF4so0VjBtUzLYN5gEevauSSAcX+GNKssH8b1XVSx5sNX5y7HvvoEEAz85ve2v8=@vger.kernel.org X-Gm-Message-State: AFuF++m+ZLxAshq4Mj3sWmRyjUyuH6+XWS/55mf9atyR2xJvP9HC1DLn ZWvaZGSstv66rLhtR2SDGsz4KV5mP+NmYWG6MSEA7HJL34BV+u58N1s8 X-Gm-Gg: AYBFou3LijAvR2wMujyl9muiP3pqwKMsffqfEai/U8LMrBwsUoHUIPXrty75Wa3WoWk ZMO0PVJ6fsexXjSibDy/IoAdeB7a8wxm7GoW7TROiMzZiZsrEfvkGFqtEzhXtfz5RnPIEa7WJFk cQDNqTo6in56l0nBE5C+CgefSGYkc+K8i++F0Z9xxMHOEPYFPQEqc2aC3mStbBcHgd4lCl4Egm+ 9VTfzsyF4fDeCh4XttK6erBK9QgdcE9Mz3aSf94XCQG0kqxXRSuEWYxjbNGI3WL972NrfqKc1+B HUyGfJ6vWFx00GCuJSlUGnPTReteOUR3aC8hPdNr5EXFhA5MIZ5FRRAOvh6lDA93+x34/h6jc/5 guZ3CoP412jNBO3NhdJ7PuE9qL8vAT86+8f7Wp5KRtzqJIT+Jo8E/+I8BPFKq2hHgIiBljsPWBZ 24NB4Fw+A+jHgg8KcZfTxZaXA3tpBQb+OmaHXZuq43Ewk7Er0gShj+3VwkeBaGB8iaVV5Qc5ez+ JEHU8U= X-Received: by 2002:a17:903:1af0:b0:2db:331b:e187 with SMTP id d9443c01a7336-2db331be292mr163344515ad.8.1788767966572; Mon, 07 Sep 2026 00:59:26 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:59:26 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 12/13] srcutree: Remove debug pr_alert()s Date: Mon, 7 Sep 2026 15:58:28 +0800 Message-ID: <20260907075829.2073224-13-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan Remove the debug pr_alert()s from srcu_gp_start() and synchronize_srcu_atomic(). Signed-off-by: Kunwu Chan --- kernel/rcu/srcutree.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index a93bf803e2f7..a016c93d65cb 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -916,7 +916,6 @@ static void srcu_gp_start(struct srcu_struct *ssp) { int state; =20 - /*&&&&*/pr_alert("%s() start: ->srcu_gp_seq: %lx ->srcu_gp_seq_needed: %l= x\n", __func__, ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_need= ed); lockdep_assert_held(&ACCESS_PRIVATE(ssp->srcu_sup, lock)); WARN_ON_ONCE(ULONG_CMP_GE(ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu= _gp_seq_needed)); WRITE_ONCE(ssp->srcu_sup->srcu_gp_start, jiffies); @@ -2152,7 +2151,6 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp) // OK, we really have to do it ourselves. Start the grace period. non_block_start(); // We must not voluntarily block! smp_store_release(&sup->srcu_gp_seq_needed, srcu_state); // See srcu_funn= el_gp_start(). - /*&&&&*/pr_alert("%s() start: ->srcu_gp_seq: %lx ->srcu_gp_seq_needed: %l= x\n", __func__, ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_need= ed); ASSERT_EXCLUSIVE_WRITER(ssp->srcu_sup->srcu_gp_seq); srcu_gp_start(ssp); raw_spin_unlock_irq_rcu_node(sup); @@ -2208,7 +2206,6 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp) cpu_relax(); srcu_advance_state(ssp, true); } - /*&&&&*/pr_alert("%s() end: ->srcu_gp_seq: %lx ->srcu_gp_seq_needed: %lx\= n", __func__, ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_needed= ); ASSERT_EXCLUSIVE_WRITER(sup->srcu_atomic_gp_flag); atomic_set_release(&sup->srcu_atomic_gp_flag, 0); preempt_enable(); --=20 2.43.0 From nobody Fri Sep 25 23:53:13 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D71B3438493 for ; Mon, 7 Sep 2026 07:59:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767973; cv=none; b=rh7/RQ2LmVGUVpYXtgVTcZ0Yp01TV9IsdXI3nIw+l0cia8b3dkWEbxyuuJOFU0lbJXARXxQu8L2wN9rWS7qXKolX80ZorZ1lVsHukLrrnbag+uHZuYbnbZA1eHQw4pyfrXCZKZrV4lSU+wbAOSMsUvY7chnwLN5vf34ijWKCJtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788767973; c=relaxed/simple; bh=uQx14bVi1sWpKlGObq7Zs2CltXZjAT2cZVhLEUWzylo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ir5nABpXoAq+o9ZFB0cV6pf4GeYUzCqJr/fLbGlcg1QImzK3DU7zSet0RgzUMZr+DDGjJJXfNxtp4on1hQpjAvrxxwbMqL2CSaDTRKvzErA+cLHLVtmWgTkTuXT751jRjp+7LuPpCdoZ0LWmhdhc+jBGtE0U5hvnKugPINm80gY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=tBs9gmtf; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tBs9gmtf" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2d91ff7d9acso27194465ad.3 for ; Mon, 07 Sep 2026 00:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788767971; x=1789372771; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Pmdmw98hxU+ikwRZNh3C3CJu0WUlu7q2qMzon9en28o=; b=tBs9gmtfPfGvOxO2rtLMEH7PzNnPbDBpXTRWq3mQRHOe6K1AJfu8t1jTzSiarOKQjc srPeWs9xCbsMy5c2MYxWpgxptbxeUaYTmOOGhHWWhJf9lWY3T7wAfqYK1Deyzb3OY7HS Bvr4n5Cha3Q7PrVMMPP3BOR+O6CvzA9FR23xYUnrWIEV5kgwVomxm6F6kpgJrIabBi98 kZv5Grnb6RDiieh6TkcYLxDYPKXN5vfd8L6wACfoaCJivuVLufXLQJct78MQ74ZZDCmb okB0iuXycr4h3Qq4TjocI8KLBFF3TggwYlc7agCvmi7GUDmck2qsNZY8XsR3PEQtHqUu 9vIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788767971; x=1789372771; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Pmdmw98hxU+ikwRZNh3C3CJu0WUlu7q2qMzon9en28o=; b=aBzU/ilQbxTNuV2b+e43qgAU9n1LSnbXoMszOrQfWvg4rIa1j2Cwv2FNXKWUQYHXYK OZjMhh73+4LZ3z3p2LzRM0jirgdNXvr359rV0V2l3EjbShfqoDkNN3lPN7LJjScSsP+I srGrm1/ANnLQrNeDs/4EgTkX68DauMujh6kCi6N2KdO/9OmIFDqOjgB1BCUz0y9eDtIL zAPuMtzdPHiLkYkg7VlytRuz/KM3JCdVGo8Dqd8cU1dDaBT0DBmu/5xrVuShp9TqSAFG JgrnEpBySkdWPcsgAQXy4bxax5SOVDT29Pq+hB2IYYwWGsPWBwHlhYDyZUayLmiKEKda N19g== X-Forwarded-Encrypted: i=1; AKwUvBxgynnrqF4OvO7JMCNlabwfa7quXY6b7RfEjG7jNaM81Uu6unnR+63/4NSV1Kb/xbCbOvfOOcxOGymopFU=@vger.kernel.org X-Gm-Message-State: AFuF++kHiDkieoq3CJD9UpdPn295lB5XNDL9UtgNvSwTexzMwwBeNOdf DPfWkbvLjZHwGpFy+KRG0Ht6B8rDdpYdc78EpOCZPpygOO2/ZcoFvKUHZXHUbyEn+nE= X-Gm-Gg: AYBFou2R3GA4WJIgTLdkzP6rNzNWkxMPoqwbNbNZRB7wc9n/LEpfaPhKujwmCH3OuSM NWgMBhl23MMx9Nr/TxRx/hyZ0IaDstsualhfmfGz/n1ke1w1X6+v5BDoK0WODxzAxZN51WOaLdF odr2emGEwJS/+OrM+KfA2yu+CxgyZXdbJMNn1pG6xtk+RBurOSVLjt+dNBoD5XYvBukT2SwhN3q 69C3mFxK2bfpoFXxiPPLk82LhrovI0zslgvBpycgg1peCiheUtouzQrYl/sjxFr6+ki5E3b3qef pTUNQP7OwOUKkd+0mHASMSk3nN47kpwHKmPP6JZo+5FCE+Qu0NTF4G5lJe4I5CJVcQU3VfXY2wE tVqyOumviPlqT4+HH1QWJ74M6uMzuD78Z6yv5wBv32oToiA8sPZMa1WH0uGj9nVMvnatCHi1iFF MNhTn/2/as/0pZpR0eEph0YIhQ/GBo2IcDgAE/iOTZOrlHha8o4m9b4/goDVwzl54ohFZKPSRPu DmwzqM= X-Received: by 2002:a17:903:40c9:b0:2d6:f6ba:263d with SMTP id d9443c01a7336-2db124b451cmr295656785ad.7.1788767970456; Mon, 07 Sep 2026 00:59:30 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2db14ae7637sm40945595ad.79.2026.09.07.00.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 00:59:30 -0700 (PDT) From: Kunwu Chan X-Google-Original-From: Kunwu Chan To: paulmck@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 13/13] srcu: Restrict atomic-SRCU non_block annotation to task context Date: Mon, 7 Sep 2026 15:58:29 +0800 Message-ID: <20260907075829.2073224-14-kunwu.chan@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907075829.2073224-1-kunwu.chan@linux.dev> References: <20260907075829.2073224-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan srcu_read_lock_atomic() and srcu_read_unlock_atomic() arm and disarm might_sleep() checks via non_block_start()/non_block_end(), skipping hardirq so the update does not land on the interrupted task's ->non_block_count. Inline softirqs run on the interrupted task's stack as well, so a timer callback running atomic-SRCU readers races with the interrupted task's own ->non_block_count updates, as KCSAN reports: BUG: KCSAN: data-race in srcu_torture_read_lock / srcu_torture_read_unlock write to 0xffffa00f818ea418 of 4 bytes by interrupt on cpu 0: srcu_torture_read_lock+0x422/0x470 rcutorture_one_extend+0xdc/0x600 rcu_torture_one_read+0xd1/0x330 rcu_torture_timer+0x75/0x140 call_timer_fn+0xe6/0x2f0 ... run_timer_softirq+0xb7/0x130 handle_softirqs+0xfc/0x3f0 __irq_exit_rcu+0x8e/0x100 Use in_task() so the annotation is applied only in task context; it is redundant elsewhere because might_sleep() already warns about sleeping from atomic context. Signed-off-by: Kunwu Chan --- include/linux/srcu.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/linux/srcu.h b/include/linux/srcu.h index 0de21155abc1..403fbe57ab15 100644 --- a/include/linux/srcu.h +++ b/include/linux/srcu.h @@ -346,11 +346,13 @@ static inline int srcu_read_lock_atomic(struct srcu_s= truct *ssp) /* * Arm might_sleep() to catch even a *potentially* sleeping call * in the section, not just an actual schedule: the atomic-domain - * promise must hold on every path, contended or not. In hardirq - * the annotation would land on the interrupted task; it is also + * promise must hold on every path, contended or not. In hardirq, + * softirq, or NMI the annotation would land on the interrupted + * task, and can also result in data races against that task's + * own non_block_start()/non_block_end() invocations; it is also * redundant there, so skip it. */ - if (!in_hardirq()) + if (in_task()) non_block_start(); srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_ATOMIC); retval =3D __srcu_read_lock(ssp); @@ -562,7 +564,7 @@ static inline void srcu_read_unlock_atomic(struct srcu_= struct *ssp, int idx) srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_ATOMIC); srcu_lock_release(&ssp->dep_map); __srcu_read_unlock(ssp, idx); - if (!in_hardirq()) + if (in_task()) non_block_end(); preempt_enable(); } --=20 2.43.0