2002-07-12 01:34:01

by Paul Menage

[permalink] [raw]
Subject: Re: spinlock assertion macros


In article <[email protected]>,
you write:
>
>MUST_NOT_HOLD is already in Jesse's patch he posted earlier today,
>though I imagine it would be used rarely if at all.
>

The spin_assert_unlocked() macro in Jesse's patch doesn't cope with
the fact that someone else might quite legitimately have the spinlock
locked. You'd need debugging spinlocks that track the owner of the
spinlock, and then check in MUST_NOT_HOLD() you'd check that
lock->owner != current. You'd also have to have some special
non-checking lock/unlock macros to handle situations where locks are
taken in non-process context or released by someone other than the
original locker (does the migration code still do that?).

Paul


2002-07-12 04:35:51

by Jesse Barnes

[permalink] [raw]
Subject: Re: spinlock assertion macros

On Thu, Jul 11, 2002 at 06:36:26PM -0700, [email protected] wrote:
> The spin_assert_unlocked() macro in Jesse's patch doesn't cope with
> the fact that someone else might quite legitimately have the spinlock
> locked. You'd need debugging spinlocks that track the owner of the
> spinlock, and then check in MUST_NOT_HOLD() you'd check that
> lock->owner != current. You'd also have to have some special
> non-checking lock/unlock macros to handle situations where locks are
> taken in non-process context or released by someone other than the
> original locker (does the migration code still do that?).

You're right about that, it would be much more useful to add a
spin_assert_unlocked_all() or MUST_NOT_HOLD_ANY() macro, as Arnd
suggested. I'll take the suggestions I've received and try to put
together a more complete patch early next week. It'll include lock
checks for rwlocks, semaphores, and rwsems as well as the global
no-locks-held macro. And as an added bonus, I'll even try to test it
:).

Thanks,
Jesse