Re: [PATCH] Make futex waiters take an mm or inode reference

From: Rusty Russell
Date: Mon Sep 08 2003 - 23:05:45 EST


In message <Pine.LNX.4.44.0309081144390.3202-100000@xxxxxxxxxxxxx> you write:
> So is there any reason to really having "private.mm" AT ALL? From what I
> can tell, it is not actually ever used (all "mm" users are "current->mm"),
> so I don't see the point of incrementing a count for it either.
>
> Or did I miss something?

Yes. Firstly, you can't do "wake one" if the one you wake might be
some completely unrelated process which happens to use the same
address. Secondly, I implemented fair futexes by relying on the
return value of FUTEX_WAKE to indicate how many people were woken: you
set the futex to a magic value, call FUTEX_WAKE(1), and if it returns
1, you've "passed" the futex directly, otherwise you unlock the futex
like normal. This is surprisingly useful for implementing
"drop_futex_if_someone_is_waiting()" in cleanup threads etc.

Sorry,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
-
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/