Linux Audio

Check our new training course

Linux debugging, profiling, tracing and performance analysis training

Apr 14-17, 2025
Register
Loading...
v5.4
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#undef TRACE_SYSTEM
 3#define TRACE_SYSTEM lock
 4
 5#if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
 6#define _TRACE_LOCK_H
 7
 8#include <linux/lockdep.h>
 9#include <linux/tracepoint.h>
10
 
 
 
 
 
 
 
 
 
11#ifdef CONFIG_LOCKDEP
12
 
 
13TRACE_EVENT(lock_acquire,
14
15	TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
16		int trylock, int read, int check,
17		struct lockdep_map *next_lock, unsigned long ip),
18
19	TP_ARGS(lock, subclass, trylock, read, check, next_lock, ip),
20
21	TP_STRUCT__entry(
22		__field(unsigned int, flags)
23		__string(name, lock->name)
24		__field(void *, lockdep_addr)
25	),
26
27	TP_fast_assign(
28		__entry->flags = (trylock ? 1 : 0) | (read ? 2 : 0);
29		__assign_str(name, lock->name);
30		__entry->lockdep_addr = lock;
31	),
32
33	TP_printk("%p %s%s%s", __entry->lockdep_addr,
34		  (__entry->flags & 1) ? "try " : "",
35		  (__entry->flags & 2) ? "read " : "",
36		  __get_str(name))
37);
38
39DECLARE_EVENT_CLASS(lock,
40
41	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
42
43	TP_ARGS(lock, ip),
44
45	TP_STRUCT__entry(
46		__string(	name, 	lock->name	)
47		__field(	void *, lockdep_addr	)
48	),
49
50	TP_fast_assign(
51		__assign_str(name, lock->name);
52		__entry->lockdep_addr = lock;
53	),
54
55	TP_printk("%p %s",  __entry->lockdep_addr, __get_str(name))
56);
57
58DEFINE_EVENT(lock, lock_release,
59
60	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
61
62	TP_ARGS(lock, ip)
63);
64
65#ifdef CONFIG_LOCK_STAT
66
67DEFINE_EVENT(lock, lock_contended,
68
69	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
70
71	TP_ARGS(lock, ip)
72);
73
74DEFINE_EVENT(lock, lock_acquired,
75
76	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
77
78	TP_ARGS(lock, ip)
79);
80
81#endif
82#endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
84#endif /* _TRACE_LOCK_H */
85
86/* This part must be outside protection */
87#include <trace/define_trace.h>
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#undef TRACE_SYSTEM
  3#define TRACE_SYSTEM lock
  4
  5#if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
  6#define _TRACE_LOCK_H
  7
  8#include <linux/sched.h>
  9#include <linux/tracepoint.h>
 10
 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)
 18
 19
 20#ifdef CONFIG_LOCKDEP
 21
 22#include <linux/lockdep.h>
 23
 24TRACE_EVENT(lock_acquire,
 25
 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),
 29
 30	TP_ARGS(lock, subclass, trylock, read, check, next_lock, ip),
 31
 32	TP_STRUCT__entry(
 33		__field(unsigned int, flags)
 34		__string(name, lock->name)
 35		__field(void *, lockdep_addr)
 36	),
 37
 38	TP_fast_assign(
 39		__entry->flags = (trylock ? 1 : 0) | (read ? 2 : 0);
 40		__assign_str(name, lock->name);
 41		__entry->lockdep_addr = lock;
 42	),
 43
 44	TP_printk("%p %s%s%s", __entry->lockdep_addr,
 45		  (__entry->flags & 1) ? "try " : "",
 46		  (__entry->flags & 2) ? "read " : "",
 47		  __get_str(name))
 48);
 49
 50DECLARE_EVENT_CLASS(lock,
 51
 52	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
 53
 54	TP_ARGS(lock, ip),
 55
 56	TP_STRUCT__entry(
 57		__string(	name, 	lock->name	)
 58		__field(	void *, lockdep_addr	)
 59	),
 60
 61	TP_fast_assign(
 62		__assign_str(name, lock->name);
 63		__entry->lockdep_addr = lock;
 64	),
 65
 66	TP_printk("%p %s",  __entry->lockdep_addr, __get_str(name))
 67);
 68
 69DEFINE_EVENT(lock, lock_release,
 70
 71	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
 72
 73	TP_ARGS(lock, ip)
 74);
 75
 76#ifdef CONFIG_LOCK_STAT
 77
 78DEFINE_EVENT(lock, lock_contended,
 79
 80	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
 81
 82	TP_ARGS(lock, ip)
 83);
 84
 85DEFINE_EVENT(lock, lock_acquired,
 86
 87	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
 88
 89	TP_ARGS(lock, ip)
 90);
 91
 92#endif /* CONFIG_LOCK_STAT */
 93#endif /* CONFIG_LOCKDEP */
 94
 95TRACE_EVENT(contention_begin,
 96
 97	TP_PROTO(void *lock, unsigned int flags),
 98
 99	TP_ARGS(lock, flags),
100
101	TP_STRUCT__entry(
102		__field(void *, lock_addr)
103		__field(unsigned int, flags)
104	),
105
106	TP_fast_assign(
107		__entry->lock_addr = lock;
108		__entry->flags = flags;
109	),
110
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" }
119			  ))
120);
121
122TRACE_EVENT(contention_end,
123
124	TP_PROTO(void *lock, int ret),
125
126	TP_ARGS(lock, ret),
127
128	TP_STRUCT__entry(
129		__field(void *, lock_addr)
130		__field(int, ret)
131	),
132
133	TP_fast_assign(
134		__entry->lock_addr = lock;
135		__entry->ret = ret;
136	),
137
138	TP_printk("%p (ret=%d)", __entry->lock_addr, __entry->ret)
139);
140
141#endif /* _TRACE_LOCK_H */
142
143/* This part must be outside protection */
144#include <trace/define_trace.h>