* [PATCH] i386 adds smp_call_function_single
@ 2006-07-11 13:24 Stephane Eranian
2006-07-11 17:52 ` Dave Jones
2006-07-13 6:47 ` Keith Owens
0 siblings, 2 replies; 4+ messages in thread
From: Stephane Eranian @ 2006-07-11 13:24 UTC (permalink / raw)
To: linux-kernel; +Cc: Stephane Eranian
Hello,
Continiung the series of small patches necessary for the perfmon subsystem, here
is a patch that adds support for the smp_call_function_single() function for i386.
It exists for almost all other architectures but i386. The perfmon subsystem
needs it in one case to free some state on a designated remote CPU.
Changelog:
- adds smp_call_function_single() to i386 tree. This function
is used to invoked a procedure on a designated remote CPU.
<signed-off-by>: eranian@hpl.hp.com
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -634,3 +634,69 @@ fastcall void smp_call_function_interrup
}
}
+/*
+ * this function sends a 'generic call function' IPI to one other CPU
+ * in the system.
+ *
+ * cpu is a standard Linux logical CPU number.
+ */
+static void
+__smp_call_function_single(int cpu, void (*func) (void *info), void *info,
+ int nonatomic, int wait)
+{
+ struct call_data_struct data;
+ int cpus = 1;
+
+ data.func = func;
+ data.info = info;
+ atomic_set(&data.started, 0);
+ data.wait = wait;
+ if (wait)
+ atomic_set(&data.finished, 0);
+
+ call_data = &data;
+ wmb();
+ /* Send a message to all other CPUs and wait for them to respond */
+ send_IPI_mask(cpumask_of_cpu(cpu), CALL_FUNCTION_VECTOR);
+
+ /* Wait for response */
+ while (atomic_read(&data.started) != cpus)
+ cpu_relax();
+
+ if (!wait)
+ return;
+
+ while (atomic_read(&data.finished) != cpus)
+ cpu_relax();
+}
+
+/*
+ * smp_call_function_single - Run a function on another CPU
+ * @func: The function to run. This must be fast and non-blocking.
+ * @info: An arbitrary pointer to pass to the function.
+ * @nonatomic: Currently unused.
+ * @wait: If true, wait until function has completed on other CPUs.
+ *
+ * Retrurns 0 on success, else a negative status code.
+ *
+ * Does not return until the remote CPU is nearly ready to execute <func>
+ * or is or has executed.
+ */
+
+int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
+ int nonatomic, int wait)
+{
+ /* prevent preemption and reschedule on another processor */
+ int me = get_cpu();
+ if (cpu == me) {
+ WARN_ON(1);
+ put_cpu();
+ return -EBUSY;
+ }
+ spin_lock_bh(&call_lock);
+ __smp_call_function_single(cpu, func, info, nonatomic, wait);
+ spin_unlock_bh(&call_lock);
+ put_cpu();
+ return 0;
+}
+EXPORT_SYMBOL(smp_call_function_single);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i386 adds smp_call_function_single
2006-07-11 13:24 [PATCH] i386 adds smp_call_function_single Stephane Eranian
@ 2006-07-11 17:52 ` Dave Jones
2006-07-11 20:00 ` Stephane Eranian
2006-07-13 6:47 ` Keith Owens
1 sibling, 1 reply; 4+ messages in thread
From: Dave Jones @ 2006-07-11 17:52 UTC (permalink / raw)
To: Stephane Eranian; +Cc: linux-kernel
On Tue, Jul 11, 2006 at 06:24:22AM -0700, Stephane Eranian wrote:
> Hello,
>
> Continiung the series of small patches necessary for the perfmon subsystem, here
> is a patch that adds support for the smp_call_function_single() function for i386.
> It exists for almost all other architectures but i386. The perfmon subsystem
> needs it in one case to free some state on a designated remote CPU.
>
> Changelog:
> - adds smp_call_function_single() to i386 tree. This function
> is used to invoked a procedure on a designated remote CPU.
The naming seems a little strange to me. Something like
run_on_cpu() would be clearer. Less keystrokes too :)
Dave
--
http://www.codemonkey.org.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i386 adds smp_call_function_single
2006-07-11 17:52 ` Dave Jones
@ 2006-07-11 20:00 ` Stephane Eranian
0 siblings, 0 replies; 4+ messages in thread
From: Stephane Eranian @ 2006-07-11 20:00 UTC (permalink / raw)
To: Dave Jones, linux-kernel
Dave,
On Tue, Jul 11, 2006 at 01:52:39PM -0400, Dave Jones wrote:
> On Tue, Jul 11, 2006 at 06:24:22AM -0700, Stephane Eranian wrote:
> > Hello,
> >
> > Continiung the series of small patches necessary for the perfmon subsystem, here
> > is a patch that adds support for the smp_call_function_single() function for i386.
> > It exists for almost all other architectures but i386. The perfmon subsystem
> > needs it in one case to free some state on a designated remote CPU.
> >
> > Changelog:
> > - adds smp_call_function_single() to i386 tree. This function
> > is used to invoked a procedure on a designated remote CPU.
>
> The naming seems a little strange to me. Something like
> run_on_cpu() would be clearer. Less keystrokes too :)
>
I agree with you that the name is a bit long but I did not invent it.
The same function name is used for this functionality on IA-64 and X86-64.
--
-Stephane
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i386 adds smp_call_function_single
2006-07-11 13:24 [PATCH] i386 adds smp_call_function_single Stephane Eranian
2006-07-11 17:52 ` Dave Jones
@ 2006-07-13 6:47 ` Keith Owens
1 sibling, 0 replies; 4+ messages in thread
From: Keith Owens @ 2006-07-13 6:47 UTC (permalink / raw)
To: eranian; +Cc: linux-kernel
Stephane Eranian (on Tue, 11 Jul 2006 06:24:22 -0700) wrote:
>+static void
>+__smp_call_function_single(int cpu, void (*func) (void *info), void *info,
>+ int nonatomic, int wait)
>...
>+ wmb();
>+ /* Send a message to all other CPUs and wait for them to respond */
>+ send_IPI_mask(cpumask_of_cpu(cpu), CALL_FUNCTION_VECTOR);
Nit pick. The comment is wrong, one cpu, not all cpus.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-07-13 6:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-11 13:24 [PATCH] i386 adds smp_call_function_single Stephane Eranian
2006-07-11 17:52 ` Dave Jones
2006-07-11 20:00 ` Stephane Eranian
2006-07-13 6:47 ` Keith Owens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox