Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-02-09 Thread Benjamin Herrenschmidt
On Mon, 2011-02-07 at 14:54 +0100, Peter Zijlstra wrote:
 On Mon, 2011-02-07 at 10:26 +1100, Benjamin Herrenschmidt wrote:
  You missed:
  
  diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
  index 9813605..467d122 100644
  --- a/arch/powerpc/kernel/smp.c
  +++ b/arch/powerpc/kernel/smp.c
  @@ -98,6 +98,7 @@ void smp_message_recv(int msg)
  break;
  case PPC_MSG_RESCHEDULE:
  /* we notice need_resched on exit */
  +   scheduler_ipi();
  break;
  case PPC_MSG_CALL_FUNC_SINGLE:
  generic_smp_call_function_single_interrupt();
  
  Fold that in and add:
  
  Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org
 
 Thanks Ben!

BTW. I we lurking at some of our CPU hotplug code and I think I cannot
totally guarantee that this won't be called on an offline CPU. If that's
a problem, you may want to add a test for that.

IE. The call function IPIs are normally not going to be sent to an
offlined CPU, and stop_machine should be a good enough fence here, but
we do abuse reschedule for a number of things (including in some case
to wake up a sleeping CPU that was pseudo-offlined :-)

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-02-09 Thread Peter Zijlstra
On Wed, 2011-02-09 at 17:14 +1100, Benjamin Herrenschmidt wrote:
 On Mon, 2011-02-07 at 14:54 +0100, Peter Zijlstra wrote:
  On Mon, 2011-02-07 at 10:26 +1100, Benjamin Herrenschmidt wrote:
   You missed:
   
   diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
   index 9813605..467d122 100644
   --- a/arch/powerpc/kernel/smp.c
   +++ b/arch/powerpc/kernel/smp.c
   @@ -98,6 +98,7 @@ void smp_message_recv(int msg)
   break;
   case PPC_MSG_RESCHEDULE:
   /* we notice need_resched on exit */
   +   scheduler_ipi();
   break;
   case PPC_MSG_CALL_FUNC_SINGLE:
   generic_smp_call_function_single_interrupt();
   
   Fold that in and add:
   
   Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org
  
  Thanks Ben!
 
 BTW. I we lurking at some of our CPU hotplug code and I think I cannot
 totally guarantee that this won't be called on an offline CPU. If that's
 a problem, you may want to add a test for that.
 
 IE. The call function IPIs are normally not going to be sent to an
 offlined CPU, and stop_machine should be a good enough fence here, but
 we do abuse reschedule for a number of things (including in some case
 to wake up a sleeping CPU that was pseudo-offlined :-)

Hmm, I _think_ that should all work out nicely, but we'll see, if when
this stuff hits the tree powerpc machines start falling over we'd better
put that check in ;-)

Meanwhile I'm going to preserve this comment in the changelog of this
patch so we don't forget.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-02-07 Thread Peter Zijlstra
On Mon, 2011-02-07 at 10:26 +1100, Benjamin Herrenschmidt wrote:
 You missed:
 
 diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
 index 9813605..467d122 100644
 --- a/arch/powerpc/kernel/smp.c
 +++ b/arch/powerpc/kernel/smp.c
 @@ -98,6 +98,7 @@ void smp_message_recv(int msg)
 break;
 case PPC_MSG_RESCHEDULE:
 /* we notice need_resched on exit */
 +   scheduler_ipi();
 break;
 case PPC_MSG_CALL_FUNC_SINGLE:
 generic_smp_call_function_single_interrupt();
 
 Fold that in and add:
 
 Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org

Thanks Ben!

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-02-06 Thread Benjamin Herrenschmidt
On Mon, 2011-01-17 at 12:07 +0100, Peter Zijlstra wrote:
 diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
 index 68034bb..7ee0fc3 100644
 --- a/arch/powerpc/kernel/smp.c
 +++ b/arch/powerpc/kernel/smp.c
 @@ -128,6 +128,7 @@ static irqreturn_t call_function_action(int irq, void 
 *data)
  static irqreturn_t reschedule_action(int irq, void *data)
  {
 /* we just need the return path side effect of checking need_resched 
 */
 +   scheduler_ipi();
 return IRQ_HANDLED;
  }
   

You missed:

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 9813605..467d122 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -98,6 +98,7 @@ void smp_message_recv(int msg)
break;
case PPC_MSG_RESCHEDULE:
/* we notice need_resched on exit */
+   scheduler_ipi();
break;
case PPC_MSG_CALL_FUNC_SINGLE:
generic_smp_call_function_single_interrupt();

Fold that in and add:

Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org

(We have two variants of the IPIs)

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Peter Zijlstra
For future rework of try_to_wake_up() we'd like to push part of that
onto the CPU the task is actually going to run on, in order to do so we
need a generic callback from the existing scheduler IPI.

This patch introduces such a generic callback: scheduler_ipi() and
implements it as a NOP.

I visited existing smp_send_reschedule() implementations and tried to
add a call to scheduler_ipi() in their handler part, but esp. for MIPS
I'm not quite sure I actually got all of them.

Also, while reading through all this, I noticed the blackfin SMP code
looks to be broken, it simply discards any IPI when low on memory.

Signed-off-by: Peter Zijlstra a.p.zijls...@chello.nl
---
 arch/alpha/kernel/smp.c |1 +
 arch/arm/kernel/smp.c   |1 +
 arch/blackfin/mach-common/smp.c |3 ++-
 arch/cris/arch-v32/kernel/smp.c |   13 -
 arch/ia64/kernel/irq_ia64.c |2 ++
 arch/ia64/xen/irq_xen.c |   10 +-
 arch/m32r/kernel/smp.c  |2 +-
 arch/mips/kernel/smtc.c |1 +
 arch/mips/sibyte/bcm1480/smp.c  |7 +++
 arch/mips/sibyte/sb1250/smp.c   |7 +++
 arch/mn10300/kernel/smp.c   |2 +-
 arch/parisc/kernel/smp.c|1 +
 arch/powerpc/kernel/smp.c   |1 +
 arch/s390/kernel/smp.c  |6 +++---
 arch/sh/kernel/smp.c|2 ++
 arch/sparc/kernel/smp_32.c  |2 +-
 arch/sparc/kernel/smp_64.c  |1 +
 arch/tile/kernel/smp.c  |1 +
 arch/um/kernel/smp.c|2 +-
 arch/x86/kernel/smp.c   |1 +
 arch/x86/xen/smp.c  |1 +
 include/linux/sched.h   |1 +
 22 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 42aa078..c4a570b 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -587,6 +587,7 @@ handle_ipi(struct pt_regs *regs)
case IPI_RESCHEDULE:
/* Reschedule callback.  Everything to be done
   is done by the interrupt return path.  */
+   scheduler_ipi();
break;
 
case IPI_CALL_FUNC:
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 9066473..ffde790 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -579,6 +579,7 @@ asmlinkage void __exception do_IPI(struct pt_regs *regs)
 * nothing more to do - eveything is
 * done on the interrupt return path
 */
+   scheduler_ipi();
break;
 
case IPI_CALL_FUNC:
diff --git a/arch/blackfin/mach-common/smp.c b/arch/blackfin/mach-common/smp.c
index a17107a..e210f8a 100644
--- a/arch/blackfin/mach-common/smp.c
+++ b/arch/blackfin/mach-common/smp.c
@@ -156,6 +156,7 @@ static irqreturn_t ipi_handler(int irq, void *dev_instance)
case BFIN_IPI_RESCHEDULE:
/* That's the easiest one; leave it to
 * return_from_int. */
+   scheduler_ipi();
kfree(msg);
break;
case BFIN_IPI_CALL_FUNC:
@@ -301,7 +302,7 @@ void smp_send_reschedule(int cpu)
 
msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
if (!msg)
-   return;
+   return; /* XXX unreliable needs fixing ! */
INIT_LIST_HEAD(msg-list);
msg-type = BFIN_IPI_RESCHEDULE;
 
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index 84fed3b..86e3c76 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -340,15 +340,18 @@ irqreturn_t crisv32_ipi_interrupt(int irq, void *dev_id)
 
ipi = REG_RD(intr_vect, irq_regs[smp_processor_id()], rw_ipi);
 
+   if (ipi.vector  IPI_SCHEDULE) {
+   scheduler_ipi();
+   }
if (ipi.vector  IPI_CALL) {
-func(info);
+   func(info);
}
if (ipi.vector  IPI_FLUSH_TLB) {
-if (flush_mm == FLUSH_ALL)
-__flush_tlb_all();
-else if (flush_vma == FLUSH_ALL)
+   if (flush_mm == FLUSH_ALL)
+   __flush_tlb_all();
+   else if (flush_vma == FLUSH_ALL)
__flush_tlb_mm(flush_mm);
-else
+   else
__flush_tlb_page(flush_vma, flush_addr);
}
 
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index 9a26015..a580230 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -31,6 +31,7 @@
 #include linux/irq.h
 #include linux/ratelimit.h
 #include linux/acpi.h
+#include linux/sched.h
 
 #include asm/delay.h
 #include asm/intrinsics.h
@@ -496,6 +497,7 @@ ia64_handle_irq (ia64_vector vector, struct pt_regs 

Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Peter Zijlstra
On Mon, 2011-01-17 at 11:26 +, Russell King - ARM Linux wrote:
 On Mon, Jan 17, 2011 at 12:07:13PM +0100, Peter Zijlstra wrote:
  diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
  index 42aa078..c4a570b 100644
  --- a/arch/alpha/kernel/smp.c
  +++ b/arch/alpha/kernel/smp.c
  @@ -587,6 +587,7 @@ handle_ipi(struct pt_regs *regs)
  case IPI_RESCHEDULE:
  /* Reschedule callback.  Everything to be done
 is done by the interrupt return path.  */
  +   scheduler_ipi();
  break;
   
  case IPI_CALL_FUNC:
  diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
  index 9066473..ffde790 100644
  --- a/arch/arm/kernel/smp.c
  +++ b/arch/arm/kernel/smp.c
  @@ -579,6 +579,7 @@ asmlinkage void __exception do_IPI(struct pt_regs *regs)
   * nothing more to do - eveything is
   * done on the interrupt return path
   */
  +   scheduler_ipi();
 
 Maybe remove the comment everything is done on the interrupt return path
 as with this function call, that is no longer the case.
 
 Looks like the same is true for Alpha as well?

Right, will do, thanks! It looks like I've somewhat inconsistent with
that.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Peter Zijlstra
On Mon, 2011-01-17 at 12:31 +0100, Peter Zijlstra wrote:
 On Mon, 2011-01-17 at 11:26 +, Russell King - ARM Linux wrote:

  Maybe remove the comment everything is done on the interrupt return path
  as with this function call, that is no longer the case.

(Removed am33, m32r-ka, m32r, arm-kernel lists because they kept sending
bounces)

---
Subject: sched: provide scheduler_ipi() callback in response to 
smp_send_reschedule()
From: Peter Zijlstra pet...@infradead.org
Date: Mon, 17 Jan 2011 12:07:13 +0100

For future rework of try_to_wake_up() we'd like to push part of that
onto the CPU the task is actually going to run on, in order to do so we
need a generic callback from the existing scheduler IPI.

This patch introduces such a generic callback: scheduler_ipi() and
implements it as a NOP.

I visited existing smp_send_reschedule() implementations and tried to
add a call to scheduler_ipi() in their handler part, but esp. for MIPS
I'm not quite sure I actually got all of them.

Also, while reading through all this, I noticed the blackfin SMP code
looks to be broken, it simply discards any IPI when low on memory.

Signed-off-by: Peter Zijlstra a.p.zijls...@chello.nl
LKML-Reference: new-submission
---
 arch/alpha/kernel/smp.c |3 +--
 arch/arm/kernel/smp.c   |5 +
 arch/blackfin/mach-common/smp.c |5 ++---
 arch/cris/arch-v32/kernel/smp.c |   13 -
 arch/ia64/kernel/irq_ia64.c |2 ++
 arch/ia64/xen/irq_xen.c |   10 +-
 arch/m32r/kernel/smp.c  |4 +---
 arch/mips/kernel/smtc.c |2 +-
 arch/mips/sibyte/bcm1480/smp.c  |7 +++
 arch/mips/sibyte/sb1250/smp.c   |7 +++
 arch/mn10300/kernel/smp.c   |5 +
 arch/parisc/kernel/smp.c|5 +
 arch/powerpc/kernel/smp.c   |2 +-
 arch/s390/kernel/smp.c  |6 +++---
 arch/sh/kernel/smp.c|2 ++
 arch/sparc/kernel/smp_32.c  |2 +-
 arch/sparc/kernel/smp_64.c  |1 +
 arch/tile/kernel/smp.c  |6 +-
 arch/um/kernel/smp.c|2 +-
 arch/x86/kernel/smp.c   |5 ++---
 arch/x86/xen/smp.c  |5 ++---
 include/linux/sched.h   |1 +
 22 files changed, 48 insertions(+), 52 deletions(-)

Index: linux-2.6/arch/alpha/kernel/smp.c
===
--- linux-2.6.orig/arch/alpha/kernel/smp.c
+++ linux-2.6/arch/alpha/kernel/smp.c
@@ -585,8 +585,7 @@ handle_ipi(struct pt_regs *regs)
 
switch (which) {
case IPI_RESCHEDULE:
-   /* Reschedule callback.  Everything to be done
-  is done by the interrupt return path.  */
+   scheduler_ipi();
break;
 
case IPI_CALL_FUNC:
Index: linux-2.6/arch/arm/kernel/smp.c
===
--- linux-2.6.orig/arch/arm/kernel/smp.c
+++ linux-2.6/arch/arm/kernel/smp.c
@@ -575,10 +575,7 @@ asmlinkage void __exception do_IPI(struc
break;
 
case IPI_RESCHEDULE:
-   /*
-* nothing more to do - eveything is
-* done on the interrupt return path
-*/
+   scheduler_ipi();
break;
 
case IPI_CALL_FUNC:
Index: linux-2.6/arch/blackfin/mach-common/smp.c
===
--- linux-2.6.orig/arch/blackfin/mach-common/smp.c
+++ linux-2.6/arch/blackfin/mach-common/smp.c
@@ -154,8 +154,7 @@ static irqreturn_t ipi_handler(int irq, 
list_del(msg-list);
switch (msg-type) {
case BFIN_IPI_RESCHEDULE:
-   /* That's the easiest one; leave it to
-* return_from_int. */
+   scheduler_ipi();
kfree(msg);
break;
case BFIN_IPI_CALL_FUNC:
@@ -301,7 +300,7 @@ void smp_send_reschedule(int cpu)
 
msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
if (!msg)
-   return;
+   return; /* XXX unreliable needs fixing ! */
INIT_LIST_HEAD(msg-list);
msg-type = BFIN_IPI_RESCHEDULE;
 
Index: linux-2.6/arch/cris/arch-v32/kernel/smp.c
===
--- linux-2.6.orig/arch/cris/arch-v32/kernel/smp.c
+++ linux-2.6/arch/cris/arch-v32/kernel/smp.c
@@ -340,15 +340,18 @@ irqreturn_t crisv32_ipi_interrupt(int ir
 
ipi = REG_RD(intr_vect, irq_regs[smp_processor_id()], rw_ipi);
 
+   if (ipi.vector  IPI_SCHEDULE) {
+   scheduler_ipi();
+   }
if (ipi.vector  IPI_CALL) {
-func(info);
+   func(info);
}
if 

Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Russell King - ARM Linux
On Mon, Jan 17, 2011 at 12:07:13PM +0100, Peter Zijlstra wrote:
 diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
 index 42aa078..c4a570b 100644
 --- a/arch/alpha/kernel/smp.c
 +++ b/arch/alpha/kernel/smp.c
 @@ -587,6 +587,7 @@ handle_ipi(struct pt_regs *regs)
   case IPI_RESCHEDULE:
   /* Reschedule callback.  Everything to be done
  is done by the interrupt return path.  */
 + scheduler_ipi();
   break;
  
   case IPI_CALL_FUNC:
 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
 index 9066473..ffde790 100644
 --- a/arch/arm/kernel/smp.c
 +++ b/arch/arm/kernel/smp.c
 @@ -579,6 +579,7 @@ asmlinkage void __exception do_IPI(struct pt_regs *regs)
* nothing more to do - eveything is
* done on the interrupt return path
*/
 + scheduler_ipi();

Maybe remove the comment everything is done on the interrupt return path
as with this function call, that is no longer the case.

Looks like the same is true for Alpha as well?
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Russell King - ARM Linux
On Mon, Jan 17, 2011 at 12:41:49PM +0100, Peter Zijlstra wrote:
 ===
 --- linux-2.6.orig/arch/arm/kernel/smp.c
 +++ linux-2.6/arch/arm/kernel/smp.c
 @@ -575,10 +575,7 @@ asmlinkage void __exception do_IPI(struc
   break;
  
   case IPI_RESCHEDULE:
 - /*
 -  * nothing more to do - eveything is
 -  * done on the interrupt return path
 -  */
 + scheduler_ipi();
   break;
  
   case IPI_CALL_FUNC:

Acked-by: Russell King rmk+ker...@arm.linux.org.uk
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Martin Schwidefsky
On Mon, 17 Jan 2011 12:07:13 +0100
Peter Zijlstra pet...@infradead.org wrote:

 I visited existing smp_send_reschedule() implementations and tried to
 add a call to scheduler_ipi() in their handler part, but esp. for MIPS
 I'm not quite sure I actually got all of them.
  
 diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
 index 94cf510..61789e8 100644
 --- a/arch/s390/kernel/smp.c
 +++ b/arch/s390/kernel/smp.c
 @@ -163,12 +163,12 @@ static void do_ext_call_interrupt(unsigned int 
 ext_int_code,
  
   /*
* handle bit signal external calls
 -  *
 -  * For the ec_schedule signal we have to do nothing. All the work
 -  * is done automatically when we return from the interrupt.
*/
   bits = xchg(S390_lowcore.ext_call_fast, 0);
  
 + if (test_bit(ec_schedule, bits))
 + scheduler_ipi();
 +
   if (test_bit(ec_call_function, bits))
   generic_smp_call_function_interrupt();
  

s390 bits are fine.

-- 
blue skies,
   Martin.

Reality continues to ruin my life. - Calvin.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Chris Metcalf
On 1/17/2011 6:41 AM, Peter Zijlstra wrote:
 Index: linux-2.6/arch/tile/kernel/smp.c
 ===
 --- linux-2.6.orig/arch/tile/kernel/smp.c
 +++ linux-2.6/arch/tile/kernel/smp.c
 @@ -184,12 +184,8 @@ void flush_icache_range(unsigned long st
  /* Called when smp_send_reschedule() triggers IRQ_RESCHEDULE. */
  static irqreturn_t handle_reschedule_ipi(int irq, void *token)
  {
 -   /*
 -* Nothing to do here; when we return from interrupt, the
 -* rescheduling will occur there. But do bump the interrupt
 -* profiler count in the meantime.
 -*/
 __get_cpu_var(irq_stat).irq_resched_count++;
 +   scheduler_ipi();

 return IRQ_HANDLED;
  }

Acked-by: Chris Metcalf cmetc...@tilera.com

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Jesper Nilsson
On Mon, Jan 17, 2011 at 12:41:49PM +0100, Peter Zijlstra wrote:
 Index: linux-2.6/arch/cris/arch-v32/kernel/smp.c
 ===
 --- linux-2.6.orig/arch/cris/arch-v32/kernel/smp.c
 +++ linux-2.6/arch/cris/arch-v32/kernel/smp.c
 @@ -340,15 +340,18 @@ irqreturn_t crisv32_ipi_interrupt(int ir
 
 ipi = REG_RD(intr_vect, irq_regs[smp_processor_id()], rw_ipi);
 
 +   if (ipi.vector  IPI_SCHEDULE) {
 +   scheduler_ipi();
 +   }
 if (ipi.vector  IPI_CALL) {
 -func(info);
 +   func(info);
 }
 if (ipi.vector  IPI_FLUSH_TLB) {
 -if (flush_mm == FLUSH_ALL)
 -__flush_tlb_all();
 -else if (flush_vma == FLUSH_ALL)
 +   if (flush_mm == FLUSH_ALL)
 +   __flush_tlb_all();
 +   else if (flush_vma == FLUSH_ALL)
 __flush_tlb_mm(flush_mm);
 -else
 +   else
 __flush_tlb_page(flush_vma, flush_addr);
 }
 

Acked-by: Jesper Nilsson jesper.nils...@axis.com

/^JN - Jesper Nilsson
-- 
   Jesper Nilsson -- jesper.nils...@axis.com
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread David Daney

On 01/17/2011 03:07 AM, Peter Zijlstra wrote:

For future rework of try_to_wake_up() we'd like to push part of that
onto the CPU the task is actually going to run on, in order to do so we
need a generic callback from the existing scheduler IPI.

This patch introduces such a generic callback: scheduler_ipi() and
implements it as a NOP.

I visited existing smp_send_reschedule() implementations and tried to
add a call to scheduler_ipi() in their handler part, but esp. for MIPS
I'm not quite sure I actually got all of them.

Also, while reading through all this, I noticed the blackfin SMP code
looks to be broken, it simply discards any IPI when low on memory.

Signed-off-by: Peter Zijlstraa.p.zijls...@chello.nl
---
  arch/alpha/kernel/smp.c |1 +
  arch/arm/kernel/smp.c   |1 +
  arch/blackfin/mach-common/smp.c |3 ++-
  arch/cris/arch-v32/kernel/smp.c |   13 -
  arch/ia64/kernel/irq_ia64.c |2 ++
  arch/ia64/xen/irq_xen.c |   10 +-
  arch/m32r/kernel/smp.c  |2 +-
  arch/mips/kernel/smtc.c |1 +
  arch/mips/sibyte/bcm1480/smp.c  |7 +++
  arch/mips/sibyte/sb1250/smp.c   |7 +++

[...]

Peter,

You will also have to patch the mailbox_interrupt() function in 
arch/mips/cavium-octeon/smp.c


David Daney.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [uclinux-dist-devel] [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Mike Frysinger
On Mon, Jan 17, 2011 at 06:07, Peter Zijlstra wrote:
 Also, while reading through all this, I noticed the blackfin SMP code
 looks to be broken, it simply discards any IPI when low on memory.

not really.  see changelog of commit 73a400646b8e26615f3ef1a0a4bc0cd0d5bd284c.
-mike
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [uclinux-dist-devel] [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Peter Zijlstra
On Mon, 2011-01-17 at 14:49 -0500, Mike Frysinger wrote:
 On Mon, Jan 17, 2011 at 06:07, Peter Zijlstra wrote:
  Also, while reading through all this, I noticed the blackfin SMP code
  looks to be broken, it simply discards any IPI when low on memory.
 
 not really.  see changelog of commit 73a400646b8e26615f3ef1a0a4bc0cd0d5bd284c.

Ah, indeed, it appears my tree was simply out of date, very good!
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Benjamin Herrenschmidt
On Mon, 2011-01-17 at 12:07 +0100, Peter Zijlstra wrote:
 For future rework of try_to_wake_up() we'd like to push part of that
 onto the CPU the task is actually going to run on, in order to do so we
 need a generic callback from the existing scheduler IPI.
 
 This patch introduces such a generic callback: scheduler_ipi() and
 implements it as a NOP.
 
 I visited existing smp_send_reschedule() implementations and tried to
 add a call to scheduler_ipi() in their handler part, but esp. for MIPS
 I'm not quite sure I actually got all of them.
 
 Also, while reading through all this, I noticed the blackfin SMP code
 looks to be broken, it simply discards any IPI when low on memory.

Beware of false positive, I've used fake reschedule IPIs in the past
for other things (like kicking a CPU out of sleep state for unrelated
reasons). Nothing that I know that is upstream today but some of that
might come back. I'd like to avoid having to add an atomic to know if
it's a real reschedule, will the scheduler be smart enough to not bother
with false positives ?

Cheers,
Ben.

 Signed-off-by: Peter Zijlstra a.p.zijls...@chello.nl
 ---
  arch/alpha/kernel/smp.c |1 +
  arch/arm/kernel/smp.c   |1 +
  arch/blackfin/mach-common/smp.c |3 ++-
  arch/cris/arch-v32/kernel/smp.c |   13 -
  arch/ia64/kernel/irq_ia64.c |2 ++
  arch/ia64/xen/irq_xen.c |   10 +-
  arch/m32r/kernel/smp.c  |2 +-
  arch/mips/kernel/smtc.c |1 +
  arch/mips/sibyte/bcm1480/smp.c  |7 +++
  arch/mips/sibyte/sb1250/smp.c   |7 +++
  arch/mn10300/kernel/smp.c   |2 +-
  arch/parisc/kernel/smp.c|1 +
  arch/powerpc/kernel/smp.c   |1 +
  arch/s390/kernel/smp.c  |6 +++---
  arch/sh/kernel/smp.c|2 ++
  arch/sparc/kernel/smp_32.c  |2 +-
  arch/sparc/kernel/smp_64.c  |1 +
  arch/tile/kernel/smp.c  |1 +
  arch/um/kernel/smp.c|2 +-
  arch/x86/kernel/smp.c   |1 +
  arch/x86/xen/smp.c  |1 +
  include/linux/sched.h   |1 +
  22 files changed, 46 insertions(+), 22 deletions(-)
 
 diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
 index 42aa078..c4a570b 100644
 --- a/arch/alpha/kernel/smp.c
 +++ b/arch/alpha/kernel/smp.c
 @@ -587,6 +587,7 @@ handle_ipi(struct pt_regs *regs)
   case IPI_RESCHEDULE:
   /* Reschedule callback.  Everything to be done
  is done by the interrupt return path.  */
 + scheduler_ipi();
   break;
  
   case IPI_CALL_FUNC:
 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
 index 9066473..ffde790 100644
 --- a/arch/arm/kernel/smp.c
 +++ b/arch/arm/kernel/smp.c
 @@ -579,6 +579,7 @@ asmlinkage void __exception do_IPI(struct pt_regs *regs)
* nothing more to do - eveything is
* done on the interrupt return path
*/
 + scheduler_ipi();
   break;
  
   case IPI_CALL_FUNC:
 diff --git a/arch/blackfin/mach-common/smp.c b/arch/blackfin/mach-common/smp.c
 index a17107a..e210f8a 100644
 --- a/arch/blackfin/mach-common/smp.c
 +++ b/arch/blackfin/mach-common/smp.c
 @@ -156,6 +156,7 @@ static irqreturn_t ipi_handler(int irq, void 
 *dev_instance)
   case BFIN_IPI_RESCHEDULE:
   /* That's the easiest one; leave it to
* return_from_int. */
 + scheduler_ipi();
   kfree(msg);
   break;
   case BFIN_IPI_CALL_FUNC:
 @@ -301,7 +302,7 @@ void smp_send_reschedule(int cpu)
  
   msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
   if (!msg)
 - return;
 + return; /* XXX unreliable needs fixing ! */
   INIT_LIST_HEAD(msg-list);
   msg-type = BFIN_IPI_RESCHEDULE;
  
 diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
 index 84fed3b..86e3c76 100644
 --- a/arch/cris/arch-v32/kernel/smp.c
 +++ b/arch/cris/arch-v32/kernel/smp.c
 @@ -340,15 +340,18 @@ irqreturn_t crisv32_ipi_interrupt(int irq, void *dev_id)
  
   ipi = REG_RD(intr_vect, irq_regs[smp_processor_id()], rw_ipi);
  
 + if (ipi.vector  IPI_SCHEDULE) {
 + scheduler_ipi();
 + }
   if (ipi.vector  IPI_CALL) {
 -  func(info);
 + func(info);
   }
   if (ipi.vector  IPI_FLUSH_TLB) {
 -  if (flush_mm == FLUSH_ALL)
 -  __flush_tlb_all();
 -  else if (flush_vma == FLUSH_ALL)
 + if (flush_mm == FLUSH_ALL)
 + __flush_tlb_all();
 + else if (flush_vma == FLUSH_ALL)
   __flush_tlb_mm(flush_mm);
 -  else
 + else

Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-01-17 Thread Peter Zijlstra
On Tue, 2011-01-18 at 07:31 +1100, Benjamin Herrenschmidt wrote:
 
 Beware of false positive, I've used fake reschedule IPIs in the past
 for other things (like kicking a CPU out of sleep state for unrelated
 reasons). Nothing that I know that is upstream today but some of that
 might come back. I'd like to avoid having to add an atomic to know if
 it's a real reschedule, will the scheduler be smart enough to not bother
 with false positives ? 

Yes it can deal with that, some will be for reschedules, some will be
for ttwu tail ends and x86 too uses this ipi for a few random other
things like kicking kvm out of guest context..
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev