Re: [PATCH] [14/58] x86_64: Add on_cpu_single

2007-07-19 Thread Andi Kleen

> But probably you should just drop this ... with smp_call_function_single's
> new semantics, I don't see this function growing any users.

The new sched-clock uses it, but i'll update it to use smp_call_function_single

Thanks

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] [14/58] x86_64: Add on_cpu_single

2007-07-19 Thread Satyam Sharma

Hi Andi,

On 7/19/07, Andi Kleen <[EMAIL PROTECTED]> wrote:


Call a function on a target CPU but do the right thing when
we're already on that CPU. That's the main difference from
smp_call_function_single
which does the wrong thing in this case (erroring out)


I think this is no longer the case, is it? With KVM updates already
merged in latest mainline -git, that modified smp_call_function_single()
behaviour ...


+#ifdef CONFIG_SMP
+/* Similar to smp_call_function_single, but DTRT when we're already
+   on the right CPU. */
+static inline void on_cpu_single(int cpu, void (*func)(void *), void *info)
+{
+   int me = get_cpu();
+   if (cpu == me) {
+   func(info);
+   put_cpu();
+   } else {
+   put_cpu();
+   /* wait is forced on because the me==cpu case above will always 
wait */
+   smp_call_function_single(cpu, func, info, 0, 1);


In any case, this is unsafe. smp_call_function_single() -- with the old
semantics, which is what this patch assumes, obviously -- is quite
pointless without its _caller_ disabling preemption around it. So the
put_cpu() must come after the smp_call_function_single, otherwise
you won't even detect the error that might happen, seeing you're
ignoring its return and this wrapper being void-returning.


+   }
+}
+#else
+static inline void on_cpu_single(int cpu, void (*func)(void *), void *info)
+{


WARN_ON(irqs_disabled());
local_irq_disable();


+   func(info);


local_irq_restore();


+}
+#endif


... for the sake of API / behaviour consistency.


But probably you should just drop this ... with smp_call_function_single's
new semantics, I don't see this function growing any users.

Satyam
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] [14/58] x86_64: Add on_cpu_single

2007-07-19 Thread Andi Kleen

Call a function on a target CPU but do the right thing when 
we're already on that CPU. That's the main difference from 
smp_call_function_single
which does the wrong thing in this case (erroring out)

Another advantage is that it is also defined for the UP case, avoiding
some ifdefs.

I also dropped retry (which never did anything) and wait (because the on
current cpu case will always wait)
Signed-off-by: Andi Kleen <[EMAIL PROTECTED]>

---
 include/linux/smp.h |   22 ++
 1 file changed, 22 insertions(+)

Index: linux/include/linux/smp.h
===
--- linux.orig/include/linux/smp.h
+++ linux/include/linux/smp.h
@@ -138,4 +138,26 @@ static inline void smp_send_reschedule(i
 
 void smp_setup_processor_id(void);
 
+#ifdef CONFIG_SMP
+/* Similar to smp_call_function_single, but DTRT when we're already
+   on the right CPU. */
+static inline void on_cpu_single(int cpu, void (*func)(void *), void *info)
+{
+   int me = get_cpu();
+   if (cpu == me) {
+   func(info);
+   put_cpu();
+   } else {
+   put_cpu();
+   /* wait is forced on because the me==cpu case above will always 
wait */
+   smp_call_function_single(cpu, func, info, 0, 1);
+   }
+}
+#else
+static inline void on_cpu_single(int cpu, void (*func)(void *), void *info)
+{
+   func(info);
+}
+#endif
+
 #endif /* __LINUX_SMP_H */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] [14/58] x86_64: Add on_cpu_single

2007-07-19 Thread Andi Kleen

Call a function on a target CPU but do the right thing when 
we're already on that CPU. That's the main difference from 
smp_call_function_single
which does the wrong thing in this case (erroring out)

Another advantage is that it is also defined for the UP case, avoiding
some ifdefs.

I also dropped retry (which never did anything) and wait (because the on
current cpu case will always wait)
Signed-off-by: Andi Kleen [EMAIL PROTECTED]

---
 include/linux/smp.h |   22 ++
 1 file changed, 22 insertions(+)

Index: linux/include/linux/smp.h
===
--- linux.orig/include/linux/smp.h
+++ linux/include/linux/smp.h
@@ -138,4 +138,26 @@ static inline void smp_send_reschedule(i
 
 void smp_setup_processor_id(void);
 
+#ifdef CONFIG_SMP
+/* Similar to smp_call_function_single, but DTRT when we're already
+   on the right CPU. */
+static inline void on_cpu_single(int cpu, void (*func)(void *), void *info)
+{
+   int me = get_cpu();
+   if (cpu == me) {
+   func(info);
+   put_cpu();
+   } else {
+   put_cpu();
+   /* wait is forced on because the me==cpu case above will always 
wait */
+   smp_call_function_single(cpu, func, info, 0, 1);
+   }
+}
+#else
+static inline void on_cpu_single(int cpu, void (*func)(void *), void *info)
+{
+   func(info);
+}
+#endif
+
 #endif /* __LINUX_SMP_H */
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] [14/58] x86_64: Add on_cpu_single

2007-07-19 Thread Satyam Sharma

Hi Andi,

On 7/19/07, Andi Kleen [EMAIL PROTECTED] wrote:


Call a function on a target CPU but do the right thing when
we're already on that CPU. That's the main difference from
smp_call_function_single
which does the wrong thing in this case (erroring out)


I think this is no longer the case, is it? With KVM updates already
merged in latest mainline -git, that modified smp_call_function_single()
behaviour ...


+#ifdef CONFIG_SMP
+/* Similar to smp_call_function_single, but DTRT when we're already
+   on the right CPU. */
+static inline void on_cpu_single(int cpu, void (*func)(void *), void *info)
+{
+   int me = get_cpu();
+   if (cpu == me) {
+   func(info);
+   put_cpu();
+   } else {
+   put_cpu();
+   /* wait is forced on because the me==cpu case above will always 
wait */
+   smp_call_function_single(cpu, func, info, 0, 1);


In any case, this is unsafe. smp_call_function_single() -- with the old
semantics, which is what this patch assumes, obviously -- is quite
pointless without its _caller_ disabling preemption around it. So the
put_cpu() must come after the smp_call_function_single, otherwise
you won't even detect the error that might happen, seeing you're
ignoring its return and this wrapper being void-returning.


+   }
+}
+#else
+static inline void on_cpu_single(int cpu, void (*func)(void *), void *info)
+{


WARN_ON(irqs_disabled());
local_irq_disable();


+   func(info);


local_irq_restore();


+}
+#endif


... for the sake of API / behaviour consistency.


But probably you should just drop this ... with smp_call_function_single's
new semantics, I don't see this function growing any users.

Satyam
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] [14/58] x86_64: Add on_cpu_single

2007-07-19 Thread Andi Kleen

 But probably you should just drop this ... with smp_call_function_single's
 new semantics, I don't see this function growing any users.

The new sched-clock uses it, but i'll update it to use smp_call_function_single

Thanks

-Andi
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/