public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH][2.5] smp_call_function_mask
@ 2003-01-21  7:13 Manfred Spraul
  2003-01-21  8:07 ` Zwane Mwaikambo
  2003-01-21 23:14 ` Alan Cox
  0 siblings, 2 replies; 11+ messages in thread
From: Manfred Spraul @ 2003-01-21  7:13 UTC (permalink / raw)
  To: Alan, Zwane Mwaikambo; +Cc: linux-kernel

Alan wrote:

>On Fri, 2003-01-17 at 05:18, Zwane Mwaikambo wrote:
>> +	/* Wait for response */
>> +	while (atomic_read(&data.started) != num_cpus)
>> +		barrier();
>
>Only old old intel x86 that does -bad- things as it
>generates a lot of bus locked cycles. Better to do
>
>	while(atomic_read(&data.started) != num_cpus)
>		while(data.started.value != num_cpus)
>		{
>			barrier();
>			cpu_relax();
>		}
>
>I would think ?
>
>  
>
from 2.5.52, <asm-i386/atomic.h>
    #define atomic_read(v)          ((v)->counter)
AFAIK atomic_read never contained locked bus cycles.

Btw, Zwane, what about removing non_atomic from the prototype?

--
    Manfred


^ permalink raw reply	[flat|nested] 11+ messages in thread
* [PATCH][2.5] smp_call_function_mask
@ 2003-01-17  5:18 Zwane Mwaikambo
  2003-01-17  5:44 ` Andrew Morton
  2003-01-20 23:19 ` Alan
  0 siblings, 2 replies; 11+ messages in thread
From: Zwane Mwaikambo @ 2003-01-17  5:18 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Ingo Molnar, Robert Love, Andrew Morton

This patch adds a smp_call_function which also accepts a cpu mask which is 
needed for targetting specific or groups of cpus.

Index: linux-2.5.58-cpu_hotplug/arch/i386/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.58/arch/i386/kernel/smp.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- linux-2.5.58-cpu_hotplug/arch/i386/kernel/smp.c	14 Jan 2003 06:59:22 -0000	1.1.1.1
+++ linux-2.5.58-cpu_hotplug/arch/i386/kernel/smp.c	15 Jan 2003 07:59:32 -0000	1.2
@@ -544,6 +544,57 @@
 	return 0;
 }
 
+int smp_call_function_mask (void (*func) (void *info), void *info, int nonatomic,
+			int wait, unsigned long mask)
+/*
+ * [SUMMARY] Run a function on specific CPUs, save self.
+ * <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 (atomically) until function has completed on other CPUs.
+ * <mask> The bitmask of CPUs to call the function
+ * [RETURNS] 0 on success, else a negative status code. Does not return until
+ * remote CPUs are nearly ready to execute <<func>> or are or have executed.
+ *
+ * You must not call this function with disabled interrupts or from a
+ * hardware interrupt handler or from a bottom half handler.
+ */
+{
+	struct call_data_struct data;
+	int num_cpus = hweight32(mask);
+
+	if (num_cpus == 0)
+		return -EINVAL;
+
+	if ((1UL << smp_processor_id()) & mask)
+		return -EINVAL;
+
+	data.func = func;
+	data.info = info;
+	atomic_set(&data.started, 0);
+	data.wait = wait;
+	if (wait)
+		atomic_set(&data.finished, 0);
+
+	spin_lock(&call_lock);
+	call_data = &data;
+	wmb();
+
+	/* Send a message to the CPUs in the mask and wait for them to respond */
+	send_IPI_mask_sequence(mask, CALL_FUNCTION_VECTOR);
+
+	/* Wait for response */
+	while (atomic_read(&data.started) != num_cpus)
+		barrier();
+
+	if (wait)
+		while (atomic_read(&data.finished) != num_cpus)
+			barrier();
+	spin_unlock(&call_lock);
+
+	return 0;
+}
+
 static void stop_this_cpu (void * dummy)
 {
 	/*
Index: linux-2.5.58-cpu_hotplug/include/linux/smp.h
===================================================================
RCS file: /build/cvsroot/linux-2.5.58/include/linux/smp.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 smp.h
--- linux-2.5.58-cpu_hotplug/include/linux/smp.h	14 Jan 2003 07:02:19 -0000	1.1.1.1
+++ linux-2.5.58-cpu_hotplug/include/linux/smp.h	15 Jan 2003 08:13:35 -0000
@@ -53,6 +53,9 @@
 extern int smp_call_function (void (*func) (void *info), void *info,
 			      int retry, int wait);
 
+extern int smp_call_function_mask (void (*func) (void *info), void *info,
+				int retry, int wait, unsigned long mask);
+
 /*
  * True once the per process idle is forked
  */
@@ -96,6 +99,7 @@
 #define hard_smp_processor_id()			0
 #define smp_threads_ready			1
 #define smp_call_function(func,info,retry,wait)	({ 0; })
+#define smp_call_function_mask(func,info,retry,wait,mask) ({ 0; })
 static inline void smp_send_reschedule(int cpu) { }
 static inline void smp_send_reschedule_all(void) { }
 #define cpu_online_map				1

-- 
function.linuxpower.ca


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-01-21 23:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-21  7:13 [PATCH][2.5] smp_call_function_mask Manfred Spraul
2003-01-21  8:07 ` Zwane Mwaikambo
2003-01-21  9:21   ` Zwane Mwaikambo
2003-01-21 17:13     ` Manfred Spraul
2003-01-21 17:49       ` Zwane Mwaikambo
2003-01-21 23:14 ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2003-01-17  5:18 Zwane Mwaikambo
2003-01-17  5:44 ` Andrew Morton
2003-01-17  5:56   ` Zwane Mwaikambo
2003-01-20 23:19 ` Alan
2003-01-21  7:16   ` Zwane Mwaikambo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox