Re: [PATCH] rwsem: Make rwsems use interrupt disabling spinlocks

2005-03-11 Thread Ingo Molnar

* Andrew Morton <[EMAIL PROTECTED]> wrote:

> We should arrange for touch_softlockup_watchdog() to be called
> whenever touch_nmi_watchdog() is called.

the patch below adds a touch_softlockup_watchdog() call to every
touch_nmi_watchdog() call.

[A future consolidation patch should introduce a touch_watchdogs() call
that will do both a touch_nmi_watchdog() [if available on the platform]
and a touch_softlockup_watchdog() call.]

Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>

--- linux/arch/x86_64/kernel/nmi.c.orig
+++ linux/arch/x86_64/kernel/nmi.c
@@ -378,6 +378,11 @@ void touch_nmi_watchdog (void)
 */
for (i = 0; i < NR_CPUS; i++)
alert_counter[i] = 0;
+
+   /*
+* Tickle the softlockup detector too:
+*/
+   touch_softlockup_watchdog();
 }
 
 void nmi_watchdog_tick (struct pt_regs * regs, unsigned reason)
--- linux/arch/i386/kernel/nmi.c.orig
+++ linux/arch/i386/kernel/nmi.c
@@ -469,6 +469,11 @@ void touch_nmi_watchdog (void)
 */
for (i = 0; i < NR_CPUS; i++)
alert_counter[i] = 0;
+
+   /*
+* Tickle the softlockup detector too:
+*/
+   touch_softlockup_watchdog();
 }
 
 extern void die_nmi(struct pt_regs *, const char *msg);
-
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] rwsem: Make rwsems use interrupt disabling spinlocks

2005-03-11 Thread Andrew Morton
Ingo Molnar <[EMAIL PROTECTED]> wrote:
>
> 
> * Arjan van de Ven <[EMAIL PROTECTED]> wrote:
> 
> > > Ingo, we already have a touch_nmi_watchdog() in the sysrq code.  It might 
> > > be
> > > worth adding a touch_softlockup_watchdog() wherever we have a
> > > touch_nmi_watchdog().
> > 
> > or add touch_softlockup_watchdog to touch_nmi_watchdog() instead
> > and rename it tickle_watchdog() overtime.
> 
> you mean like:
> 
> +extern void touch_softlockup_watchdog(void);
> 
> in:
> 
>  
> http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.11/2.6.11-mm2/broken-out/detect-soft-lockups.patch
> 
> ?
> 

Nope.

This particular lockup happened because a huge stream of stuff was sent to
the serial console.

We already have a touch_nmi_watchdog() in that code.

We should arrange for touch_softlockup_watchdog() to be called whenever
touch_nmi_watchdog() is called.

-
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] rwsem: Make rwsems use interrupt disabling spinlocks

2005-03-11 Thread Ingo Molnar

* Arjan van de Ven <[EMAIL PROTECTED]> wrote:

> > Ingo, we already have a touch_nmi_watchdog() in the sysrq code.  It might be
> > worth adding a touch_softlockup_watchdog() wherever we have a
> > touch_nmi_watchdog().
> 
> or add touch_softlockup_watchdog to touch_nmi_watchdog() instead
> and rename it tickle_watchdog() overtime.

you mean like:

+extern void touch_softlockup_watchdog(void);

in:

 
http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.11/2.6.11-mm2/broken-out/detect-soft-lockups.patch

?

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/


Re: [PATCH] rwsem: Make rwsems use interrupt disabling spinlocks

2005-03-09 Thread Arjan van de Ven

> Ingo, we already have a touch_nmi_watchdog() in the sysrq code.  It might be
> worth adding a touch_softlockup_watchdog() wherever we have a
> touch_nmi_watchdog().

or add touch_softlockup_watchdog to touch_nmi_watchdog() instead
and rename it tickle_watchdog() overtime.

-
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] rwsem: Make rwsems use interrupt disabling spinlocks

2005-03-09 Thread Andrew Morton
Badari Pulavarty <[EMAIL PROTECTED]> wrote:
>
>  I am not sure if this is related to your patch. But I ran into
>  BUG() with sysrq-t with your patch.
> 
>  Thanks,
>  Badari
> 
>  BUG: soft lockup detected on CPU#1!
>  
>  Modules linked in: joydev sg st floppy usbserial parport_pc lp parport
>  ipv6 ohci_hcd i2c_amd756 i2c_core evdev usbcore raid0 dm_mod nls_utf8
>  Pid: 15433, comm: bash Not tainted 2.6.11-mm1n
>  RIP: 0010:[] {__do_softirq+84}
>  RSP: 0018:8101dff83f68  EFLAGS: 0206
>  RAX: 80651880 RBX: 0002 RCX: 0004
>  RDX: 0002 RSI: 0103 RDI: 8101d7c77680
>  RBP: 810177ffbe48 R08: 0002 R09: 0100
>  R10: 0001 R11:  R12: 0001
>  R13: 2aafb000 R14: 000a R15: 0001
>  FS:  2b2890a0() GS:80651880()
>  knlGS:
>  CS:  0010 DS:  ES:  CR0: 8005003b
>  CR2: 2aafb000 CR3: 0001bb2a CR4: 06e0
>
>  Call Trace: {do_softirq+53}
>  {apic_timer_interrupt+133}
>   {_spin_unlock_irqrestore+5}
> {write_sysrq_trigger+55}
>  {vfs_write+233}
> {sys_write+83}
>  {system_call+126}

That's probably just a false positive in Ingo's soft-lockup detector.  Long
streams of irq-context serial console output will do that.

Ingo, we already have a touch_nmi_watchdog() in the sysrq code.  It might be
worth adding a touch_softlockup_watchdog() wherever we have a
touch_nmi_watchdog().
-
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] rwsem: Make rwsems use interrupt disabling spinlocks

2005-03-09 Thread Badari Pulavarty
Well, aio-stress seems to run better with your patch (no Oops) but
I think we still have a problem in AIO. It looks like aio-stress
is stuck (unable to kill it).

Here is the sysrq-t output:

aio-stressD 8101be224970 0 15430  1   15429
(NOTLB)
8101be21bd58 0082 8101be21be18 0001
   8101be2248b0 81010074 007a
810198868e90
   8101d6daaf50 8101d6dab160
Call Trace:{__down+152}
{default_wake_function+0}
   {__down_failed+53}
{.text.lock.filemap+65}
   {aio_pwrite+0}
{aio_pwrite+33}
   {__aio_run_iocbs+384}
{io_submit_one+494}
   {sys_io_submit+217}
{system_call+126}


Top shows:

top - 12:22:33 up  2:57,  2 users,  load average: 5.08, 5.08, 5.01
Tasks:  79 total,   1 running,  77 sleeping,   0 stopped,   1 zombie
Cpu(s):  0.0% us, 25.0% sy,  0.0% ni, 75.0% id,  0.0% wa,  0.0% hi, 
0.0% si
Mem:   7148100k total,   176708k used,  6971392k free,18600k buffers
Swap:  1048784k total,0k used,  1048784k free,44708k cached


  PID USER  PR  NI  VIRT  RES  SHR S %CPU %MEMTIME+  COMMAND
15425 root  16   0 000 Z 99.8  0.0 172:17.98 aio-stress

15803 root  16   0  4048 1116  820 R  0.3  0.0   0:00.51 top



Thanks,
Badari


On Wed, 2005-03-09 at 09:35, Badari Pulavarty wrote:
> Your patch seems to have helped. I don't see the Oops anymore - my
> tests are still running (past 1 hour - it used to panic in 10 min).
> 
> Thanks,
> Badari
> 
> On Wed, 2005-03-09 at 04:12, David Howells wrote:
> > The attached patch makes read/write semaphores use interrupt disabling
> > spinlocks, thus rendering the up functions and trylock functions available 
> > for
> > use in interrupt context.
> > 
> > I've assumed that the normal down functions must be called with interrupts
> > enabled (since they might schedule), and used the irq-disabling spinlock
> > variants that don't save the flags.
> > 
> > Signed-Off-By: David Howells <[EMAIL PROTECTED]>
> > ---
> > warthog>diffstat -p1 rwsem-irqspin-2611mm2.diff
> 
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-aio' in
> the body to [EMAIL PROTECTED]  For more info on Linux AIO,
> see: http://www.kvack.org/aio/
> Don't email: mailto:"[EMAIL PROTECTED]">[EMAIL PROTECTED]
> 

-
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] rwsem: Make rwsems use interrupt disabling spinlocks

2005-03-09 Thread Badari Pulavarty
Hi,

I am not sure if this is related to your patch. But I ran into
BUG() with sysrq-t with your patch.

Thanks,
Badari

BUG: soft lockup detected on CPU#1!

Modules linked in: joydev sg st floppy usbserial parport_pc lp parport
ipv6 ohci_hcd i2c_amd756 i2c_core evdev usbcore raid0 dm_mod nls_utf8
Pid: 15433, comm: bash Not tainted 2.6.11-mm1n
RIP: 0010:[] {__do_softirq+84}
RSP: 0018:8101dff83f68  EFLAGS: 0206
RAX: 80651880 RBX: 0002 RCX: 0004
RDX: 0002 RSI: 0103 RDI: 8101d7c77680
RBP: 810177ffbe48 R08: 0002 R09: 0100
R10: 0001 R11:  R12: 0001
R13: 2aafb000 R14: 000a R15: 0001
FS:  2b2890a0() GS:80651880()
knlGS:
CS:  0010 DS:  ES:  CR0: 8005003b
CR2: 2aafb000 CR3: 0001bb2a CR4: 06e0
  
Call Trace: {do_softirq+53}
{apic_timer_interrupt+133}
 {_spin_unlock_irqrestore+5}
   {write_sysrq_trigger+55}
{vfs_write+233}
   {sys_write+83}
{system_call+126}


On Wed, 2005-03-09 at 04:12, David Howells wrote:
> The attached patch makes read/write semaphores use interrupt disabling
> spinlocks, thus rendering the up functions and trylock functions available for
> use in interrupt context.
> 
> I've assumed that the normal down functions must be called with interrupts
> enabled (since they might schedule), and used the irq-disabling spinlock
> variants that don't save the flags.
> 
> Signed-Off-By: David Howells <[EMAIL PROTECTED]>


-
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] rwsem: Make rwsems use interrupt disabling spinlocks

2005-03-09 Thread Badari Pulavarty
Your patch seems to have helped. I don't see the Oops anymore - my
tests are still running (past 1 hour - it used to panic in 10 min).

Thanks,
Badari

On Wed, 2005-03-09 at 04:12, David Howells wrote:
> The attached patch makes read/write semaphores use interrupt disabling
> spinlocks, thus rendering the up functions and trylock functions available for
> use in interrupt context.
> 
> I've assumed that the normal down functions must be called with interrupts
> enabled (since they might schedule), and used the irq-disabling spinlock
> variants that don't save the flags.
> 
> Signed-Off-By: David Howells <[EMAIL PROTECTED]>
> ---
> warthog>diffstat -p1 rwsem-irqspin-2611mm2.diff


-
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] rwsem: Make rwsems use interrupt disabling spinlocks

2005-03-09 Thread David Howells

The attached patch makes read/write semaphores use interrupt disabling
spinlocks, thus rendering the up functions and trylock functions available for
use in interrupt context.

I've assumed that the normal down functions must be called with interrupts
enabled (since they might schedule), and used the irq-disabling spinlock
variants that don't save the flags.

Signed-Off-By: David Howells <[EMAIL PROTECTED]>
---
warthog>diffstat -p1 rwsem-irqspin-2611mm2.diff
 lib/rwsem-spinlock.c |   42 ++
 lib/rwsem.c  |   16 ++--
 2 files changed, 36 insertions(+), 22 deletions(-)

diff -uNrp linux-2.6.11-mm2/lib/rwsem.c linux-2.6.11-mm2-rwsem/lib/rwsem.c
--- linux-2.6.11-mm2/lib/rwsem.c2004-10-19 10:42:19.0 +0100
+++ linux-2.6.11-mm2-rwsem/lib/rwsem.c  2005-03-09 10:45:16.0 +
@@ -150,7 +150,7 @@ rwsem_down_failed_common(struct rw_semap
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
 
/* set up my own style of waitqueue */
-   spin_lock(&sem->wait_lock);
+   spin_lock_irq(&sem->wait_lock);
waiter->task = tsk;
get_task_struct(tsk);
 
@@ -163,7 +163,7 @@ rwsem_down_failed_common(struct rw_semap
if (!(count & RWSEM_ACTIVE_MASK))
sem = __rwsem_do_wake(sem, 0);
 
-   spin_unlock(&sem->wait_lock);
+   spin_unlock_irq(&sem->wait_lock);
 
/* wait to be given the lock */
for (;;) {
@@ -219,15 +219,17 @@ rwsem_down_write_failed(struct rw_semaph
  */
 struct rw_semaphore fastcall *rwsem_wake(struct rw_semaphore *sem)
 {
+   unsigned long flags;
+
rwsemtrace(sem, "Entering rwsem_wake");
 
-   spin_lock(&sem->wait_lock);
+   spin_lock_irqsave(&sem->wait_lock, flags);
 
/* do nothing if list empty */
if (!list_empty(&sem->wait_list))
sem = __rwsem_do_wake(sem, 0);
 
-   spin_unlock(&sem->wait_lock);
+   spin_unlock_irqrestore(&sem->wait_lock, flags);
 
rwsemtrace(sem, "Leaving rwsem_wake");
 
@@ -241,15 +243,17 @@ struct rw_semaphore fastcall *rwsem_wake
  */
 struct rw_semaphore fastcall *rwsem_downgrade_wake(struct rw_semaphore *sem)
 {
+   unsigned long flags;
+
rwsemtrace(sem, "Entering rwsem_downgrade_wake");
 
-   spin_lock(&sem->wait_lock);
+   spin_lock_irqsave(&sem->wait_lock, flags);
 
/* do nothing if list empty */
if (!list_empty(&sem->wait_list))
sem = __rwsem_do_wake(sem, 1);
 
-   spin_unlock(&sem->wait_lock);
+   spin_unlock_irqrestore(&sem->wait_lock, flags);
 
rwsemtrace(sem, "Leaving rwsem_downgrade_wake");
return sem;
diff -uNrp linux-2.6.11-mm2/lib/rwsem-spinlock.c 
linux-2.6.11-mm2-rwsem/lib/rwsem-spinlock.c
--- linux-2.6.11-mm2/lib/rwsem-spinlock.c   2004-09-16 12:06:23.0 
+0100
+++ linux-2.6.11-mm2-rwsem/lib/rwsem-spinlock.c 2005-03-09 10:43:47.0 
+
@@ -140,12 +140,12 @@ void fastcall __sched __down_read(struct
 
rwsemtrace(sem, "Entering __down_read");
 
-   spin_lock(&sem->wait_lock);
+   spin_lock_irq(&sem->wait_lock);
 
if (sem->activity >= 0 && list_empty(&sem->wait_list)) {
/* granted */
sem->activity++;
-   spin_unlock(&sem->wait_lock);
+   spin_unlock_irq(&sem->wait_lock);
goto out;
}
 
@@ -160,7 +160,7 @@ void fastcall __sched __down_read(struct
list_add_tail(&waiter.list, &sem->wait_list);
 
/* we don't need to touch the semaphore struct anymore */
-   spin_unlock(&sem->wait_lock);
+   spin_unlock_irq(&sem->wait_lock);
 
/* wait to be given the lock */
for (;;) {
@@ -181,10 +181,12 @@ void fastcall __sched __down_read(struct
  */
 int fastcall __down_read_trylock(struct rw_semaphore *sem)
 {
+   unsigned long flags;
int ret = 0;
+
rwsemtrace(sem, "Entering __down_read_trylock");
 
-   spin_lock(&sem->wait_lock);
+   spin_lock_irqsave(&sem->wait_lock, flags);
 
if (sem->activity >= 0 && list_empty(&sem->wait_list)) {
/* granted */
@@ -192,7 +194,7 @@ int fastcall __down_read_trylock(struct 
ret = 1;
}
 
-   spin_unlock(&sem->wait_lock);
+   spin_unlock_irqrestore(&sem->wait_lock, flags);
 
rwsemtrace(sem, "Leaving __down_read_trylock");
return ret;
@@ -209,12 +211,12 @@ void fastcall __sched __down_write(struc
 
rwsemtrace(sem, "Entering __down_write");
 
-   spin_lock(&sem->wait_lock);
+   spin_lock_irq(&sem->wait_lock);
 
if (sem->activity == 0 && list_empty(&sem->wait_list)) {
/* granted */
sem->activity = -1;
-   spin_unlock(&sem->wait_lock);
+   spin_unlock_irq(&sem->wait_lock);
goto out;
}
 
@@ -229,7 +231,7 @@ void fastcall __sched __down_write(struc
list_add_tail(&waiter.list, &sem->wait_list);
 
/* we