Re: [PATCH 2/2] futex: correct futex_requeue futex key ref countingin requeue loop

From: Darren Hart
Date: Tue Dec 30 2008 - 18:36:21 EST


Darren Hart wrote:
The requeue loop takes multiple references to key2, but the corresponding
put loop decrements the refs for key1. This patch corrects the accounting.

Build and boot tested on an x86_64 system.

Signed-off-by: Darren Hart <dvhltc@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Rusty Russell <rusty@xxxxxxxxxxx>
---

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

diff --git a/kernel/futex.c b/kernel/futex.c
index cf363ce..3b66d91 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -919,7 +919,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);

put_futex_key(fshared, &key2);
out_put_key1:


Ugh, so I'm having second thoughts about this patch. 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.

I apologize for the confusion on this. Thanks for suggesting I send this patch out independently from the rest Peter ;-)

If we can come to a consensus on this, I suggest pulling this patch from tip/core/futexes.


--
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/