1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM lock
5 #if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
8 #include <linux/sched.h>
9 #include <linux/tracepoint.h>
11 /* flags for lock:contention_begin */
12 #define LCB_F_SPIN (1U << 0)
13 #define LCB_F_READ (1U << 1)
14 #define LCB_F_WRITE (1U << 2)
15 #define LCB_F_RT (1U << 3)
16 #define LCB_F_PERCPU (1U << 4)
17 #define LCB_F_MUTEX (1U << 5)
22 #include <linux/lockdep.h>
24 TRACE_EVENT(lock_acquire
,
26 TP_PROTO(struct lockdep_map
*lock
, unsigned int subclass
,
27 int trylock
, int read
, int check
,
28 struct lockdep_map
*next_lock
, unsigned long ip
),
30 TP_ARGS(lock
, subclass
, trylock
, read
, check
, next_lock
, ip
),
33 __field(unsigned int, flags
)
34 __string(name
, lock
->name
)
35 __field(void *, lockdep_addr
)
39 __entry
->flags
= (trylock
? 1 : 0) | (read
? 2 : 0);
41 __entry
->lockdep_addr
= lock
;
44 TP_printk("%p %s%s%s", __entry
->lockdep_addr
,
45 (__entry
->flags
& 1) ? "try " : "",
46 (__entry
->flags
& 2) ? "read " : "",
50 DECLARE_EVENT_CLASS(lock
,
52 TP_PROTO(struct lockdep_map
*lock
, unsigned long ip
),
57 __string( name
, lock
->name
)
58 __field( void *, lockdep_addr
)
63 __entry
->lockdep_addr
= lock
;
66 TP_printk("%p %s", __entry
->lockdep_addr
, __get_str(name
))
69 DEFINE_EVENT(lock
, lock_release
,
71 TP_PROTO(struct lockdep_map
*lock
, unsigned long ip
),
76 #ifdef CONFIG_LOCK_STAT
78 DEFINE_EVENT(lock
, lock_contended
,
80 TP_PROTO(struct lockdep_map
*lock
, unsigned long ip
),
85 DEFINE_EVENT(lock
, lock_acquired
,
87 TP_PROTO(struct lockdep_map
*lock
, unsigned long ip
),
92 #endif /* CONFIG_LOCK_STAT */
93 #endif /* CONFIG_LOCKDEP */
95 TRACE_EVENT(contention_begin
,
97 TP_PROTO(void *lock
, unsigned int flags
),
102 __field(void *, lock_addr
)
103 __field(unsigned int, flags
)
107 __entry
->lock_addr
= lock
;
108 __entry
->flags
= flags
;
111 TP_printk("%p (flags=%s)", __entry
->lock_addr
,
112 __print_flags(__entry
->flags
, "|",
113 { LCB_F_SPIN
, "SPIN" },
114 { LCB_F_READ
, "READ" },
115 { LCB_F_WRITE
, "WRITE" },
117 { LCB_F_PERCPU
, "PERCPU" },
118 { LCB_F_MUTEX
, "MUTEX" }
122 TRACE_EVENT(contention_end
,
124 TP_PROTO(void *lock
, int ret
),
129 __field(void *, lock_addr
)
134 __entry
->lock_addr
= lock
;
138 TP_printk("%p (ret=%d)", __entry
->lock_addr
, __entry
->ret
)
141 #endif /* _TRACE_LOCK_H */
143 /* This part must be outside protection */
144 #include <trace/define_trace.h>