NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-sparc/37930: sparc mutex stubs are broken on MP



>Number:         37930
>Category:       port-sparc
>Synopsis:       sparc mutex stubs are broken on MP
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-sparc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 31 11:45:01 +0000 2008
>Originator:     Andrew Doran
>Release:        4.99.52
>Organization:
The NetBSD Project
>Environment:
n/a
>Description:
The sparc mutex stubs are broken on MP systems. Usually they
work like this:

- grab the mutex interlock
- that suceeds, so set the full owning LWP address into mtx_owner

On an MP system the following can occur:

cpu2  acquire kernel_lock
cpu1  grab mutex interlock
cpu1  device interrupt occurs before setting mtx_owner
cpu1  spin on kernel_lock trying to process device interrupt
cpu2  spin or block trying to acquire mutex 'half held' by cpu1

-> potentially deadlock
>How-To-Repeat:
Code inspection.
>Fix:
- Implement 'restart' for mutex_enter() in all the interrupt stubs.
  This would be very tricky.

or:

- Change the sparc to __HAVE_SIMPLE_MUTEXES.
- Use atomic_cas_ptr() to acquire and release mutexes.
- Work on optimizing atomic_cas_ptr().

I'll create a patch.





Home | Main Index | Thread Index | Old Index