[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <497DEF02.90003@us.ibm.com>
Date: Mon, 26 Jan 2009 09:12:34 -0800
From: Darren Hart <dvhltc@...ibm.com>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>
CC: "Pallipadi, Venkatesh" <venkatesh.pallipadi@...el.com>,
Theodore Tso <tytso@....EDU>,
Arjan van de Ven <arjan@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
Ingo Molnar <mingo@...e.hu>,
Nick Piggin <nickpiggin@...oo.com.au>
Subject: Re: 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@...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@...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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists