From patchwork Mon Jul 17 18:18:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13316235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E89DEB64DC for ; Mon, 17 Jul 2023 18:18:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231853AbjGQSSk (ORCPT ); Mon, 17 Jul 2023 14:18:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231793AbjGQSSf (ORCPT ); Mon, 17 Jul 2023 14:18:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 092671700; Mon, 17 Jul 2023 11:18:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 916F7611DC; Mon, 17 Jul 2023 18:18:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2A34C433C7; Mon, 17 Jul 2023 18:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689617903; bh=5yZnYA/vYH5K7ZYo4itQZ34JbDb64O4rGCUZ6y8VJ9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C6GIMua+brOodMq7+iCLtjYjLpI4ibvqi1J3nVXHWPyDduASQ+Xh+3oQSa4v8O8e7 8oXCUzQgNtwAfUFwWfqPnB1wV9IvTJDnAbRW69Wm3OFDArHJmvJ74Ytj7ucDmHi97d uElDQM7sw0ZZenGPbp01W7j24L3g1VspxVR/MFmUgv+MmhBoQi1SY5ubBSDQkhFmH8 ZIAQxleBE/6tpMNZlpWZq3vxm29G6HprQnisVF/Tr8VRA6cUOjEmM99SRxOUOJ0L86 ei4rHA4PwBD1yO7R/0dExfc5i6WjQDB77286MTEK2KqK12BVw9zO8XW0sXyVY0O/UR bkPForBmE6A/w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A836DCE03F1; Mon, 17 Jul 2023 11:18:22 -0700 (PDT) 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" Subject: [PATCH rcu 1/4] torture: Scale scftorture memory based on number of CPUs Date: Mon, 17 Jul 2023 11:18:17 -0700 Message-Id: <20230717181820.1098541-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <38be0135-a7a4-4c16-b2c6-1b3817c3067f@paulmck-laptop> References: <38be0135-a7a4-4c16-b2c6-1b3817c3067f@paulmck-laptop> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org As the number of CPUs increases, the number of outstanding no-wait smp_call_function() handlers also increases, so that the default of 2G of memory is not always sufficient on 80-CPU systems. This commit therefore scales the amount of memory specified to qemu based on the number of CPUs specified to the scftorture test instance. Signed-off-by: Paul E. McKenney --- tools/testing/selftests/rcutorture/bin/torture.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh index 5a2ae2264403..9fa6526067f0 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -376,8 +376,10 @@ fi if test "$do_scftorture" = "yes" then + # Scale memory based on the number of CPUs. + scfmem=$((2+HALF_ALLOTED_CPUS/16)) torture_bootargs="scftorture.nthreads=$HALF_ALLOTED_CPUS torture.disable_onoff_at_boot csdlock_debug=1" - torture_set "scftorture" tools/testing/selftests/rcutorture/bin/kvm.sh --torture scf --allcpus --duration "$duration_scftorture" --configs "$configs_scftorture" --kconfig "CONFIG_NR_CPUS=$HALF_ALLOTED_CPUS" --memory 2G --trust-make + torture_set "scftorture" tools/testing/selftests/rcutorture/bin/kvm.sh --torture scf --allcpus --duration "$duration_scftorture" --configs "$configs_scftorture" --kconfig "CONFIG_NR_CPUS=$HALF_ALLOTED_CPUS" --memory ${scfmem}G --trust-make fi if test "$do_rt" = "yes" From patchwork Mon Jul 17 18:18:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13316234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D4E4C001DE for ; Mon, 17 Jul 2023 18:18:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231708AbjGQSSj (ORCPT ); Mon, 17 Jul 2023 14:18:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231730AbjGQSSf (ORCPT ); Mon, 17 Jul 2023 14:18:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D3B41701; Mon, 17 Jul 2023 11:18:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A1A31611E9; Mon, 17 Jul 2023 18:18:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A8CEC433C8; Mon, 17 Jul 2023 18:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689617903; bh=kOL1Zapyu+0MBMzzQqJDacaa50DKEhK1uQVmnZTCnQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CLMMENSAlauGHHkJchd64UixIimj8OJg9ZLFeIoziZqM3aKwBgkk3OEuhNTxbtRlh dqAGx/9rPN0279PCKUbxno0BSqA/CVNOrvWMBGIm1r2XUr+umK+atSNrov1EiKP5VP DlRaHqW4dztQduvXmWBTX7QasopCbVzfem/fcUwagPF2BKAgHUw/eTcD9dXMedbOHT +8ZbCouvpqRP+zEI+Y10OTRP72eQaigg0DeenPo3Kqk3jmnYBcdYVXk3QtIrZU2HA8 cl7VVKTbVbgvnGvE04TlxKc4pB/STaqf3t1L0pedF6mojy/q/VWCPrVy1iUaFaHvG1 fl2N02j7GZVNg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AB6ADCE04CD; Mon, 17 Jul 2023 11:18:22 -0700 (PDT) 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" Subject: [PATCH rcu 2/4] scftorture: Forgive memory-allocation failure if KASAN Date: Mon, 17 Jul 2023 11:18:18 -0700 Message-Id: <20230717181820.1098541-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <38be0135-a7a4-4c16-b2c6-1b3817c3067f@paulmck-laptop> References: <38be0135-a7a4-4c16-b2c6-1b3817c3067f@paulmck-laptop> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org Kernels built with CONFIG_KASAN=y quarantine newly freed memory in order to better detect use-after-free errors. However, this can exhaust memory more quickly in allocator-heavy tests, which can result in spurious scftorture failure. This commit therefore forgives memory-allocation failure in kernels built with CONFIG_KASAN=y, but continues counting the errors for use in detailed test-result analyses. Signed-off-by: Paul E. McKenney --- kernel/scftorture.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/scftorture.c b/kernel/scftorture.c index 5d113aa59e77..83c33ba0ca7e 100644 --- a/kernel/scftorture.c +++ b/kernel/scftorture.c @@ -171,7 +171,8 @@ static void scf_torture_stats_print(void) scfs.n_all_wait += scf_stats_p[i].n_all_wait; } if (atomic_read(&n_errs) || atomic_read(&n_mb_in_errs) || - atomic_read(&n_mb_out_errs) || atomic_read(&n_alloc_errs)) + atomic_read(&n_mb_out_errs) || + (!IS_ENABLED(CONFIG_KASAN) && atomic_read(&n_alloc_errs))) bangstr = "!!! "; pr_alert("%s %sscf_invoked_count %s: %lld resched: %lld single: %lld/%lld single_ofl: %lld/%lld single_rpc: %lld single_rpc_ofl: %lld many: %lld/%lld all: %lld/%lld ", SCFTORT_FLAG, bangstr, isdone ? "VER" : "ver", invoked_count, scfs.n_resched, @@ -323,7 +324,8 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra preempt_disable(); if (scfsp->scfs_prim == SCF_PRIM_SINGLE || scfsp->scfs_wait) { scfcp = kmalloc(sizeof(*scfcp), GFP_ATOMIC); - if (WARN_ON_ONCE(!scfcp)) { + if (!scfcp) { + WARN_ON_ONCE(!IS_ENABLED(CONFIG_KASAN)); atomic_inc(&n_alloc_errs); } else { scfcp->scfc_cpu = -1; From patchwork Mon Jul 17 18:18:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13316236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0A30C001DF for ; Mon, 17 Jul 2023 18:18:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231791AbjGQSSk (ORCPT ); Mon, 17 Jul 2023 14:18:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231795AbjGQSSf (ORCPT ); Mon, 17 Jul 2023 14:18:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D4CE1702; Mon, 17 Jul 2023 11:18:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9E63611E8; Mon, 17 Jul 2023 18:18:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16307C433C9; Mon, 17 Jul 2023 18:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689617903; bh=l6fjQzSsJ9XsALv/Md6uxcktla62nAu93vPkfT4e3qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=etxS+i0iNTnyaCWJcK4R0j8eUpxNo6zB/FtCsE4dKbjDj/mpdlZ1gGxaHB4kO1DzK ISDzkRTISi+vvI/rBORGbI4XDaSCALn7WAO2tnE3F0LKt9sMpY0K+z6XsaLN31OYPB 502fTz8IddsJ0aliVyXmdi38ZaINNT5Ku37hSl/IsRmfud0EG8b5DZhMgDdGPvMiro KXlNEiqEHyOguUBRUJ/NpYncmwwY5nom9e28PpHTBSEGkyz8wDDzz3l0or7/m/L0BN b6h3M8jNUjvYDUKhF8hNUQ9QX50rx70/Rg7zJULOWxLsqVStAN1tuLsx90wQ0yiJt3 3Uiv3taX/p/Kw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AE001CE0806; Mon, 17 Jul 2023 11:18:22 -0700 (PDT) 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" Subject: [PATCH rcu 3/4] scftorture: Pause testing after memory-allocation failure Date: Mon, 17 Jul 2023 11:18:19 -0700 Message-Id: <20230717181820.1098541-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <38be0135-a7a4-4c16-b2c6-1b3817c3067f@paulmck-laptop> References: <38be0135-a7a4-4c16-b2c6-1b3817c3067f@paulmck-laptop> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org The scftorture test can quickly execute a large number of calls to no-wait smp_call_function(), each of which holds a block of memory until the corresponding handler is invoked. Especially when the longwait module parameter is specified, this can chew up an arbitrarily large amount of memory. This commit therefore blocks after each memory-allocation failure, with the duration a function of longwait. Signed-off-by: Paul E. McKenney --- kernel/scftorture.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/scftorture.c b/kernel/scftorture.c index 83c33ba0ca7e..59032aaccd18 100644 --- a/kernel/scftorture.c +++ b/kernel/scftorture.c @@ -313,6 +313,7 @@ static void scf_handler_1(void *scfc_in) // Randomly do an smp_call_function*() invocation. static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_random_state *trsp) { + bool allocfail = false; uintptr_t cpu; int ret = 0; struct scf_check *scfcp = NULL; @@ -327,6 +328,7 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra if (!scfcp) { WARN_ON_ONCE(!IS_ENABLED(CONFIG_KASAN)); atomic_inc(&n_alloc_errs); + allocfail = true; } else { scfcp->scfc_cpu = -1; scfcp->scfc_wait = scfsp->scfs_wait; @@ -433,7 +435,9 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra cpus_read_unlock(); else preempt_enable(); - if (!(torture_random(trsp) & 0xfff)) + if (allocfail) + schedule_timeout_idle((1 + longwait) * HZ); // Let no-wait handlers complete. + else if (!(torture_random(trsp) & 0xfff)) schedule_timeout_uninterruptible(1); } From patchwork Mon Jul 17 18:18:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13316237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34751C001DE for ; Mon, 17 Jul 2023 18:18:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231753AbjGQSSm (ORCPT ); Mon, 17 Jul 2023 14:18:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231686AbjGQSSg (ORCPT ); Mon, 17 Jul 2023 14:18:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39AD41703; Mon, 17 Jul 2023 11:18:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C0E0D611EB; Mon, 17 Jul 2023 18:18:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28798C433CD; Mon, 17 Jul 2023 18:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689617903; bh=9le1Yp2JqpCktuy/Ds5vAtG09Rigc3XXHuPHaCwxaUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XiLrTR1Hxqlw5Mvng+sDv4ZxMSlNGj1ERs+NHyMPyNOyHi0NQw3n19yWc3iMT6xtu XUztLwl/+1x2MlS7gBaqT7wTrfgvqzltAT0hsd2fM0nbbQgg6PfckN1d6LB4ewsHfc oSyA0ubQXFSlL+RIpq7H2JO07YClNxD4sHM1CoioR/Z0iaClvUAsZHmulFWOtHlbjK CCxEvlpctS7aGWnmFoU+hk70oulENHpNkHdaC8+5PzLQmyTVYr3UKX0gMeGG3DCpNJ b1B3vQSypoY9Ivx4kvgh9D+8dLiKTTun6NFfw69g87Kqw4vOmRtnUu515hW2JGmH6t dgG6kSUJm/Jjw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B07B7CE0836; Mon, 17 Jul 2023 11:18:22 -0700 (PDT) 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" Subject: [PATCH rcu 4/4] scftorture: Add CONFIG_PREEMPT_DYNAMIC=n to NOPREEMPT scenario Date: Mon, 17 Jul 2023 11:18:20 -0700 Message-Id: <20230717181820.1098541-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <38be0135-a7a4-4c16-b2c6-1b3817c3067f@paulmck-laptop> References: <38be0135-a7a4-4c16-b2c6-1b3817c3067f@paulmck-laptop> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org It is no longer possible to build a kernel with a preemption-disabled RCU without use of CONFIG_PREEMPT_DYNAMIC=n. This commit therefore adds CONFIG_PREEMPT_DYNAMIC=n to the scf torture type's NOPREEMPT scenario file. Signed-off-by: Paul E. McKenney --- tools/testing/selftests/rcutorture/configs/scf/NOPREEMPT | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/rcutorture/configs/scf/NOPREEMPT b/tools/testing/selftests/rcutorture/configs/scf/NOPREEMPT index 3a59346b3de7..6133f54ce2a7 100644 --- a/tools/testing/selftests/rcutorture/configs/scf/NOPREEMPT +++ b/tools/testing/selftests/rcutorture/configs/scf/NOPREEMPT @@ -2,6 +2,8 @@ CONFIG_SMP=y CONFIG_PREEMPT_NONE=y CONFIG_PREEMPT_VOLUNTARY=n CONFIG_PREEMPT=n +CONFIG_PREEMPT_DYNAMIC=n +#CHECK#CONFIG_PREEMPT_RCU=n CONFIG_HZ_PERIODIC=n CONFIG_NO_HZ_IDLE=n CONFIG_NO_HZ_FULL=y