mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][2.5][13/14] smp_call_function_on_cpu - UML
@ 2003-02-14  9:34 Zwane Mwaikambo
  2003-02-14 13:09 ` Zwane Mwaikambo
  2003-02-22 19:21 ` Jeff Dike
  0 siblings, 2 replies; 3+ messages in thread
From: Zwane Mwaikambo @ 2003-02-14  9:34 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Jeff Dike, Linus Torvalds

 smp.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

Index: linux-2.5.60/arch/um/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.60/arch/um/kernel/smp.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 smp.c
--- linux-2.5.60/arch/um/kernel/smp.c	10 Feb 2003 22:15:17 -0000	1.1.1.1
+++ linux-2.5.60/arch/um/kernel/smp.c	14 Feb 2003 07:46:06 -0000
@@ -255,15 +255,19 @@
 	atomic_inc(&scf_finished);
 }
 
-int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic, 
-		      int wait)
+int smp_call_function_on_cpu(void (*_func)(void *info), void *_info, int wait,
+				unsigned long mask)
 {
-	int cpus = num_online_cpus() - 1;
-	int i;
-
-	if (!cpus)
-		return 0;
+	int i, cpu, num_cpus;
 
+	cpu = get_cpu();
+	mask &= ~(1UL << cpu);
+	num_cpus = hweight32(mask);
+	if (num_cpus == 0) {
+		put_cpu_no_resched();
+		return -EINVAL;
+	}
+	
 	spin_lock_bh(&call_lock);
 	atomic_set(&scf_started, 0);
 	atomic_set(&scf_finished, 0);
@@ -271,19 +275,24 @@
 	info = _info;
 
 	for (i=0;i<NR_CPUS;i++)
-		if((i != current->thread_info->cpu) && 
-		   test_bit(i, &cpu_online_map))
+		if (cpu_online(i) && ((1UL << i) & mask))
 			write(cpu_data[i].ipi_pipe[1], "C", 1);
 
-	while (atomic_read(&scf_started) != cpus)
+	while (atomic_read(&scf_started) != num_cpus)
 		barrier();
 
 	if (wait)
-		while (atomic_read(&scf_finished) != cpus)
+		while (atomic_read(&scf_finished) != num_cpus)
 			barrier();
 
 	spin_unlock_bh(&call_lock);
+	put_cpu_no_resched();
 	return 0;
+}
+
+int smp_call_function(void (*_func)(void *info), void *_info, int wait)
+{
+	return smp_call_function_on_cpu(_func, _info, wait, cpu_online_map);
 }
 
 #endif

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

* Re: [PATCH][2.5][13/14] smp_call_function_on_cpu - UML
  2003-02-14  9:34 [PATCH][2.5][13/14] smp_call_function_on_cpu - UML Zwane Mwaikambo
@ 2003-02-14 13:09 ` Zwane Mwaikambo
  2003-02-22 19:21 ` Jeff Dike
  1 sibling, 0 replies; 3+ messages in thread
From: Zwane Mwaikambo @ 2003-02-14 13:09 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Jeff Dike, Linus Torvalds

One liner to fix num_cpus == 0 on SMP kernel w/ UP box

Index: linux-2.5.60/arch/um/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.60/arch/um/kernel/smp.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 smp.c
--- linux-2.5.60/arch/um/kernel/smp.c	10 Feb 2003 22:15:17 -0000	1.1.1.1
+++ linux-2.5.60/arch/um/kernel/smp.c	14 Feb 2003 12:59:41 -0000
@@ -255,15 +255,19 @@
 	atomic_inc(&scf_finished);
 }
 
-int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic, 
-		      int wait)
+int smp_call_function_on_cpu(void (*_func)(void *info), void *_info, int wait,
+				unsigned long mask)
 {
-	int cpus = num_online_cpus() - 1;
-	int i;
+	int i, cpu, num_cpus;
 
-	if (!cpus)
+	cpu = get_cpu();
+	mask &= ~(1UL << cpu);
+	num_cpus = hweight32(mask);
+	if (num_cpus == 0) {
+		put_cpu_no_resched();
 		return 0;
-
+	}
+	
 	spin_lock_bh(&call_lock);
 	atomic_set(&scf_started, 0);
 	atomic_set(&scf_finished, 0);
@@ -271,19 +275,24 @@
 	info = _info;
 
 	for (i=0;i<NR_CPUS;i++)
-		if((i != current->thread_info->cpu) && 
-		   test_bit(i, &cpu_online_map))
+		if (cpu_online(i) && ((1UL << i) & mask))
 			write(cpu_data[i].ipi_pipe[1], "C", 1);
 
-	while (atomic_read(&scf_started) != cpus)
+	while (atomic_read(&scf_started) != num_cpus)
 		barrier();
 
 	if (wait)
-		while (atomic_read(&scf_finished) != cpus)
+		while (atomic_read(&scf_finished) != num_cpus)
 			barrier();
 
 	spin_unlock_bh(&call_lock);
+	put_cpu_no_resched();
 	return 0;
+}
+
+int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic, int wait)
+{
+	return smp_call_function_on_cpu(_func, _info, wait, cpu_online_map);
 }
 
 #endif

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

* Re: [PATCH][2.5][13/14] smp_call_function_on_cpu - UML
  2003-02-14  9:34 [PATCH][2.5][13/14] smp_call_function_on_cpu - UML Zwane Mwaikambo
  2003-02-14 13:09 ` Zwane Mwaikambo
@ 2003-02-22 19:21 ` Jeff Dike
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Dike @ 2003-02-22 19:21 UTC (permalink / raw)
  To: Zwane Mwaikambo; +Cc: Linux Kernel

zwane@holomorphy.com said:
> One liner to fix num_cpus == 0 on SMP kernel w/ UP box 

Applied, thanks.

		Jeff


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

end of thread, other threads:[~2003-02-22 19:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-14  9:34 [PATCH][2.5][13/14] smp_call_function_on_cpu - UML Zwane Mwaikambo
2003-02-14 13:09 ` Zwane Mwaikambo
2003-02-22 19:21 ` Jeff Dike

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®