[PATCH] robust pi futex tracing

From: Darren Hart
Date: Fri Jun 25 2010 - 16:54:25 EST


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

diff --git a/kernel/futex.c b/kernel/futex.c
index e7a35f1..24ac437 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -683,6 +683,8 @@ retry:
*/
if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) {
/* Keep the OWNER_DIED bit */
+ if (ownerdied)
+ trace_printk("ownerdied, taking over lock\n");
newval = (curval & ~FUTEX_TID_MASK) | task_pid_vnr(task);
ownerdied = 0;
lock_taken = 1;
@@ -692,14 +694,18 @@ retry:

if (unlikely(curval == -EFAULT))
return -EFAULT;
- if (unlikely(curval != uval))
+ if (unlikely(curval != uval)) {
+ trace_printk("cmpxchg failed, retrying\n");
goto retry;
+ }

/*
* We took the lock due to owner died take over.
*/
- if (unlikely(lock_taken))
+ if (unlikely(lock_taken)) {
+ trace_printk("ownerdied, lock acquired, return 1\n");
return 1;
+ }

/*
* We dont have the lock. Look up the PI state (or create it if
@@ -710,13 +716,16 @@ retry:
if (unlikely(ret)) {
switch (ret) {
case -ESRCH:
+ trace_printk("lookup_pi_state: -ESRCH\n");
/*
* No owner found for this futex. Check if the
* OWNER_DIED bit is set to figure out whether
* this is a robust futex or not.
*/
- if (get_futex_value_locked(&curval, uaddr))
+ if (get_futex_value_locked(&curval, uaddr)) {
+ trace_printk("get_futex_value_locked: -EFAULT\n");
return -EFAULT;
+ }

/*
* We simply start over in case of a robust
@@ -724,10 +733,13 @@ retry:
* and return happy.
*/
if (curval & FUTEX_OWNER_DIED) {
+ trace_printk("ownerdied, goto retry\n");
ownerdied = 1;
goto retry;
}
+ trace_printk("ownerdied not detected, returning -ESRCH\n");
default:
+ trace_printk("lookup_pi_state: %d\n", ret);
break;
}
}
@@ -1950,6 +1962,8 @@ retry_private:
put_futex_key(fshared, &q.key);
cond_resched();
goto retry;
+ case -ESRCH:
+ trace_printk("returning -ESRCH to userspace\n");
default:
goto out_unlock_put_key;
}
@@ -2537,8 +2551,10 @@ void exit_robust_list(struct task_struct *curr)
/*
* Avoid excessively long or circular lists:
*/
- if (!--limit)
+ if (!--limit) {
+ trace_printk("excessively long list, aborting\n");
break;
+ }

cond_resched();
}
--
1.7.0.4

--
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/