From patchwork Thu Jan 16 20:21:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13942233 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC41C242249; Thu, 16 Jan 2025 20:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737058875; cv=none; b=ABBglwgJhTonWtJWvfd0VeTyAL5JD4VlI6nK4T2d5mgjyHykBoawCvUXWMQ9l/Dlhc9u0y6DTBMt82qI2HkPqZDXiq9GsC/BP7qDPPJ1dq4r5CqNjCqIkO7cXxQfkPnGqqbfUGUSJOFwJ18g1nIOB4tgBR8yMvw7UYXoJXN8cgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737058875; c=relaxed/simple; bh=3qE7yuKsFlMf41c9U8r2tEXixXhgWo3FZtKXnx6kwDo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SxL6ItiZNWuEvkbhDPM9E4CE8dTXRUeZGyRCfOFrUr3aPRbEFC0hJKOU5VOWxvB/OmGe/ZLy5HeNu5qcDIP3dufv7fmEr6tPaciuAKb4IqgFwBiIAllg4vZ8NmoZZaZBxkk6A3X74MGhUI/GO5Kmg2o++IGWYAMejgbXmWe773w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DTHTtmj4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DTHTtmj4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A99BC4CEFB; Thu, 16 Jan 2025 20:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737058875; bh=3qE7yuKsFlMf41c9U8r2tEXixXhgWo3FZtKXnx6kwDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DTHTtmj4yFpClebyIsRPzqSAQX8SK4/1vqHlJU6/rhN7jRAJdNY+wJX83R4x6WqAd GVI2YBiW78zRJ4PzFlBzeZ3CTdq5J1/GLdZ+S6QLCfMgtp+55kLarPsKp9Eu0c3Wvx cYk9ra9T8erdIIVBbLumCQcch0Yy8h3DnPzPjeN5vjZ1JdCaKNiG91e0MhcEWszh4B S/HTDBBTM2MvtOq+JTrrKvNDPvgmX6of/U7E/aD6ljscgAZXNoSj37AKPsLh/uPLU/ K7zjgGuSjsa2uGo8A/CJDaT0NZKRFyamrpiDxeHsqJ3ymoaOH//ShGI+VDVcFV837V X546lX3dE3SWQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A30DBCE37DB; Thu, 16 Jan 2025 12:21:14 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , Alexei Starovoitov , Andrii Nakryiko , Peter Zijlstra , Kent Overstreet , bpf@vger.kernel.org Subject: [PATCH rcu 14/17] rcutorture: Add ability to test srcu_read_{,un}lock_fast() Date: Thu, 16 Jan 2025 12:21:09 -0800 Message-Id: <20250116202112.3783327-14-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <826c8527-d6ba-46c5-bb89-4625750cbeed@paulmck-laptop> References: <826c8527-d6ba-46c5-bb89-4625750cbeed@paulmck-laptop> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit permits rcutorture to test srcu_read_{,un}lock_fast(), which is specified by the rcutorture.reader_flavor=0x8 kernel boot parameter. Signed-off-by: Paul E. McKenney Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Peter Zijlstra Cc: Kent Overstreet Cc: --- kernel/rcu/rcutorture.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 1d2de50fb5d60..1bd3eaa0b8e7a 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -677,6 +677,7 @@ static void srcu_get_gp_data(int *flags, unsigned long *gp_seq) static int srcu_torture_read_lock(void) { int idx; + struct srcu_ctr __percpu *scp; int ret = 0; if ((reader_flavor & SRCU_READ_FLAVOR_NORMAL) || !(reader_flavor & SRCU_READ_FLAVOR_ALL)) { @@ -694,6 +695,12 @@ static int srcu_torture_read_lock(void) WARN_ON_ONCE(idx & ~0x1); ret += idx << 2; } + if (reader_flavor & SRCU_READ_FLAVOR_FAST) { + scp = srcu_read_lock_fast(srcu_ctlp); + idx = __srcu_ptr_to_ctr(srcu_ctlp, scp); + WARN_ON_ONCE(idx & ~0x1); + ret += idx << 3; + } return ret; } @@ -719,6 +726,8 @@ srcu_read_delay(struct torture_random_state *rrsp, struct rt_read_seg *rtrsp) static void srcu_torture_read_unlock(int idx) { WARN_ON_ONCE((reader_flavor && (idx & ~reader_flavor)) || (!reader_flavor && (idx & ~0x1))); + if (reader_flavor & SRCU_READ_FLAVOR_FAST) + srcu_read_unlock_fast(srcu_ctlp, __srcu_ctr_to_ptr(srcu_ctlp, (idx & 0x8) >> 3)); if (reader_flavor & SRCU_READ_FLAVOR_LITE) srcu_read_unlock_lite(srcu_ctlp, (idx & 0x4) >> 2); if (reader_flavor & SRCU_READ_FLAVOR_NMI)