mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Chuyi Zhou" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Chuyi Zhou <zhouchuyi@bytedance.com>,
	Thomas Gleixner <tglx@kernel.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: smp/core] scftorture: Remove preempt_disable() in scftorture_invoke_one()
Date: Thu, 23 Jul 2026 10:21:14 -0000	[thread overview]
Message-ID: <178480207447.2943223.5930234307841919600.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260709122933.4021501-10-zhouchuyi@bytedance.com>

The following commit has been merged into the smp/core branch of tip:

Commit-ID:     99b49e02f9488335156c896c24aab0785623eb67
Gitweb:        https://git.kernel.org/tip/99b49e02f9488335156c896c24aab0785623eb67
Author:        Chuyi Zhou <zhouchuyi@bytedance.com>
AuthorDate:    Thu, 09 Jul 2026 20:29:28 +08:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Thu, 16 Jul 2026 09:24:56 +02:00

scftorture: Remove preempt_disable() in scftorture_invoke_one()

The smp_call*() functions handle their required preemption and CPU
pinning internally. The explicit preempt_disable() in
scftorture_invoke_one() is therefore no longer required for correctness.
Keeping the outer preempt_disable() would also prevent scftorture from
exercising the narrowed internal preemption-disabled regions during IPI
dispatch.

Removing the outer preemption protection can expose a CPU hotplug race in
the test validation when use_cpus_read_lock is false. For multicast
operations, SCF_PRIM_MANY or SCF_PRIM_ALL, if only one CPU is online,
smp_call_function_many() correctly skips sending IPIs and leaves scfc_out
false. Without preemption disabled, a CPU hotplug thread can preempt the
test thread, bring a second CPU online and increment num_online_cpus().
When the test thread resumes, the validation check can observe
num_online_cpus() > 1 and falsely trigger the memory-ordering warning,
leaking the scfcp structure.

Remove the preempt_disable() and preempt_enable() pairs around the
smp_call*() invocations in scftorture_invoke_one(). Restrict the
num_online_cpus() > 1 validation to the use_cpus_read_lock=true case,
where the CPU count is stable during the evaluation.

Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://patch.msgid.link/20260709122933.4021501-10-zhouchuyi@bytedance.com
---
 kernel/scftorture.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/kernel/scftorture.c b/kernel/scftorture.c
index 327c315..2082f9b 100644
--- a/kernel/scftorture.c
+++ b/kernel/scftorture.c
@@ -348,6 +348,8 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
 	int ret = 0;
 	struct scf_check *scfcp = NULL;
 	struct scf_selector *scfsp = scf_sel_rand(trsp);
+	bool is_single = (scfsp->scfs_prim == SCF_PRIM_SINGLE ||
+			  scfsp->scfs_prim == SCF_PRIM_SINGLE_RPC);
 
 	if (scfsp->scfs_prim == SCF_PRIM_SINGLE || scfsp->scfs_wait) {
 		scfcp = kmalloc_obj(*scfcp, GFP_ATOMIC);
@@ -364,8 +366,6 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
 	}
 	if (use_cpus_read_lock)
 		cpus_read_lock();
-	else
-		preempt_disable();
 	switch (scfsp->scfs_prim) {
 	case SCF_PRIM_RESCHED:
 		if (IS_BUILTIN(CONFIG_SCF_TORTURE_TEST)) {
@@ -411,13 +411,10 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
 		if (!ret) {
 			if (use_cpus_read_lock)
 				cpus_read_unlock();
-			else
-				preempt_enable();
+
 			wait_for_completion(&scfcp->scfc_completion);
 			if (use_cpus_read_lock)
 				cpus_read_lock();
-			else
-				preempt_disable();
 		} else {
 			scfp->n_single_rpc_ofl++;
 			scf_add_to_free_list(scfcp);
@@ -452,7 +449,7 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
 			scfcp->scfc_out = true;
 	}
 	if (scfcp && scfsp->scfs_wait) {
-		if (WARN_ON_ONCE((num_online_cpus() > 1 || scfsp->scfs_prim == SCF_PRIM_SINGLE) &&
+		if (WARN_ON_ONCE(((use_cpus_read_lock && num_online_cpus() > 1) || is_single) &&
 				 !scfcp->scfc_out)) {
 			pr_warn("%s: Memory-ordering failure, scfs_prim: %d.\n", __func__, scfsp->scfs_prim);
 			atomic_inc(&n_mb_out_errs); // Leak rather than trash!
@@ -463,8 +460,6 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
 	}
 	if (use_cpus_read_lock)
 		cpus_read_unlock();
-	else
-		preempt_enable();
 	if (allocfail)
 		schedule_timeout_idle((1 + longwait) * HZ);  // Let no-wait handlers complete.
 	else if (!(torture_random(trsp) & 0xfff))

  reply	other threads:[~2026-07-23 10:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 12:29 [PATCH v10 00/14] Allow preemption during IPI completion waiting to improve real-time performance Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 01/14] smp: Disable preemption explicitly in __csd_lock_wait() Chuyi Zhou
2026-07-23 10:21   ` [tip: smp/core] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 02/14] smp: Enable preemption early in smp_call_function_single() Chuyi Zhou
2026-07-23 10:21   ` [tip: smp/core] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 03/14] smp: Refactor remote CPU selection in smp_call_function_any() Chuyi Zhou
2026-07-23 10:21   ` [tip: smp/core] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 04/14] smp: Use task-local IPI cpumask in smp_call_function_many_cond() Chuyi Zhou
2026-07-23 10:21   ` [tip: smp/core] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 05/14] smp: Alloc percpu csd data in smpcfd_prepare_cpu() only once Chuyi Zhou
2026-07-23 10:21   ` [tip: smp/core] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 06/14] smp: Enable preemption early in smp_call_function_many_cond() Chuyi Zhou
2026-07-23 10:21   ` [tip: smp/core] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 07/14] smp: Remove preempt_disable() from smp_call_function() Chuyi Zhou
2026-07-23 10:21   ` [tip: smp/core] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 08/14] smp: Remove preempt_disable() from on_each_cpu_cond_mask() Chuyi Zhou
2026-07-23 10:21   ` [tip: smp/core] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 09/14] scftorture: Remove preempt_disable() in scftorture_invoke_one() Chuyi Zhou
2026-07-23 10:21   ` tip-bot2 for Chuyi Zhou [this message]
2026-07-09 12:29 ` [PATCH v10 10/14] x86/mm: Factor out flush_tlb_info initialization Chuyi Zhou
2026-07-23 10:32   ` [tip: x86/mm] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 11/14] x86/mm: Cap flush_tlb_info alignment at 64 bytes Chuyi Zhou
2026-07-23 10:32   ` [tip: x86/mm] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 12/14] x86/mm: Move flush_tlb_info back to the stack Chuyi Zhou
2026-07-23 10:32   ` [tip: x86/mm] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 13/14] x86/kvm: Disable preemption in kvm_flush_tlb_multi() Chuyi Zhou
2026-07-23 10:32   ` [tip: x86/mm] " tip-bot2 for Chuyi Zhou
2026-07-09 12:29 ` [PATCH v10 14/14] x86/mm: Re-enable preemption before flush_tlb_multi() Chuyi Zhou
2026-07-23 10:32   ` [tip: x86/mm] " tip-bot2 for Chuyi Zhou
2026-07-16 14:14 ` [PATCH v10 00/14] Allow preemption during IPI completion waiting to improve real-time performance Chuyi Zhou
2026-07-16 21:18   ` Thomas Gleixner
2026-07-23 19:26 ` Borislav Petkov
2026-07-24  3:08   ` Chuyi Zhou
2026-08-11 21:22     ` Borislav Petkov
2026-08-12  3:56   ` Chuyi Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178480207447.2943223.5930234307841919600.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    --cc=zhouchuyi@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®