Messages in this thread | | | Date | Wed, 4 Dec 2013 13:14:56 -0800 | Subject | Re: [PATCH] mutexes: Add CONFIG_DEBUG_MUTEX_FASTPATH=y debug variant to debug SMP races | From | Linus Torvalds <> |
| |
On Wed, Dec 4, 2013 at 1:19 AM, Simon Kirby <sim@hostway.ca> wrote: > > Meanwhile, I still don't understand how moving the unlock _up_ to cover > less of the code can solve the race, but I will stare at your long > explanation more tomorrow.
The lock we're moving up isn't the lock that actually protects the whole allocation logic (it's the lock that then protects the pipe contents when a pipe is *used*). So it's a useless lock, and moving it up is a good idea regardless (because it makes the locks only protect the parts they are actually *supposed* to protect.
And while extraneous lock wouldn't normally hurt, the sleeping locks (both mutexes and semaphores) aren't actually safe wrt de-allocation - they protect anything *inside* the lock, but the lock data structure itself is accessed racily wrt other lockers (in a way that still leaves the locked region protected, but not the lock itself). If you care about details, you can walk through my example.
Linus
| |