From: Steven Rostedt <[email protected]>

For the futex system call trace event for FUTEX_LOCK_PI and
FUTEX_UNLOCK_PI commands, show the TID from the value (which is usually in
hex) as well as translate the flags (DIED and WAITERS).

 pi_mutex_hammer-1098    [000] .....   121.876928: sys_futex(uaddr: 
0x560f40cc8180 (0x450) tid: 1104, FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, val: 0, 
timespec: 0x7f2f9d4b1e50 (0.000100000))
 pi_mutex_hammer-1128    [000] .....   121.877120: sys_futex(uaddr: 
0x560f40cc8180 (0x8000042a) tid: 1066 (WAITERS), 
FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, val: 0, timespec: 0x7f2f8e493e50 
(0.000100000))
 pi_mutex_hammer-1106    [000] .....   121.877242: sys_futex(uaddr: 
0x560f40cc8180 (0x80000452) tid: 1106 (WAITERS), 
FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, val: 0)

This makes it easier to see the hand off of a mutex and who the owner was.

Signed-off-by: Steven Rostedt (Google) <[email protected]>
---
 kernel/trace/trace_syscalls.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index d128dcb218a7..b3eddfee1a6b 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -300,6 +300,9 @@ sys_enter_futex_print(struct syscall_trace_enter *trace, 
struct syscall_metadata
 
        trace_seq_printf(s, "%s(", entry->name);
 
+       op = trace->args[1];
+       cmd = op & FUTEX_CMD_MASK;
+
        for (i = 0; !done && i < entry->nb_args; i++) {
 
                if (trace_seq_has_overflowed(s))
@@ -314,11 +317,29 @@ sys_enter_futex_print(struct syscall_trace_enter *trace, 
struct syscall_metadata
                                        trace_seq_printf(s, " (%u)", val);
                                else
                                        trace_seq_printf(s, " (0x%x)", val);
+
+                               switch(cmd) {
+                               case FUTEX_LOCK_PI:
+                               case FUTEX_UNLOCK_PI:
+                                       trace_seq_printf(s, " tid: %d", val & 
FUTEX_TID_MASK);
+
+                                       if (!(val & 
(FUTEX_OWNER_DIED|FUTEX_WAITERS)))
+                                               break;
+
+                                       trace_seq_puts(s, " (");
+                                       if (val & FUTEX_WAITERS)
+                                               trace_seq_puts(s, "WAITERS");
+                                       if (val & FUTEX_OWNER_DIED) {
+                                               if (op & FUTEX_WAITERS)
+                                                       trace_seq_putc(s, '|');
+                                               trace_seq_puts(s, "DIED");
+                                       }
+                                       trace_seq_putc(s, ')');
+                                       break;
+                               }
                        }
                        continue;
                case 1:
-                       op = trace->args[i];
-                       cmd = op & FUTEX_CMD_MASK;
                        if (cmd <= FUTEX_LOCK_PI2)
                                trace_seq_printf(s, ", %s", __futex_cmds[cmd]);
                        else
-- 
2.51.0


Reply via email to