Blob Blame History Raw
Patch-mainline: v5.10-rc1
Git-commit: e48c15b796d412ede883bb2ef7779b2a142f7962
References: bsc#1180846
From: "Paul E. McKenney" <paulmck@kernel.org>
Date: Mon, 29 Jun 2020 17:21:32 -0700
Subject: [PATCH] smp: Add source and destination CPUs to __call_single_data

This commit adds a destination CPU to __call_single_data, and is inspired
by an earlier commit by Peter Zijlstra.  This version adds #ifdef to
permit use by 32-bit systems and supplying the destination CPU for all
smp_call_function*() requests, not just smp_call_function_single().

If need be, 32-bit systems could be accommodated by shrinking the flags
field to 16 bits (the atomic_t variant is currently unused) and by
providing only eight bits for CPU on such systems.

It is not clear that the addition of the fields to __call_single_node
are really needed.

[ paulmck: Apply Boqun Feng feedback on 32-bit builds. ]
Link: https://lore.kernel.org/lkml/20200615164048.GC2531@hirez.programming.kicks-ass.net/
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/linux/smp.h       | 3 +++
 kernel/smp.c              | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/include/linux/smp.h b/include/linux/smp.h
index 80d557ef8a11..9f13966d3d92 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -20,6 +20,9 @@ struct __call_single_data {
 	smp_call_func_t func;
 	void *info;
 	unsigned int flags;
+#ifdef CONFIG_64BIT
+	u16 src, dst;
+#endif
 };
 
 /* Use __aligned() to avoid to use 2 cache lines for 1 csd */
diff --git a/kernel/smp.c b/kernel/smp.c
index d0ae8eb6bf8b..865a876f83ce 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -164,6 +164,9 @@ int generic_exec_single(int cpu, call_single_data_t *csd,
 
 	csd->func = func;
 	csd->info = info;
+#ifdef CONFIG_64BIT
+	csd->dst = cpu;
+#endif
 
 	/*
 	 * The list addition should be visible before sending the IPI
@@ -470,6 +473,9 @@ static void smp_call_function_many(const struct cpumask *mask,
 			csd->flags |= CSD_FLAG_SYNCHRONOUS;
 		csd->func = func;
 		csd->info = info;
+#ifdef CONFIG_64BIT
+		csd->dst = cpu;
+#endif
 		if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu)))
 			__cpumask_set_cpu(cpu, cfd->cpumask_ipi);
 	}
-- 
2.26.2