[2.5] smp_call_function_mask
Subsystems (4)
Quoted 8 lines · Alan
Review
Quoted 3 lines · Zwane Mwaikambo
(quoted diff) +3
-0+ /* 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
Quoted 11 lines
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
Quoted 5 lines · Manfred Spraul
from 2.5.52, <
asm-i386/atomic.h>#define atomic_read(v) ((v)->counter)AFAIK
atomic_readnever contained locked bus cycles.Btw, Zwane, what about removing
non_atomicfrom the prototype?
The funny thing is, there are about 3 different versions of smp_call_function and removing nonatomic would reduce the argument count (there are some architectures which use 'retry' in nonatomic's place) and i'm a bit wary of making other archs bend over for i386 these days. Perhaps renaming it to __unused or something similarly obvious.
Zwane
Signature · 1 line
function.linuxpower.ca
Quoted 10 lines · Zwane Mwaikambo
Quoted 5 lines · Manfred Spraul
from 2.5.52, <
asm-i386/atomic.h>#define atomic_read(v) ((v)->counter)AFAIK
atomic_readnever contained locked bus cycles.Btw, Zwane, what about removing
non_atomicfrom the prototype?The funny thing is, there are about 3 different versions of
smp_call_functionand removing nonatomic would reduce the argument count
I was actually thinking about smp_call_function_mask type functions.
Quoted 3 lines
(there are some architectures which use 'retry' in nonatomic's place) and i'm a bit wary of making other archs bend over for i386 these days. Perhaps renaming it to
__unusedor something similarly obvious.
I renamed the function to smp_call_function_on_cpu like its Alpha counterpart, we could also reuse it to deliver to all CPUs but it might be faster to just send one broadcast message in that case on some architectures.
Something like this?
Index: linux-2.5.59/include/linux/smp.h
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/include/linux/smp.h,v retrieving revision 1.1.1.1
include/linux/smp.h +7 -0
@@ -54,6 +54,12 @@ int retry, int wait);/* +* Call a function on a single or group of processors +*/ +extern int smp_call_function_on_cpu (void (*func) (void *info),void *info,int retry, +int wait,unsigned long mask); + +/* * True once the per process idle is forked */ extern int smp_threads_ready;
@@ -96,6 +102,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_on_cpu (func,info,retry,wait) ({ 0; })static inline void smp_send_reschedule (int cpu) { }static inline void smp_send_reschedule_all (void ) { }#define cpu_online_map 1
Index: linux-2.5.59/arch/i386/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/i386/kernel/smp.c,v retrieving revision 1.1.1.1
arch/i386/kernel/smp.c +57 -0
63 lines not on this page · raw message
Index: linux-2.5.59/arch/ia64/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/ia64/kernel/smp.c,v retrieving revision 1.1.1.1
arch/ia64/kernel/smp.c +32 -17
78 lines not on this page · raw message
Index: linux-2.5.59/arch/mips/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/mips/kernel/smp.c,v retrieving revision 1.1.1.1
arch/mips/kernel/smp.c +48 -0
54 lines not on this page · raw message
Index: linux-2.5.59/arch/parisc/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/parisc/kernel/smp.c,v retrieving revision 1.1.1.1
arch/parisc/kernel/smp.c +81 -0
88 lines not on this page · raw message
Index: linux-2.5.59/arch/ppc/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/ppc/kernel/smp.c,v retrieving revision 1.1.1.1
arch/ppc/kernel/smp.c +75 -0
81 lines not on this page · raw message
Index: linux-2.5.59/arch/ppc64/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/ppc64/kernel/smp.c,v retrieving revision 1.1.1.1
arch/ppc64/kernel/smp.c +88 -0
94 lines not on this page · raw message
Index: linux-2.5.59/arch/s390/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/s390/kernel/smp.c,v retrieving revision 1.1.1.1
arch/s390/kernel/smp.c +59 -0
65 lines not on this page · raw message
Index: linux-2.5.59/arch/sparc64/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/sparc64/kernel/smp.c,v retrieving revision 1.1.1.1
arch/sparc64/kernel/smp.c +62 -0
68 lines not on this page · raw message
Index: linux-2.5.59/arch/um/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/um/kernel/smp.c,v retrieving revision 1.1.1.1
arch/um/kernel/smp.c +36 -0
@@ -254,6 +254,42 @@atomic_inc (&scf_finished); } +int smp_call_function_on_cpu (void (*_func)(void *info),void *_info,int retry, +int wait,unsigned long mask) +{ +int i, cpu, num_cpus =hweight32 (mask); + +if (num_cpus ==0 ) +return 0 ; + + cpu =get_cpu (); +if ((1UL << cpu) && mask) { +put_cpu_no_resched (); +return 0 ; + } + +spin_lock_bh (&call_lock); +atomic_set (&scf_started,0 ); +atomic_set (&scf_finished,0 ); + func = _func; + info = _info; + +for (i=0 ;i<NR_CPUS ;i++) +if (cpu_online (i) && ((1UL << i) & mask)) +write (cpu_data[i].ipi_pipe[1 ],"C" ,1 ); + +while (atomic_read (&scf_started) != num_cpus) +barrier (); + +if (wait) +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) {
Index: linux-2.5.59/arch/x86_64/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59/arch/x86_64/kernel/smp.c,v retrieving revision 1.1.1.1
arch/x86_64/kernel/smp.c +57 -0
63 lines not on this page · raw message
Signature · 1 line
function.linuxpower.ca
Quoted 12 lines · Zwane Mwaikambo
Quoted 8 lines · Zwane Mwaikambo
Quoted 4 lines · Manfred Spraul
from 2.5.52, <
asm-i386/atomic.h>
#defineatomic_read(v)((v)->counter)
AFAIKatomic_readnever contained locked bus cycles.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Btw, Zwane, what about removing
non_atomicfrom the prototype?The funny thing is, there are about 3 different versions of
smp_call_functionand removing nonatomic would reduce the argument count
You can blame me for the mess with smp_call_function:
2.2 supported nonatomic calls. I have no idea if that was deadlock free.
But noone used the 'retry/nonatomic' parameter, noone handled an error return of smp_call_function (some callers panic). Thus I've removed these features from i386, without changing the prototype. I think all archs have picked that up now. But retry/nonatomic should not spread into new functions.
--
Manfred
Quoted 8 lines · Manfred Spraul
You can blame me for the mess with
smp_call_function:
2.2 supported nonatomic calls. I have no idea if that was deadlock free.But noone used the 'retry/nonatomic' parameter, noone handled an error return of
smp_call_function(some callers panic).
Thus I've removed these features from i386, without changing the prototype. I think all archs have picked that up now.
But retry/nonatomic should not spread into new functions.
Ok i'll send something with forced retry and removing the nonatomic/retry parameter completely.
Zwane
Signature · 1 line
function.linuxpower.ca
Quoted 10 lines · Manfred Spraul
Quoted 8 lines · Alan
Review
Quoted 3 lines · Zwane Mwaikambo
(quoted diff) +3
-0+ /* 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
Quoted 5 lines
Quoted 1 line
while(atomic_read(&data.started) != num_cpus)from 2.5.52, <
asm-i386/atomic.h>#define atomic_read(v) ((v)->counter)AFAIK
atomic_readnever contained locked bus cycles.
For x86 at least it never did, you are right. Must be time for a brain transplant