blob: 5c1dcfc16c6037019d8bcecf4e7c2fa4f3649505 [file] [log] [blame]
Li Zefand0b6e042009-07-13 10:33:21 +08001#undef TRACE_SYSTEM
Frederic Weisbecker67178762009-11-13 10:06:34 +01002#define TRACE_SYSTEM lock
Li Zefand0b6e042009-07-13 10:33:21 +08003
Frederic Weisbecker67178762009-11-13 10:06:34 +01004#if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_LOCK_H
Peter Zijlstraefed7922009-03-04 12:32:55 +01006
7#include <linux/lockdep.h>
8#include <linux/tracepoint.h>
9
Steven Rostedtea20d922009-04-10 08:54:16 -040010#ifdef CONFIG_LOCKDEP
11
Steven Rostedt39517092009-04-24 11:05:52 -040012TRACE_EVENT(lock_acquire,
13
Steven Rostedtea20d922009-04-10 08:54:16 -040014 TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
15 int trylock, int read, int check,
16 struct lockdep_map *next_lock, unsigned long ip),
Steven Rostedtea20d922009-04-10 08:54:16 -040017
Steven Rostedt39517092009-04-24 11:05:52 -040018 TP_ARGS(lock, subclass, trylock, read, check, next_lock, ip),
19
20 TP_STRUCT__entry(
21 __field(unsigned int, flags)
22 __string(name, lock->name)
Hitoshi Mitakec965be12010-01-30 20:43:32 +090023 __field(void *, lockdep_addr)
Steven Rostedt39517092009-04-24 11:05:52 -040024 ),
25
26 TP_fast_assign(
27 __entry->flags = (trylock ? 1 : 0) | (read ? 2 : 0);
28 __assign_str(name, lock->name);
Hitoshi Mitakec965be12010-01-30 20:43:32 +090029 __entry->lockdep_addr = lock;
Steven Rostedt39517092009-04-24 11:05:52 -040030 ),
31
Hitoshi Mitakec965be12010-01-30 20:43:32 +090032 TP_printk("%p %s%s%s", __entry->lockdep_addr,
33 (__entry->flags & 1) ? "try " : "",
Steven Rostedt39517092009-04-24 11:05:52 -040034 (__entry->flags & 2) ? "read " : "",
35 __get_str(name))
36);
37
38TRACE_EVENT(lock_release,
39
Steven Rostedtea20d922009-04-10 08:54:16 -040040 TP_PROTO(struct lockdep_map *lock, int nested, unsigned long ip),
Steven Rostedt39517092009-04-24 11:05:52 -040041
Steven Rostedtea20d922009-04-10 08:54:16 -040042 TP_ARGS(lock, nested, ip),
Steven Rostedt39517092009-04-24 11:05:52 -040043
44 TP_STRUCT__entry(
45 __string(name, lock->name)
Hitoshi Mitakec965be12010-01-30 20:43:32 +090046 __field(void *, lockdep_addr)
Steven Rostedt39517092009-04-24 11:05:52 -040047 ),
48
49 TP_fast_assign(
50 __assign_str(name, lock->name);
Hitoshi Mitakec965be12010-01-30 20:43:32 +090051 __entry->lockdep_addr = lock;
Steven Rostedt39517092009-04-24 11:05:52 -040052 ),
53
Hitoshi Mitakec965be12010-01-30 20:43:32 +090054 TP_printk("%p %s",
55 __entry->lockdep_addr, __get_str(name))
Steven Rostedt39517092009-04-24 11:05:52 -040056);
Steven Rostedtea20d922009-04-10 08:54:16 -040057
58#ifdef CONFIG_LOCK_STAT
59
Steven Rostedt39517092009-04-24 11:05:52 -040060TRACE_EVENT(lock_contended,
61
Steven Rostedtea20d922009-04-10 08:54:16 -040062 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
Steven Rostedt39517092009-04-24 11:05:52 -040063
Steven Rostedtea20d922009-04-10 08:54:16 -040064 TP_ARGS(lock, ip),
Steven Rostedt39517092009-04-24 11:05:52 -040065
66 TP_STRUCT__entry(
67 __string(name, lock->name)
Hitoshi Mitakec965be12010-01-30 20:43:32 +090068 __field(void *, lockdep_addr)
Steven Rostedt39517092009-04-24 11:05:52 -040069 ),
70
71 TP_fast_assign(
72 __assign_str(name, lock->name);
Hitoshi Mitakec965be12010-01-30 20:43:32 +090073 __entry->lockdep_addr = lock;
Steven Rostedt39517092009-04-24 11:05:52 -040074 ),
75
Hitoshi Mitakec965be12010-01-30 20:43:32 +090076 TP_printk("%p %s",
77 __entry->lockdep_addr, __get_str(name))
Steven Rostedt39517092009-04-24 11:05:52 -040078);
Steven Rostedtea20d922009-04-10 08:54:16 -040079
80TRACE_EVENT(lock_acquired,
81 TP_PROTO(struct lockdep_map *lock, unsigned long ip, s64 waittime),
82
83 TP_ARGS(lock, ip, waittime),
84
85 TP_STRUCT__entry(
Frederic Weisbecker7e7ca9a2009-04-19 04:54:49 +020086 __string(name, lock->name)
Hitoshi Mitakec965be12010-01-30 20:43:32 +090087 __field(s64, wait_nsec)
88 __field(void *, lockdep_addr)
Steven Rostedtea20d922009-04-10 08:54:16 -040089 ),
Hitoshi Mitakec965be12010-01-30 20:43:32 +090090
Steven Rostedtea20d922009-04-10 08:54:16 -040091 TP_fast_assign(
Frederic Weisbecker7e7ca9a2009-04-19 04:54:49 +020092 __assign_str(name, lock->name);
Hitoshi Mitakec965be12010-01-30 20:43:32 +090093 __entry->wait_nsec = waittime;
94 __entry->lockdep_addr = lock;
Steven Rostedtea20d922009-04-10 08:54:16 -040095 ),
Hitoshi Mitakec965be12010-01-30 20:43:32 +090096 TP_printk("%p %s (%llu ns)", __entry->lockdep_addr,
97 __get_str(name),
98 __entry->wait_nsec)
Steven Rostedtea20d922009-04-10 08:54:16 -040099);
Peter Zijlstraefed7922009-03-04 12:32:55 +0100100
101#endif
Steven Rostedtea20d922009-04-10 08:54:16 -0400102#endif
103
Frederic Weisbecker67178762009-11-13 10:06:34 +0100104#endif /* _TRACE_LOCK_H */
Steven Rostedta8d154b2009-04-10 09:36:00 -0400105
106/* This part must be outside protection */
107#include <trace/define_trace.h>