1 #include <linux/version.h>
4 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
5 #define TRACE_SYSTEM lock
7 #define TRACE_SYSTEM lockdep
8 #define TRACE_INCLUDE_FILE lock
9 #if defined(_TRACE_LOCKDEP_H)
14 #if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
17 #include <linux/lockdep.h>
18 #include <linux/tracepoint.h>
22 TRACE_EVENT(lock_acquire,
24 TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
25 int trylock, int read, int check,
26 struct lockdep_map *next_lock, unsigned long ip),
28 TP_ARGS(lock, subclass, trylock, read, check, next_lock, ip),
31 __field(unsigned int, flags)
32 __string(name, lock->name)
33 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
34 __field(void *, lockdep_addr)
39 tp_assign(flags, (trylock ? 1 : 0) | (read ? 2 : 0))
40 tp_strcpy(name, lock->name)
41 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
42 tp_assign(lockdep_addr, lock)
46 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
47 TP_printk("%p %s%s%s", __entry->lockdep_addr,
51 (__entry->flags & 1) ? "try " : "",
52 (__entry->flags & 2) ? "read " : "",
56 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
58 DECLARE_EVENT_CLASS(lock,
60 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
65 __string( name, lock->name )
66 __field( void *, lockdep_addr )
70 tp_strcpy(name, lock->name)
71 tp_assign(lockdep_addr, lock)
74 TP_printk("%p %s", __entry->lockdep_addr, __get_str(name))
77 DEFINE_EVENT(lock, lock_release,
79 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
84 #ifdef CONFIG_LOCK_STAT
86 DEFINE_EVENT(lock, lock_contended,
88 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
93 DEFINE_EVENT(lock, lock_acquired,
95 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
102 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
104 TRACE_EVENT(lock_release,
106 TP_PROTO(struct lockdep_map *lock, int nested, unsigned long ip),
108 TP_ARGS(lock, nested, ip),
111 __string( name, lock->name )
112 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
113 __field( void *, lockdep_addr )
118 tp_strcpy(name, lock->name)
119 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
120 tp_assign(lockdep_addr, lock)
124 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
125 TP_printk("%p %s", __entry->lockdep_addr, __get_str(name))
127 TP_printk("%s", __get_str(name))
131 #ifdef CONFIG_LOCK_STAT
133 TRACE_EVENT(lock_contended,
135 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
140 __string( name, lock->name )
141 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
142 __field( void *, lockdep_addr )
147 tp_strcpy(name, lock->name)
148 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
149 tp_assign(lockdep_addr, lock)
153 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
154 TP_printk("%p %s", __entry->lockdep_addr, __get_str(name))
156 TP_printk("%s", __get_str(name))
160 TRACE_EVENT(lock_acquired,
162 TP_PROTO(struct lockdep_map *lock, unsigned long ip, s64 waittime),
164 TP_ARGS(lock, ip, waittime),
167 __string( name, lock->name )
168 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
169 __field( s64, wait_nsec )
170 __field( void *, lockdep_addr )
172 __field(unsigned long, wait_usec)
173 __field(unsigned long, wait_nsec_rem)
178 tp_strcpy(name, lock->name)
179 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
180 tp_assign(wait_nsec, waittime)
181 tp_assign(lockdep_addr, lock)
183 tp_assign(wait_usec, (unsigned long)waittime)
184 tp_assign(wait_nsec_rem, do_div(waittime, NSEC_PER_USEC))
188 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
189 TP_printk("%p %s (%llu ns)", __entry->lockdep_addr,
190 __get_str(name), __entry->wait_nsec)
192 TP_printk("%s (%lu.%03lu us)",
194 __entry->wait_usec, __entry->wait_nsec_rem)
200 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
204 #endif /* _TRACE_LOCK_H */
206 /* This part must be outside protection */
207 #include "../../../probes/define_trace.h"