Re: [PATCH 2/4 V2] rtmutex: add BUG_ON if a task attempts to blockon two locks

From: Darren Hart
Date: Sat Jul 10 2010 - 13:30:56 EST


On 07/09/2010 05:30 PM, Steven Rostedt wrote:
> On Fri, 2010-07-09 at 15:32 -0700, Darren Hart wrote:
>> rtmutex proxy locking complicates the logic a bit and opens up
>> the possibility for a task to wake and attempt to take another
>> sleeping lock without knowing it has been enqueued on another
>> lock already. Add a BUG_ON to catch this scenario early.
>>
>> Signed-off-by: Darren Hart<dvhltc@xxxxxxxxxx>
>> Cc: Thomas Gleixner<tglx@xxxxxxxxxxxxx>
>> Cc: Peter Zijlstra<peterz@xxxxxxxxxxxxx>
>> Cc: Ingo Molnar<mingo@xxxxxxx>
>> Cc: Eric Dumazet<eric.dumazet@xxxxxxxxx>
>> Cc: John Kacur<jkacur@xxxxxxxxxx>
>> Cc: Steven Rostedt<rostedt@xxxxxxxxxxx>
>> Cc: Mike Galbraith<efault@xxxxxx>
>> ---
>> kernel/rtmutex.c | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
>> index baac7d9..22f9d18 100644
>> --- a/kernel/rtmutex.c
>> +++ b/kernel/rtmutex.c
>> @@ -459,6 +459,9 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
>> top_waiter = rt_mutex_top_waiter(lock);
>> plist_add(&waiter->list_entry,&lock->wait_list);
>>
>> + /* Tasks can only block on one lock at a time. */
>> + BUG_ON(task->pi_blocked_on != NULL);
>
> WARN_ON may be better. Since it may not cause a system crash or other
> huge bug if it is not true.
>

No objection.