lkml.org 
[lkml]   [2009]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: kernel BUG at fs/ext/super.c:428
Peter Zijlstra wrote:
> On Mon, 2009-01-26 at 08:39 -0800, Darren Hart wrote:
>
>>> diff --git a/kernel/futex.c b/kernel/futex.c
>>> index f89d373..f4132ab 100644
>>> --- a/kernel/futex.c
>>> +++ b/kernel/futex.c
>>> @@ -929,7 +929,7 @@ out_unlock:
>>>
>>> /* drop_futex_key_refs() must be called outside the spinlocks. */
>>> while (--drop_count >= 0)
>>> - drop_futex_key_refs(&key1);
>>> + drop_futex_key_refs(&key2);
>> Unfortunately, I realized later that this code was indeed correct and I
>> asked Ingo to pull my patch implementing the above change. Quoting my
>> previous mail on the subject:
>>
>> "I believe what is happening here is that the requeue loop requeues each
>> waiter from one futex (key1) to another (key2). It rightly takes a
>> reference to the futex at key2 and then decrements the references to
>> key1 by drop_count (since the waiters now reference key2, not key1).
>> The newly taken key2 references will be dropped in futex_wait() when
>> each waiter is woken up and takes the futex."
>
> Argh, that wants a comment..
>

Agreed. How about this.


futex: comment requeue key reference symmantics

From: Darren Hart <dvhltc@us.ibm.com>

We've tripped over the futex_requeue drop_count refering to key2
instead of key1. The code is actually correct, but is non-intuitive.
This patch adds an explicit comment explaining the requeue.

Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
---

kernel/futex.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)


diff --git a/kernel/futex.c b/kernel/futex.c
index 8af1002..3655cad 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -969,7 +969,12 @@ out_unlock:
if (hb1 != hb2)
spin_unlock(&hb2->lock);

- /* drop_futex_key_refs() must be called outside the spinlocks. */
+ /*
+ * drop_futex_key_refs() must be called outside the spinlocks. During
+ * the requeue we moved futex_q's from the hash bucket at key1 to the
+ * one at key2 and updated their key pointer. We no longer need to
+ * hold the references to key1.
+ */
while (--drop_count >= 0)
drop_futex_key_refs(&key1);


--
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team


\
 
 \ /
  Last update: 2009-01-26 18:15    [W:0.689 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site