Skip to contentSkip to conversation

futex: add WARN_ON to catch certain assymetric (get|put)_futex_key calls

PATCH Applied Darren Hart 2 participants 2 messages Dec 30, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 futex: add WARN_ON to catch certain assymetric (get|put)_futex_key calls

Following up on my previous key reference accounting patches, this patch will catch puts on keys that haven't been "got". This won't catch nested get/put mismatches though.

Build and boot tested, with minimal desktop activity and a run of the open_posix_testsuite in LTP for testing. No warnings logged.

Cc "Peter Zijlstra" <[email protected]>
Cc "Thomas Gleixner" <[email protected]>
Cc "Rusty Russell" <[email protected]>

---

 kernel/futex.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
kernel/futex.c +4 -1
index 748778a..5288acf 100644
@@ -170,8 +170,11 @@ static void get_futex_key_refs(union futex_key *key)
  */
 static void drop_futex_key_refs(union futex_key *key)
 {
-	if (!key->both.ptr)
+	if (!key->both.ptr) {
+		/* If we're here then we tried to put a key we failed to get */
+		WARN_ON(1);
 		return;
+	}
 
 	switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
 	case FUT_OFF_INODE:
Applied
#1 lore raw
Quoted 7 lines · Darren Hart

Following up on my previous key reference accounting patches, this patch will catch puts on keys that haven't been "got". This won't catch nested get/put mismatches though.

Build and boot tested, with minimal desktop activity and a run of the open_posix_testsuite in LTP for testing. No warnings logged.

Quoted 8 lines
Cc "Peter Zijlstra" <[email protected]>
Cc "Thomas Gleixner" <[email protected]>
Cc "Rusty Russell" <[email protected]>

---

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

applied to tip/core/futexes, thanks!

I changed this:

kernel/futex.c static void get_futex_key_refs(union futex_key *key) · line 176

Quoted 2 lines
kernel/futex.c +1 -0
+		WARN_ON(1);
 		return;

to WARN_ON_ONCE() - warning once per bootup is good enough for kerneloops.org to pick it up, while a ton of warnings add no extra (other than to inconvenience the user, or even make the system unworkable).

Ingo