From patchwork Sun Aug 27 21:46:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13367402 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 3421EC83F01 for ; Sun, 27 Aug 2023 21:47:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbjH0Vq6 (ORCPT ); Sun, 27 Aug 2023 17:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230344AbjH0Vqc (ORCPT ); Sun, 27 Aug 2023 17:46:32 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0823124 for ; Sun, 27 Aug 2023 14:46:29 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-7927f36120cso82591639f.1 for ; Sun, 27 Aug 2023 14:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1693172789; x=1693777589; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6mcwO+IbeJ6pSmZ/BjxjTTVqEmFcInv2K/OfpA2NMnU=; b=Az9zw+ATe3PlF3OhMMTM/WWPXUwi/94KCKAGjXJD7qM6Mr6OrjUiOn1sH+8o/EsaOn cdsc5A9xXnfw+YW2bjmLdScXX0nuHHoHS6oiYGmQAQVOSwLzL/56I4CuEJMsWm4tQFNy iS5GrBPzUdWHXbboY3hnu8CQNg2WGc4D72uA4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693172789; x=1693777589; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6mcwO+IbeJ6pSmZ/BjxjTTVqEmFcInv2K/OfpA2NMnU=; b=Q4IS50CjgDPBzsMl99s1I7VpB2CzxpZbrvOPKC6C5VRFiX5A/45DYa05SbdkU1VvFk chVR835Mj+UIfj9uZqzERjAeKk7q/b/RqpT6CkcM1zTHNYf/MBF/sBMIis4Fhm45gh8/ ttR5qwQ6Wg4kUoQOj0MyB5OvXJ+fY0KExnktUIQ0jdqsioPav2fTp3qU93UAPkrfq2M1 EG71h/Uwxs2qaeFVIZk/IyX3inkMKkwuNO6Kj1cXWBpb2890PekJvYz5ufjuI1Zs1D/m n7aJuulh1jbwbpPSnAf9hMyqNVTgKTIpYBkiX7mCN0UmOFcdcvOEWFORiHjo9vTue/pE 4/uw== X-Gm-Message-State: AOJu0Yw3l0J2mO8cYglwVer54c+jBRUnff0DLSLXb2vmZ15sdjzKCHKo xndz239rPoYOz0n9pflPmwRqHg== X-Google-Smtp-Source: AGHT+IE2PDpFOgkg1eIeYAvpTEAZMfuuiEANqDy0KOpHgWijDj9rwgdkP6amMl/prwYlxtPA6KcOrg== X-Received: by 2002:a6b:f214:0:b0:790:ff32:eb3 with SMTP id q20-20020a6bf214000000b00790ff320eb3mr17389815ioh.17.1693172788924; Sun, 27 Aug 2023 14:46:28 -0700 (PDT) Received: from joelboxx5.c.googlers.com.com (156.190.123.34.bc.googleusercontent.com. [34.123.190.156]) by smtp.gmail.com with ESMTPSA id d13-20020a02a48d000000b0042b1cd4c096sm1992515jam.74.2023.08.27.14.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Aug 2023 14:46:28 -0700 (PDT) From: "Joel Fernandes (Google)" To: stable@vger.kernel.org, "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Shuah Khan Cc: Joel Fernandes , rcu@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5.10 1/2] torture: Avoid torture-test reboot loops Date: Sun, 27 Aug 2023 21:46:20 +0000 Message-ID: <20230827214622.240001-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: "Paul E. McKenney" [ Upstream commit 10f84c2cfb5045e37d78cb5d4c8e8321e06ae18f ] Currently, the various torture tests sometimes react to an early-boot bug by rebooting. This is almost always counterproductive, needlessly consuming CPU time and bloating the console log. This commit therefore adds the "-no-reboot" argument to qemu so that reboot requests will cause qemu to exit. Signed-off-by: Paul E. McKenney Signed-off-by: Joel Fernandes (Google) --- tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh index 6dc2b49b85ea..bdd747dc61f2 100755 --- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh @@ -9,7 +9,7 @@ # # Usage: kvm-test-1-run.sh config builddir resdir seconds qemu-args boot_args # -# qemu-args defaults to "-enable-kvm -nographic", along with arguments +# qemu-args defaults to "-enable-kvm -nographic -no-reboot", along with arguments # specifying the number of CPUs and other options # generated from the underlying CPU architecture. # boot_args defaults to value returned by the per_version_boot_params @@ -132,7 +132,7 @@ then fi # Generate -smp qemu argument. -qemu_args="-enable-kvm -nographic $qemu_args" +qemu_args="-enable-kvm -nographic -no-reboot $qemu_args" cpu_count=`configNR_CPUS.sh $resdir/ConfigFragment` cpu_count=`configfrag_boot_cpus "$boot_args" "$config_template" "$cpu_count"` if test "$cpu_count" -gt "$TORTURE_ALLOTED_CPUS" From patchwork Sun Aug 27 21:46:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13367403 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 E6B2DC83F17 for ; Sun, 27 Aug 2023 21:47:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230344AbjH0Vq6 (ORCPT ); Sun, 27 Aug 2023 17:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbjH0Vqd (ORCPT ); Sun, 27 Aug 2023 17:46:33 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4BA811A for ; Sun, 27 Aug 2023 14:46:30 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-76c64da0e46so90203239f.0 for ; Sun, 27 Aug 2023 14:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1693172790; x=1693777590; 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; bh=EOVv5jytzvUysYuiOU5na6ju5GFr2D3rnZDe2oaI3wE=; b=LWnCDndyxijVL6m9XTaHolTRGKyhlh1Tqy8oXCQ+HmoSqGjhXv+HRqVlWVJ0WyMD2R ebGOexZUZm3j1L4LsWqKNhYf3KjnKXIO8gT7bSl8RMahake/AfwJkB6ys8DMFClZJoMD FrFKaCR41sGFexh8cPNIFQN/QxiSWMXzOQ54g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693172790; x=1693777590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EOVv5jytzvUysYuiOU5na6ju5GFr2D3rnZDe2oaI3wE=; b=YU2ISWqR+lG32KfV3oofvetHpOLSAVsxycQcRn+JPaYArd3sIlsXs/qBeIPgB7ZASQ Ms1KOJPTjyjNhpyAUZjh63jiBOJbkKFuu/4aqzxpYZdQmAR98zAeu8T4jATGL/yrw0zc F8azhbWFbO3LE20zJBMZcQk8ra5gK0Uh2/fnIy6q9SPNPaQUB6wvv+FYLE6FWWjkcEUI AYm7wHc4AiJep/Pv+34iBGejJRGybKwVwYXaQ7DSx9TW45vVn7mTf4nUCm3ReN9RdSFb pREGALlM2r+li7pfY+YFhopy3PVEC0+0gneS+Ypt2dqYI2l8/PtEo/mX6Ygw3twpeeFw qUYw== X-Gm-Message-State: AOJu0YykPP/DqEaQnp3aA261JNnb/I5GT1cDMRE9imD5/CEKfXJ9TXX1 7GIAYl0mfHrDgGcV5NrgxzvgWA== X-Google-Smtp-Source: AGHT+IGOxnQO6va/2JkAqJJhnNkpAcdZqRJekTFUkO5JXnXKKoR4610962OnVgcKGga5zxGpuViZpw== X-Received: by 2002:a5d:8550:0:b0:787:ff98:c38c with SMTP id b16-20020a5d8550000000b00787ff98c38cmr15962029ios.10.1693172790194; Sun, 27 Aug 2023 14:46:30 -0700 (PDT) Received: from joelboxx5.c.googlers.com.com (156.190.123.34.bc.googleusercontent.com. [34.123.190.156]) by smtp.gmail.com with ESMTPSA id d13-20020a02a48d000000b0042b1cd4c096sm1992515jam.74.2023.08.27.14.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Aug 2023 14:46:29 -0700 (PDT) From: "Joel Fernandes (Google)" To: stable@vger.kernel.org, "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5.10 2/2] rcu: Prevent expedited GP from enabling tick on offline CPU Date: Sun, 27 Aug 2023 21:46:21 +0000 Message-ID: <20230827214622.240001-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog In-Reply-To: <20230827214622.240001-1-joel@joelfernandes.org> References: <20230827214622.240001-1-joel@joelfernandes.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: "Paul E. McKenney" [ Upstream commit 147f04b14adde831eb4a0a1e378667429732f9e8 ] If an RCU expedited grace period starts just when a CPU is in the process of going offline, so that the outgoing CPU has completed its pass through stop-machine but has not yet completed its final dive into the idle loop, RCU will attempt to enable that CPU's scheduling-clock tick via a call to tick_dep_set_cpu(). For this to happen, that CPU has to have been online when the expedited grace period completed its CPU-selection phase. This is pointless: The outgoing CPU has interrupts disabled, so it cannot take a scheduling-clock tick anyway. In addition, the tick_dep_set_cpu() function's eventual call to irq_work_queue_on() will splat as follows: smpboot: CPU 1 is now offline WARNING: CPU: 6 PID: 124 at kernel/irq_work.c:95 +irq_work_queue_on+0x57/0x60 Modules linked in: CPU: 6 PID: 124 Comm: kworker/6:2 Not tainted 5.15.0-rc1+ #3 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS +rel-1.14.0-0-g155821a-rebuilt.opensuse.org 04/01/2014 Workqueue: rcu_gp wait_rcu_exp_gp RIP: 0010:irq_work_queue_on+0x57/0x60 Code: 8b 05 1d c7 ea 62 a9 00 00 f0 00 75 21 4c 89 ce 44 89 c7 e8 +9b 37 fa ff ba 01 00 00 00 89 d0 c3 4c 89 cf e8 3b ff ff ff eb ee <0f> 0b eb b7 +0f 0b eb db 90 48 c7 c0 98 2a 02 00 65 48 03 05 91 6f RSP: 0000:ffffb12cc038fe48 EFLAGS: 00010282 RAX: 0000000000000001 RBX: 0000000000005208 RCX: 0000000000000020 RDX: 0000000000000001 RSI: 0000000000000001 RDI: ffff9ad01f45a680 RBP: 000000000004c990 R08: 0000000000000001 R09: ffff9ad01f45a680 R10: ffffb12cc0317db0 R11: 0000000000000001 R12: 00000000fffecee8 R13: 0000000000000001 R14: 0000000000026980 R15: ffffffff9e53ae00 FS: 0000000000000000(0000) GS:ffff9ad01f580000(0000) +knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000000de0c000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: tick_nohz_dep_set_cpu+0x59/0x70 rcu_exp_wait_wake+0x54e/0x870 ? sync_rcu_exp_select_cpus+0x1fc/0x390 process_one_work+0x1ef/0x3c0 ? process_one_work+0x3c0/0x3c0 worker_thread+0x28/0x3c0 ? process_one_work+0x3c0/0x3c0 kthread+0x115/0x140 ? set_kthread_struct+0x40/0x40 ret_from_fork+0x22/0x30 ---[ end trace c5bf75eb6aa80bc6 ]--- This commit therefore avoids invoking tick_dep_set_cpu() on offlined CPUs to limit both futility and false-positive splats. Signed-off-by: Paul E. McKenney Signed-off-by: Joel Fernandes (Google) --- kernel/rcu/tree_exp.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index 401c1f331caf..07a284a18645 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -507,7 +507,10 @@ static void synchronize_rcu_expedited_wait(void) if (rdp->rcu_forced_tick_exp) continue; rdp->rcu_forced_tick_exp = true; - tick_dep_set_cpu(cpu, TICK_DEP_BIT_RCU_EXP); + preempt_disable(); + if (cpu_online(cpu)) + tick_dep_set_cpu(cpu, TICK_DEP_BIT_RCU_EXP); + preempt_enable(); } } j = READ_ONCE(jiffies_till_first_fqs);