Alan Cox writes: > On Iau, 2005-12-15 at 16:41 +0300, Nikita Danilov wrote: > > But this change is about fixing bugs: mutex assumes that > > > > - only owner can unlock, and > > > > - owner cannot lock (immediate self-deadlock). > > So add mutex_up/mutex_down that use the same semaphores but do extra > checks if lock debugging is enabled. All you need is an owner field for > debugging. And to convert almost all calls to down/up to mutex_{down,up}. At which point, it no longer makes sense to share the same data-type for semaphore and mutex. Also, (as was already mentioned several times) having separate data-type for mutex makes code easier to understand, as it specifies intended usage. To avoid duplicating code, mutex can be implemented on top of semaphore, like struct mutex { struct semaphore sema; #ifdef DEBUG_MUTEX void *owner; #endif }; or something similar. > > Now generate a trace dump on up when up and to check for sleeping on a > lock you already hold (for both sem and mutex). Sleeping on a semaphore "held" by the current thread is perfectly reasonable usage of a generic counting semaphore, as it can be upped by another thread. > > Alan Nikita. - 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/
- Follow-Ups:
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: "Christopher Friesen" <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- References:
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Alan Cox <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Paul Jackson <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Paul Jackson <[email protected]>
- [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Andrew Morton <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Ingo Molnar <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Christoph Hellwig <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Ingo Molnar <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Ingo Molnar <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Thomas Gleixner <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Mark Lord <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Andrew Morton <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Nikita Danilov <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Alan Cox <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- Prev by Date: [AIO] reorder kiocb structure elements to make sync iocb setup faster
- Next by Date: Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- Previous by thread: Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- Next by thread: Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- Index(es):