six locks: Lock contended tracepoints
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 5 Feb 2023 21:18:59 +0000 (16:18 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 31 Oct 2023 02:26:45 +0000 (22:26 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/six.c

index b684b9f00c1b2bb731ea9551b1548d9675f42705..b775cf0fb7cbf211a3f388cf78de0de6f33c581c 100644 (file)
@@ -11,6 +11,8 @@
 #include <linux/sched/task.h>
 #include <linux/slab.h>
 
+#include <trace/events/lock.h>
+
 #include "six.h"
 
 #ifdef DEBUG
@@ -462,11 +464,12 @@ static int six_lock_slowpath(struct six_lock *lock, enum six_lock_type type,
                smp_mb__after_atomic();
        }
 
+       trace_contention_begin(lock, 0);
+       lock_contended(&lock->dep_map, ip);
+
        if (six_optimistic_spin(lock, type))
                goto out;
 
-       lock_contended(&lock->dep_map, ip);
-
        wait->task              = current;
        wait->lock_want         = type;
        wait->lock_acquired     = false;
@@ -546,6 +549,7 @@ out:
                six_clear_bitmask(lock, SIX_LOCK_HELD_write);
                six_lock_wakeup(lock, atomic_read(&lock->state), SIX_LOCK_read);
        }
+       trace_contention_end(lock, 0);
 
        return ret;
 }