Re: [RFC] [patch 4/6 -rt] powerpc 2.6.20-rt8: fix a runtime warnings for xmon

2007-03-07 Thread Arnd Bergmann
On Wednesday 07 March 2007, Ingo Molnar wrote:
> i'm not an xmon expert, but maybe it might make more sense to first 
> disable preemption, then interrupts - otherwise you could be preempted 
> right after having disabled these interrupts (and be scheduled to 
> another CPU, etc.). What is the difference between local_irq_save() and 
> the above 'disable interrupts' sequence? If it's not the same and 
> xmon_core() relied on having hardirqs disabled then it might make sense 
> to do a local_irq_save() there, instead of a preempt_disable().

Since relatively recently, powerpc does no longer actually disable
the hardware interrupts with local_irq_disable(), but rather sets
a per-cpu flag that will be checked if an actual interrupt comes
in as part of the critical section.

The mtmsr() sequence in xmon corresponds to hard_irq_disable()
and should probably changed to that, but then you still need
the extra preempt_disable() / preempt_enable().

I think you're right about the sequence having to be
1. preempt_disable()
2. hard_irq_disable()
3.
4. hard_irq_enable()
5. preempt_enable()

Arnd <><
-
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: [RFC] [patch 4/6 -rt] powerpc 2.6.20-rt8: fix a runtime warnings for xmon

2007-03-07 Thread Tsutomu OWA

At Wed, 07 Mar 2007 11:10:59 +0100,
Benjamin Herrenschmidt wrote:
> 
> On Wed, 2007-03-07 at 10:16 +0100, Ingo Molnar wrote:
> > * Tsutomu OWA <[EMAIL PROTECTED]> wrote:
> > 
> > > @@ -342,6 +342,7 @@ static int xmon_core(struct pt_regs *reg
> > >  
> > >   msr = mfmsr();
> > >   mtmsr(msr & ~MSR_EE);   /* disable interrupts */
> > > + preempt_disable();
> > 
> > i'm not an xmon expert, but maybe it might make more sense to first 
> > disable preemption, then interrupts - otherwise you could be preempted 
> > right after having disabled these interrupts (and be scheduled to 
> > another CPU, etc.). What is the difference between local_irq_save() and 
> > the above 'disable interrupts' sequence? If it's not the same and 
> > xmon_core() relied on having hardirqs disabled then it might make sense 
> > to do a local_irq_save() there, instead of a preempt_disable().
> 
> powerpc 64 bits nowadays does lazy HW masking, so local_irq_disable()
> will not actually switch MSR_EE off. However, xmon needs that to happen
> (though we have a nicer accessor to do it, I suspect some bitrot need
> fixing in there, possibly already fixed in .21)
> 
> I agree that preempt_disable() should be put before the MSR tweaking
> though.

  As all of you said, I'm resending the patch here.  

  To fix the following runtime warnings when entering xmon.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Entering xmon
BUG: using smp_processor_id() in preemptible [] code: khvcd/280
caller is .xmon_core+0xb8/0x8ec
Call Trace:
[CFD737C0] [C000FAAC] .show_stack+0x68/0x1b0 (unreliable)
[CFD73860] [C01F71F0] .debug_smp_processor_id+0xc8/0xf8
[CFD738F0] [C004AF30] .xmon_core+0xb8/0x8ec
[CFD73A80] [C004B918] .xmon+0x38/0x4c
[CFD73C60] [C004BA8C] .sysrq_handle_xmon+0x48/0x5c
[CFD73CD0] [C0243A68] .__handle_sysrq+0xe0/0x1b0
[CFD73D70] [C0244974] .hvc_poll+0x18c/0x2b4
[CFD73E50] [C0244E80] .khvcd+0x88/0x164
[CFD73EE0] [C0075014] .kthread+0x124/0x174
[CFD73F90] [C0023D48] .kernel_thread+0x4c/0x68
BUG: khvcd:280 task might have lost a preemption check!
Call Trace:
[CFD73740] [C000FAAC] .show_stack+0x68/0x1b0 (unreliable)
[CFD737E0] [C0054920] .preempt_enable_no_resched+0x64/0x7c
[CFD73860] [C01F71F8] .debug_smp_processor_id+0xd0/0xf8
[CFD738F0] [C004AF30] .xmon_core+0xb8/0x8ec
[CFD73A80] [C004B918] .xmon+0x38/0x4c
[CFD73C60] [C004BA8C] .sysrq_handle_xmon+0x48/0x5c
[CFD73CD0] [C0243A68] .__handle_sysrq+0xe0/0x1b0
[CFD73D70] [C0244974] .hvc_poll+0x18c/0x2b4
[CFD73E50] [C0244E80] .khvcd+0x88/0x164
[CFD73EE0] [C0075014] .kthread+0x124/0x174
[CFD73F90] [C0023D48] .kernel_thread+0x4c/0x68
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

thanks a lot!

Signed-off-by: Tsutomu Owa <[EMAIL PROTECTED]>
-- owa

--- linux-rt8/arch/powerpc/xmon/xmon.c  2007-02-20 09:38:52.0 +0900
+++ rt/arch/powerpc/xmon/xmon.c 2007-03-07 19:49:38.0 +0900
@@ -340,6 +340,7 @@ static int xmon_core(struct pt_regs *reg
unsigned long timeout;
 #endif
 
+   preempt_disable();
msr = mfmsr();
mtmsr(msr & ~MSR_EE);   /* disable interrupts */
 
@@ -517,6 +518,7 @@ static int xmon_core(struct pt_regs *reg
insert_cpu_bpts();
 
mtmsr(msr); /* restore interrupt enable */
+   preempt_enable();
 
return cmd != 'X' && cmd != EOF;
 }
-
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: [RFC] [patch 4/6 -rt] powerpc 2.6.20-rt8: fix a runtime warnings for xmon

2007-03-07 Thread Benjamin Herrenschmidt
On Wed, 2007-03-07 at 10:16 +0100, Ingo Molnar wrote:
> * Tsutomu OWA <[EMAIL PROTECTED]> wrote:
> 
> > @@ -342,6 +342,7 @@ static int xmon_core(struct pt_regs *reg
> >  
> > msr = mfmsr();
> > mtmsr(msr & ~MSR_EE);   /* disable interrupts */
> > +   preempt_disable();
> 
> i'm not an xmon expert, but maybe it might make more sense to first 
> disable preemption, then interrupts - otherwise you could be preempted 
> right after having disabled these interrupts (and be scheduled to 
> another CPU, etc.). What is the difference between local_irq_save() and 
> the above 'disable interrupts' sequence? If it's not the same and 
> xmon_core() relied on having hardirqs disabled then it might make sense 
> to do a local_irq_save() there, instead of a preempt_disable().

powerpc 64 bits nowadays does lazy HW masking, so local_irq_disable()
will not actually switch MSR_EE off. However, xmon needs that to happen
(though we have a nicer accessor to do it, I suspect some bitrot need
fixing in there, possibly already fixed in .21)

I agree that preempt_disable() should be put before the MSR tweaking
though.

Ben.


-
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: [RFC] [patch 4/6 -rt] powerpc 2.6.20-rt8: fix a runtime warnings for xmon

2007-03-07 Thread Ingo Molnar

* Tsutomu OWA <[EMAIL PROTECTED]> wrote:

> @@ -342,6 +342,7 @@ static int xmon_core(struct pt_regs *reg
>  
>   msr = mfmsr();
>   mtmsr(msr & ~MSR_EE);   /* disable interrupts */
> + preempt_disable();

i'm not an xmon expert, but maybe it might make more sense to first 
disable preemption, then interrupts - otherwise you could be preempted 
right after having disabled these interrupts (and be scheduled to 
another CPU, etc.). What is the difference between local_irq_save() and 
the above 'disable interrupts' sequence? If it's not the same and 
xmon_core() relied on having hardirqs disabled then it might make sense 
to do a local_irq_save() there, instead of a preempt_disable().

Ingo
-
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/


[RFC] [patch 4/6 -rt] powerpc 2.6.20-rt8: fix a runtime warnings for xmon

2007-03-06 Thread Tsutomu OWA

  To fix the following runtime warnings when entering xmon.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Entering xmon
BUG: using smp_processor_id() in preemptible [] code: khvcd/280
caller is .xmon_core+0xb8/0x8ec
Call Trace:
[CFD737C0] [C000FAAC] .show_stack+0x68/0x1b0 (unreliable)
[CFD73860] [C01F71F0] .debug_smp_processor_id+0xc8/0xf8
[CFD738F0] [C004AF30] .xmon_core+0xb8/0x8ec
[CFD73A80] [C004B918] .xmon+0x38/0x4c
[CFD73C60] [C004BA8C] .sysrq_handle_xmon+0x48/0x5c
[CFD73CD0] [C0243A68] .__handle_sysrq+0xe0/0x1b0
[CFD73D70] [C0244974] .hvc_poll+0x18c/0x2b4
[CFD73E50] [C0244E80] .khvcd+0x88/0x164
[CFD73EE0] [C0075014] .kthread+0x124/0x174
[CFD73F90] [C0023D48] .kernel_thread+0x4c/0x68
BUG: khvcd:280 task might have lost a preemption check!
Call Trace:
[CFD73740] [C000FAAC] .show_stack+0x68/0x1b0 (unreliable)
[CFD737E0] [C0054920] .preempt_enable_no_resched+0x64/0x7c
[CFD73860] [C01F71F8] .debug_smp_processor_id+0xd0/0xf8
[CFD738F0] [C004AF30] .xmon_core+0xb8/0x8ec
[CFD73A80] [C004B918] .xmon+0x38/0x4c
[CFD73C60] [C004BA8C] .sysrq_handle_xmon+0x48/0x5c
[CFD73CD0] [C0243A68] .__handle_sysrq+0xe0/0x1b0
[CFD73D70] [C0244974] .hvc_poll+0x18c/0x2b4
[CFD73E50] [C0244E80] .khvcd+0x88/0x164
[CFD73EE0] [C0075014] .kthread+0x124/0x174
[CFD73F90] [C0023D48] .kernel_thread+0x4c/0x68
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

  I'd appreciate if experts on xmon would give any comments/suggestions
on this.  These warnings was just found yesterday, this patch seems to
eliminate the warnings but I have not looked into it seriously.

Signed-off-by: Tsutomu Owa <[EMAIL PROTECTED]>
-- owa

diff -rup linux-rt8/arch/powerpc/xmon/xmon.c rt/arch/powerpc/xmon/xmon.c
--- linux-rt8/arch/powerpc/xmon/xmon.c  2007-02-20 09:38:52.0 +0900
+++ rt/arch/powerpc/xmon/xmon.c 2007-03-05 15:29:46.0 +0900
@@ -342,6 +342,7 @@ static int xmon_core(struct pt_regs *reg
 
msr = mfmsr();
mtmsr(msr & ~MSR_EE);   /* disable interrupts */
+   preempt_disable();
 
bp = in_breakpoint_table(regs->nip, &offset);
if (bp != NULL) {
@@ -516,6 +517,7 @@ static int xmon_core(struct pt_regs *reg
 
insert_cpu_bpts();
 
+   preempt_enable();
mtmsr(msr); /* restore interrupt enable */
 
return cmd != 'X' && cmd != EOF;

-
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/