From patchwork Wed Oct 9 18:02:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13828948 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 732FA1E1A0B; Wed, 9 Oct 2024 18:02:56 +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=1728496976; cv=none; b=N85Y4XtFnOLa6Yjmn3eAijCg3APTkbK4iHGgAI61WWzaQ+dUQ7xGBBeSoJhSaIUuV2R0PfkkEfDTLGSrNIZY6xx2lhze5j0bcFtnXFM86x8qpH2rJAkzaUt2wmQATYnFMIaHmo5sEiSmn/Foi1fe20ItpbyEMiY18hPT5G56KyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728496976; c=relaxed/simple; bh=r+7xfcD7mxFvIDSheG/tRqNVT2+4G41e+4hHqbryp2E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yipe5MjUv/37TIfoKoK0LkSCmgZQU87OR4fDctFoq3QfxKJy9Zdauk3FMr/OudtJ9iy9qCHj2lY3dSpvfYvxJmLNmcZguo3ttZgQzxDJaIIOyrpWFa6TLVLH4FupmmPrUn073NLTucrj28atsgC4CEDV1qzTy4gv3JFqbmFVkVk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W9+JjfhU; 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="W9+JjfhU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B694C4CEC3; Wed, 9 Oct 2024 18:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728496976; bh=r+7xfcD7mxFvIDSheG/tRqNVT2+4G41e+4hHqbryp2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W9+JjfhUmZ0+opHk7pINHKDaAMx12EBs+g5xii95TnzTdZpm4L5kOxRr4gnI+Xeem ap1FKMIO95RXZNa5pbu6/o0hkU/XRlvF8A3wktDQk/Gh/L17L9SjB/qyWoDe2nv56Y ZELzekIeDVEYWYitKZE2mYpdsjBEAUtsYLPhpSMyxWhzwb1dRify3dwUUTbyoo+HLl +JMJL5sOK8ESs32Z8o8Vn73NBts9VkHDhu2MZJcTlMBzW9myq4NpZ+od1yCiPCC4tK uliwR3xDVlq4n40M0a8QX1z8l0X4XE6fMXG2OyetxkYrviigaENKaln4g+nkwOhEAc imltHfVJibScA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C50D8CE08E5; Wed, 9 Oct 2024 11:02:55 -0700 (PDT) From: "Paul E. McKenney" To: frederic@kernel.org, rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 1/5] refscale: Add test for sched_clock() Date: Wed, 9 Oct 2024 11:02:49 -0700 Message-Id: <20241009180253.777965-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> References: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit adds a "sched-clock" test for the sched_clock() function. Signed-off-by: Paul E. McKenney --- kernel/rcu/refscale.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c index 0db9db73f57f2..639d1cfc657b2 100644 --- a/kernel/rcu/refscale.c +++ b/kernel/rcu/refscale.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "rcu.h" @@ -498,6 +499,39 @@ static const struct ref_scale_ops acqrel_ops = { static volatile u64 stopopts; +static void ref_sched_clock_section(const int nloops) +{ + u64 x = 0; + int i; + + preempt_disable(); + for (i = nloops; i >= 0; i--) + x += sched_clock(); + preempt_enable(); + stopopts = x; +} + +static void ref_sched_clock_delay_section(const int nloops, const int udl, const int ndl) +{ + u64 x = 0; + int i; + + preempt_disable(); + for (i = nloops; i >= 0; i--) { + x += sched_clock(); + un_delay(udl, ndl); + } + preempt_enable(); + stopopts = x; +} + +static const struct ref_scale_ops sched_clock_ops = { + .readsection = ref_sched_clock_section, + .delaysection = ref_sched_clock_delay_section, + .name = "sched-clock" +}; + + static void ref_clock_section(const int nloops) { u64 x = 0; @@ -1083,8 +1117,8 @@ ref_scale_init(void) int firsterr = 0; static const struct ref_scale_ops *scale_ops[] = { &rcu_ops, &srcu_ops, RCU_TRACE_OPS RCU_TASKS_OPS &refcnt_ops, &rwlock_ops, - &rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops, &clock_ops, &jiffies_ops, - &typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops, + &rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops, &sched_clock_ops, &clock_ops, + &jiffies_ops, &typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops, }; if (!torture_init_begin(scale_type, verbose)) From patchwork Wed Oct 9 18:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13828945 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 43D2A1E1330; Wed, 9 Oct 2024 18:02:56 +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=1728496976; cv=none; b=tFZfeiPTN5/vor2e9JSgJWuojFRakjepZGetSufC28B4Rw5QF9ulddbTnl5By+bAGNoaI+HoZS45+unfc4+py9GX/mXk89KtQXA0E4arkQ4cSfld1arngOZisnykfMKjqrSg4ggpGCVd+0SQQVvnemQkvzGrC1bhqrasWtuhS9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728496976; c=relaxed/simple; bh=hlVg4FxJvZjim3cclQmUFm9AlIKDKpHkyjXaet4fHak=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OHb/AZ05oHa/581uIjo0mt8ttZX6NLLr0NXgYPsBJjFCZmyeXzawUf83h7BTmhk6H6lfirwNTop/LWFKa2lvqVimmTElepFf3sYSCI4Y8Hvt9mOefy+TyAnc4ACf3rYhK6AkvW8Z3ajs04R9+n9Uxw1tjmKPkNA5rc7AdAxX0Jk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MxB+ZOsU; 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="MxB+ZOsU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22BA8C4CED3; Wed, 9 Oct 2024 18:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728496976; bh=hlVg4FxJvZjim3cclQmUFm9AlIKDKpHkyjXaet4fHak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MxB+ZOsUeIBNIEItVwZ6Q8RH+xmkzldz/yfwUaEGSwgCHfI/Tgxnz7C3Ce1WCASvp jAdeJIz/K1dzPaUpjmedqC7cxIFXrxFTYN2XoiNE/TLqG3dQSmXOqjeSa39iNVwBTL pPdcKxCuX5yTZ59kK5dhekImu+daBXMwD9RZUHzNT+8o4p/R+FKahrZc0NrPR5pbNk oIn2OQbS2y2ztJyRz/2NXE0DXgJlgv7LDZsHM/N1WxMZTQz0R7GBhhFPXn97ZIj7Z2 64OOA9Aid/ih3wlIVM1SUsq0YsBpoH7ZpXLn+p6q6LZGZEDzqCs867wU9TY1xIF0XS 4PMqbP4n5rcpw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C7993CE0B68; Wed, 9 Oct 2024 11:02:55 -0700 (PDT) From: "Paul E. McKenney" To: frederic@kernel.org, rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 2/5] torture: Add --no-affinity parameter to kvm.sh Date: Wed, 9 Oct 2024 11:02:50 -0700 Message-Id: <20241009180253.777965-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> References: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In performance tests, it can be counter-productive to spread torture-test guest OSes across sockets. Plus the experimenter might have ideas about what CPUs individual guest OSes are to run on. This commit therefore adds a --no-affinity parameter to kvm.sh to prevent it from running taskset on its guest OSes. Signed-off-by: Paul E. McKenney --- .../rcutorture/bin/kvm-test-1-run-batch.sh | 43 ++++++++++--------- tools/testing/selftests/rcutorture/bin/kvm.sh | 6 +++ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh index c3808c490d92d..f87046b702d88 100755 --- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh +++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh @@ -56,27 +56,30 @@ do echo > $i/kvm-test-1-run-qemu.sh.out export TORTURE_AFFINITY= kvm-get-cpus-script.sh $T/cpuarray.awk $T/cpubatches.awk $T/cpustate - cat << ' ___EOF___' >> $T/cpubatches.awk - END { - affinitylist = ""; - if (!gotcpus()) { - print "echo No CPU-affinity information, so no taskset command."; - } else if (cpu_count !~ /^[0-9][0-9]*$/) { - print "echo " scenario ": Bogus number of CPUs (old qemu-cmd?), so no taskset command."; - } else { - affinitylist = nextcpus(cpu_count); - if (!(affinitylist ~ /^[0-9,-][0-9,-]*$/)) - print "echo " scenario ": Bogus CPU-affinity information, so no taskset command."; - else if (!dumpcpustate()) - print "echo " scenario ": Could not dump state, so no taskset command."; - else - print "export TORTURE_AFFINITY=" affinitylist; + if test -z "${TORTURE_NO_AFFINITY}" + then + cat << ' ___EOF___' >> $T/cpubatches.awk + END { + affinitylist = ""; + if (!gotcpus()) { + print "echo No CPU-affinity information, so no taskset command."; + } else if (cpu_count !~ /^[0-9][0-9]*$/) { + print "echo " scenario ": Bogus number of CPUs (old qemu-cmd?), so no taskset command."; + } else { + affinitylist = nextcpus(cpu_count); + if (!(affinitylist ~ /^[0-9,-][0-9,-]*$/)) + print "echo " scenario ": Bogus CPU-affinity information, so no taskset command."; + else if (!dumpcpustate()) + print "echo " scenario ": Could not dump state, so no taskset command."; + else + print "export TORTURE_AFFINITY=" affinitylist; + } } - } - ___EOF___ - cpu_count="`grep '# TORTURE_CPU_COUNT=' $i/qemu-cmd | sed -e 's/^.*=//'`" - affinity_export="`awk -f $T/cpubatches.awk -v cpu_count="$cpu_count" -v scenario=$i < /dev/null`" - $affinity_export + ___EOF___ + cpu_count="`grep '# TORTURE_CPU_COUNT=' $i/qemu-cmd | sed -e 's/^.*=//'`" + affinity_export="`awk -f $T/cpubatches.awk -v cpu_count="$cpu_count" -v scenario=$i < /dev/null`" + $affinity_export + fi kvm-test-1-run-qemu.sh $i >> $i/kvm-test-1-run-qemu.sh.out 2>&1 & done for i in $runfiles diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh index 7af73ddc148d1..42e5e8597a1a6 100755 --- a/tools/testing/selftests/rcutorture/bin/kvm.sh +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh @@ -42,6 +42,7 @@ TORTURE_JITTER_STOP="" TORTURE_KCONFIG_KASAN_ARG="" TORTURE_KCONFIG_KCSAN_ARG="" TORTURE_KMAKE_ARG="" +TORTURE_NO_AFFINITY="" TORTURE_QEMU_MEM=512 torture_qemu_mem_default=1 TORTURE_REMOTE= @@ -82,6 +83,7 @@ usage () { echo " --kmake-arg kernel-make-arguments" echo " --mac nn:nn:nn:nn:nn:nn" echo " --memory megabytes|nnnG" + echo " --no-affinity" echo " --no-initrd" echo " --qemu-args qemu-arguments" echo " --qemu-cmd qemu-system-..." @@ -220,6 +222,9 @@ do torture_qemu_mem_default= shift ;; + --no-affinity) + TORTURE_NO_AFFINITY="no-affinity" + ;; --no-initrd) TORTURE_INITRD=""; export TORTURE_INITRD ;; @@ -417,6 +422,7 @@ TORTURE_KCONFIG_KASAN_ARG="$TORTURE_KCONFIG_KASAN_ARG"; export TORTURE_KCONFIG_K TORTURE_KCONFIG_KCSAN_ARG="$TORTURE_KCONFIG_KCSAN_ARG"; export TORTURE_KCONFIG_KCSAN_ARG TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG"; export TORTURE_KMAKE_ARG TORTURE_MOD="$TORTURE_MOD"; export TORTURE_MOD +TORTURE_NO_AFFINITY="$TORTURE_NO_AFFINITY"; export TORTURE_NO_AFFINITY TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD"; export TORTURE_QEMU_CMD TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE"; export TORTURE_QEMU_INTERACTIVE TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC"; export TORTURE_QEMU_MAC From patchwork Wed Oct 9 18:02:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13828947 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 72CCD1E1A07; Wed, 9 Oct 2024 18:02:56 +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=1728496976; cv=none; b=JNM2MRTD27o5XS83HtCCZCy9PWpY0L8IORDq41EomdqSdgC6eqcA5miIuFqT/eQctwiqlMQMkf/IGO8oOMh0a69qGzWbvGqegTrPX5jzHQfPjD1EDoQS5OZocXGjEdwWFZ7XXZoG6ut92FAonZsmUOaL9L5ugcQAqfPfTKKqHGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728496976; c=relaxed/simple; bh=oFO/7qMuKGNQ5tH6biPfmQ7RINtkm2aVrrRixQVm2/A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t7BJDail+b25Olaw4Mx9br4R09kmSKdZK9zxzP3CDF0sbGzholqA4eCJfZ/Cg8LAi2zFZeZWnmT2kWAWDvlxWBGn5f1DgL5c4f7Ur3nheaL82Iguj5gnwbByphciQ+IlkL2ktfF1gWd0NcEzhwpxNPnc9nIFeyFDJHOW6UnGJHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nIK/bB2Q; 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="nIK/bB2Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E632C4CED2; Wed, 9 Oct 2024 18:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728496976; bh=oFO/7qMuKGNQ5tH6biPfmQ7RINtkm2aVrrRixQVm2/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nIK/bB2QCU64nmffD0sqhTZlfydtXU1yOXRCqwI6I/aT1CXu4TX7AXx/e8Nv3jshm whwpQ66RfG6wCRT1RbR0j7ZOJ1AVLxhk6eIuBjTilVrJzWDAETAYAvlz097PAbeopv K5Qw/Wx/5qXHCvl1NBSAKovpp8MjHMQXFvTNZdfzGZib5XRlgJppWNPyz2jI1TJdhp ptT0pIb3dygH+SZmefnjROwsDNzXrhgYAlqpHGyOkyiklvSoNOXilZ4ZTekiEYpGev IDS4yolkqQs7MXmD6MBi5GhnjkMNMAFWk4PxytelgiHLswC/qdUAbpgWvv/XeuFxWG wQVM0KMxchtsA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id CA5CECE0BB1; Wed, 9 Oct 2024 11:02:55 -0700 (PDT) From: "Paul E. McKenney" To: frederic@kernel.org, rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 3/5] refscale: Correct affinity check Date: Wed, 9 Oct 2024 11:02:51 -0700 Message-Id: <20241009180253.777965-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> References: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The current affinity check works fine until there are more reader processes than CPUs, at which point the affinity check is looking for non-existent CPUs. This commit therefore applies the same modulus to the check as is present in the set_cpus_allowed_ptr() call. Signed-off-by: Paul E. McKenney --- kernel/rcu/refscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c index 639d1cfc657b2..af32331ef645a 100644 --- a/kernel/rcu/refscale.c +++ b/kernel/rcu/refscale.c @@ -863,7 +863,7 @@ ref_scale_reader(void *arg) goto end; // Make sure that the CPU is affinitized appropriately during testing. - WARN_ON_ONCE(raw_smp_processor_id() != me); + WARN_ON_ONCE(raw_smp_processor_id() != me % nr_cpu_ids); WRITE_ONCE(rt->start_reader, 0); if (!atomic_dec_return(&n_started)) From patchwork Wed Oct 9 18:02:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13828946 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 72D261E1A0A; Wed, 9 Oct 2024 18:02:56 +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=1728496976; cv=none; b=sUWlNBrW3ZdWVKA1DwgVQ49cjACEcp6GMngSzISoIi6c6xyWaI1G1Q4IfPlvp3ABtgpxhisdLitxeWz92+R93jeJcI5bQQ1CwEyVSrd8SuhAP/Y4p6l5j6WixM3UcrZ5iKSP/kapl8A2z4XESf/TqkeIK4rflQ2VrqSr9mHPLt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728496976; c=relaxed/simple; bh=YDPwQSF2/texsz3QxQwBxVHxyCv65A5M1YAGUFQYwR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oQdlwNfqjBfhBjtWqPmQrkTVTTLQznx5J/4KCjNjYtErtjFiEcSJJvyHUC9dMG0oM06TCEMUlf89Th03Fn5e/WcWRwjEm9IIdUqheDGRrKMv2bkUhASrFsuEohg4tzl0OBtRS2nqkb0E3CeilT91jg2T2gSUjXJh5DsT1mSUKAs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tL4UPmYq; 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="tL4UPmYq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33C16C4CED4; Wed, 9 Oct 2024 18:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728496976; bh=YDPwQSF2/texsz3QxQwBxVHxyCv65A5M1YAGUFQYwR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tL4UPmYq8ykFNpHwuW6EaqTFHfj2slNtqv3fAAxBcFLNpOhXKY/kqKTtXjed1HL85 TK8EXgV/EFlCS5HyCeRSGmzHZtU6K64+ueqJb+/U5fp8DSzOU+s8+ll+qPJOVIDX7i tNT0isdMfSvE19+j+Xf4Bem7HA9zDNzdzUcXh+G+AotO1LL6fFuqDBhONADDo3BJKx mD9oip3E/tnEuTAxRrrjEdJtfIqTKViFvuh6KGN4PD16+UdI+YyCG735em0K/bbmp7 huzXQMx7IqavmPal6SMBrB5z6vLRtsM6MJOhDyIuHJQYAE5yPH1LJ6FUqZBDjSPZqS IWhNISBNuCjrg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id CCDA4CE0DD1; Wed, 9 Oct 2024 11:02:55 -0700 (PDT) From: "Paul E. McKenney" To: frederic@kernel.org, rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 4/5] rcuscale: Add guest_os_delay module parameter Date: Wed, 9 Oct 2024 11:02:52 -0700 Message-Id: <20241009180253.777965-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> References: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit adds a guest_os_delay module parameter that extends warm-up and cool-down the specified number of seconds before and after the series of test runs. This allows the data-collection intervals from any given rcuscale guest OSes to line up with active periods in the other rcuscale guest OSes, and also allows the thermal warm-up period required to obtain consistent results from one test to the next. Signed-off-by: Paul E. McKenney --- kernel/rcu/refscale.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c index af32331ef645a..be66e5a67ee19 100644 --- a/kernel/rcu/refscale.c +++ b/kernel/rcu/refscale.c @@ -76,6 +76,9 @@ MODULE_PARM_DESC(scale_type, "Type of test (rcu, srcu, refcnt, rwsem, rwlock."); torture_param(int, verbose, 0, "Enable verbose debugging printk()s"); torture_param(int, verbose_batched, 0, "Batch verbose debugging printk()s"); +// Number of seconds to extend warm-up and cool-down for multiple guest OSes +torture_param(long, guest_os_delay, 0, + "Number of seconds to extend warm-up/cool-down for multiple guest OSes."); // Wait until there are multiple CPUs before starting test. torture_param(int, holdoff, IS_BUILTIN(CONFIG_RCU_REF_SCALE_TEST) ? 10 : 0, "Holdoff time before test start (s)"); @@ -835,6 +838,18 @@ static void rcu_scale_one_reader(void) cur_ops->delaysection(loops, readdelay / 1000, readdelay % 1000); } +// Warm up cache, or, if needed run a series of rcu_scale_one_reader() +// to allow multiple rcuscale guest OSes to collect mutually valid data. +static void rcu_scale_warm_cool(void) +{ + unsigned long jdone = jiffies + (guest_os_delay > 0 ? guest_os_delay * HZ : -1); + + do { + rcu_scale_one_reader(); + cond_resched(); + } while (time_before(jiffies, jdone)); +} + // Reader kthread. Repeatedly does empty RCU read-side // critical section, minimizing update-side interference. static int @@ -991,6 +1006,7 @@ static int main_func(void *arg) schedule_timeout_uninterruptible(1); // Start exp readers up per experiment + rcu_scale_warm_cool(); for (exp = 0; exp < nruns && !torture_must_stop(); exp++) { if (torture_must_stop()) goto end; @@ -1021,6 +1037,7 @@ static int main_func(void *arg) result_avg[exp] = div_u64(1000 * process_durations(nreaders), nreaders * loops); } + rcu_scale_warm_cool(); // Print the average of all experiments SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n"); From patchwork Wed Oct 9 18:02:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13828949 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 9B1291E1A14; Wed, 9 Oct 2024 18:02:56 +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=1728496976; cv=none; b=IXoLV5ZnIJ0rY9orzLrM+uqCMfwz70c8Mn/s+g+5SeS1SJTKnGdJl6BBFfruIoeLcw+yH4hbr7FURBSllZZ3Wy3TGvzV6mCqIS9lPMqXif8oljGM3M6vsVHw5cMP4H9RwONJf6XyUahTu4a5INOqyXBBBLNfINoJHS40qW/YlDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728496976; c=relaxed/simple; bh=8bI82NBJXXQerlOKPpjrxuDV+Y+lBIYfZla/GLPfrVk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yb24VGbWDvF+DjU00SkNy4KZQlbXzagtbVJPWpEcd7qkBWuovTRq6FBlcwJ4ME2AZh6O/SklHcJocjufOwvUZDh9hsCzkJ6KznSqbqwYn7MXXS8X4p+f4yN4HZIMZW+Fnm926nUzT9yZ78THZy89rmE6WWd/46kb7n37wj3RC48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hAqYAhVs; 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="hAqYAhVs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FDDFC4CED5; Wed, 9 Oct 2024 18:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728496976; bh=8bI82NBJXXQerlOKPpjrxuDV+Y+lBIYfZla/GLPfrVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hAqYAhVsgWurbGEIaXzR9RW8pea34iKeT0zxT44wWSI13+xqFWG8yMt7eK/Zp3ULf Ylyy14DqsrJTTxAbJtjVFjGxQbqVv/XmX0VSa9qK2aWhUPhPAwsz4EYntCtAYDob0W IDoR+BX+Pnvmi6CRI7pEJvxHFk+80VfHr00ek0Iedswg8R+X1pZG6H5YPbKK4pA6zr ih+S69AZqRgUgj6WMYokpp9FBCVvppOjsHf6IbmxSspSCCi8syCmDNX3TEDC7gXeP6 h+3QuaEmR8i+G928W0XjhBDR6DNQ1ijyUAxlHGKh9ONSSz53RrOlxF39UKbXX0fPDB Vsu+jgCORzG3Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id CFA38CE0E61; Wed, 9 Oct 2024 11:02:55 -0700 (PDT) From: "Paul E. McKenney" To: frederic@kernel.org, rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 5/5] rcutorture: Avoid printing cpu=-1 for no-fault RCU boost failure Date: Wed, 9 Oct 2024 11:02:53 -0700 Message-Id: <20241009180253.777965-5-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> References: <51cccc37-5139-497c-92e3-6a20e17939a1@paulmck-laptop> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If a CPU runs throughout the stalled grace period without passing through a quiescent state, RCU priority boosting cannot help. The rcu_torture_boost_failed() function therefore prints a message flagging the first such CPU. However, if the stall was instead due to (for example) RCU's grace-period kthread being starved of CPU, there will be no such CPU, causing rcu_check_boost_fail() to instead pass back -1 through its cpup CPU-pointer parameter. Therefore, the current message complains about a mythical CPU -1. This commit therefore checks for this situation, and notes that all CPUs have passed through a quiescent state. Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index b4cb7623a8bfc..3ac8c69dd5bc9 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -1061,8 +1061,13 @@ static bool rcu_torture_boost_failed(unsigned long gp_state, unsigned long *star // At most one persisted message per boost test. j = jiffies; lp = READ_ONCE(last_persist); - if (time_after(j, lp + mininterval) && cmpxchg(&last_persist, lp, j) == lp) - pr_info("Boost inversion persisted: No QS from CPU %d\n", cpu); + if (time_after(j, lp + mininterval) && + cmpxchg(&last_persist, lp, j) == lp) { + if (cpu < 0) + pr_info("Boost inversion persisted: QS from all CPUs\n"); + else + pr_info("Boost inversion persisted: No QS from CPU %d\n", cpu); + } return false; // passed on a technicality } VERBOSE_TOROUT_STRING("rcu_torture_boost boosting failed");