Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / trace / events / lock.h
blob8e89baa3775f78fd0a94ff0c1de23b803f4ab4ca
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM lock
5 #if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_LOCK_H
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)
20 #ifdef CONFIG_LOCKDEP
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),
32 TP_STRUCT__entry(
33 __field(unsigned int, flags)
34 __string(name, lock->name)
35 __field(void *, lockdep_addr)
38 TP_fast_assign(
39 __entry->flags = (trylock ? 1 : 0) | (read ? 2 : 0);
40 __assign_str(name);
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 " : "",
47 __get_str(name))
50 DECLARE_EVENT_CLASS(lock,
52 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
54 TP_ARGS(lock, ip),
56 TP_STRUCT__entry(
57 __string( name, lock->name )
58 __field( void *, lockdep_addr )
61 TP_fast_assign(
62 __assign_str(name);
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),
73 TP_ARGS(lock, ip)
76 #ifdef CONFIG_LOCK_STAT
78 DEFINE_EVENT(lock, lock_contended,
80 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
82 TP_ARGS(lock, ip)
85 DEFINE_EVENT(lock, lock_acquired,
87 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
89 TP_ARGS(lock, ip)
92 #endif /* CONFIG_LOCK_STAT */
93 #endif /* CONFIG_LOCKDEP */
95 TRACE_EVENT(contention_begin,
97 TP_PROTO(void *lock, unsigned int flags),
99 TP_ARGS(lock, flags),
101 TP_STRUCT__entry(
102 __field(void *, lock_addr)
103 __field(unsigned int, flags)
106 TP_fast_assign(
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" },
116 { LCB_F_RT, "RT" },
117 { LCB_F_PERCPU, "PERCPU" },
118 { LCB_F_MUTEX, "MUTEX" }
122 TRACE_EVENT(contention_end,
124 TP_PROTO(void *lock, int ret),
126 TP_ARGS(lock, ret),
128 TP_STRUCT__entry(
129 __field(void *, lock_addr)
130 __field(int, ret)
133 TP_fast_assign(
134 __entry->lock_addr = lock;
135 __entry->ret = ret;
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>