B1;2401;0cOn Tue, 14 Dec 2010, Lai Jiangshan wrote:
I'm not convinced about that function, see comments below
I think we want a separate function which can be used by futex code,
but that's a detail.
I really do not like unitialized stuff. Omitting this init saves ZERO
performance wise and it's going to confuse the hell out of someone
who tries to debug this code.
It took me a while to grok this comment. It should read:
/*
* If the requeue above changed the top waiter, then we need to
* make it a candidate owner and possibly wake it up.
*/
Right ?
Shouldn't this:
- clear cand_owner on the previous top_waiter ?
- increment the cand_seq ?
If we increment cand_seq, then we can get rid of cand_owner completely
as waiter->cand_seq == lock->cand_seq should be sufficient. And it
would automatically prefer the new top waiter and not give the lock to
some random on the fly task.
If I understand correctly, then this is the equivalent to the
original breakout based on !task->pi_blocked_on, right ?
Why ? If the boost code changes the top waiter and wakes up the new
candidate, then this new one really should get the lock and the old on
the fly candidate should queue itself back.
Huch ? This should never happen and therefor this should be a
WARN_ON_ONCE(). We really do not put "checking is not a bad thing"
code in such a fragile and complex construct. Something is very wrong
when you ever hit this.
How should this happen with the new code ? The waiter remains in the
wait list and boosting does not change that. So that comment is
misleading.
Why should we boost ? Because we can have several candidates on the
fly and we don't care which one is the highest prio candidate? That
looks wrong.
This should init waiter->cand_seq to RTMUTEX_CAND_SEQ_MAX and get rid
of cand_owner.
If we make cand_seq an indicator then we need to do
lock->cand_seq = (lock->cand_seq + 1) & ~RTMUTEX_CAND_SEQ_MAX;
Hmm, so we loose the deadlock detection in that case. Not sure whether
it matters though.
All in all I like the idea and I think we should give it a try, but I
definitely want to test a patch against -RT, as this will shake out
all problems in no time.
Thanks,
tglx
--