1
2
3
4
5
6
7
8
9
10#ifndef __LINUX_LOCKDEP_TYPES_H
11#define __LINUX_LOCKDEP_TYPES_H
12
13#include <linux/types.h>
14
15#define MAX_LOCKDEP_SUBCLASSES 8UL
16
17enum lockdep_wait_type {
18 LD_WAIT_INV = 0,
19
20 LD_WAIT_FREE,
21 LD_WAIT_SPIN,
22
23#ifdef CONFIG_PROVE_RAW_LOCK_NESTING
24 LD_WAIT_CONFIG,
25#else
26 LD_WAIT_CONFIG = LD_WAIT_SPIN,
27#endif
28 LD_WAIT_SLEEP,
29
30 LD_WAIT_MAX,
31};
32
33enum lockdep_lock_type {
34 LD_LOCK_NORMAL = 0,
35 LD_LOCK_PERCPU,
36 LD_LOCK_MAX,
37};
38
39#ifdef CONFIG_LOCKDEP
40
41
42
43
44
45
46
47
48#define XXX_LOCK_USAGE_STATES 2
49#define LOCK_TRACE_STATES (XXX_LOCK_USAGE_STATES*4 + 2)
50
51
52
53
54
55
56
57
58
59
60#define NR_LOCKDEP_CACHING_CLASSES 2
61
62
63
64
65
66
67
68
69struct lockdep_subclass_key {
70 char __one_byte;
71} __attribute__ ((__packed__));
72
73
74struct lock_class_key {
75 union {
76 struct hlist_node hash_entry;
77 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES];
78 };
79};
80
81extern struct lock_class_key __lockdep_no_validate__;
82
83struct lock_trace;
84
85#define LOCKSTAT_POINTS 4
86
87
88
89
90
91struct lock_class {
92
93
94
95 struct hlist_node hash_entry;
96
97
98
99
100
101
102 struct list_head lock_entry;
103
104
105
106
107
108
109 struct list_head locks_after, locks_before;
110
111 const struct lockdep_subclass_key *key;
112 unsigned int subclass;
113 unsigned int dep_gen_id;
114
115
116
117
118 unsigned long usage_mask;
119 const struct lock_trace *usage_traces[LOCK_TRACE_STATES];
120
121
122
123
124
125 int name_version;
126 const char *name;
127
128 u8 wait_type_inner;
129 u8 wait_type_outer;
130 u8 lock_type;
131
132
133#ifdef CONFIG_LOCK_STAT
134 unsigned long contention_point[LOCKSTAT_POINTS];
135 unsigned long contending_point[LOCKSTAT_POINTS];
136#endif
137} __no_randomize_layout;
138
139#ifdef CONFIG_LOCK_STAT
140struct lock_time {
141 s64 min;
142 s64 max;
143 s64 total;
144 unsigned long nr;
145};
146
147enum bounce_type {
148 bounce_acquired_write,
149 bounce_acquired_read,
150 bounce_contended_write,
151 bounce_contended_read,
152 nr_bounce_types,
153
154 bounce_acquired = bounce_acquired_write,
155 bounce_contended = bounce_contended_write,
156};
157
158struct lock_class_stats {
159 unsigned long contention_point[LOCKSTAT_POINTS];
160 unsigned long contending_point[LOCKSTAT_POINTS];
161 struct lock_time read_waittime;
162 struct lock_time write_waittime;
163 struct lock_time read_holdtime;
164 struct lock_time write_holdtime;
165 unsigned long bounces[nr_bounce_types];
166};
167
168struct lock_class_stats lock_stats(struct lock_class *class);
169void clear_lock_stats(struct lock_class *class);
170#endif
171
172
173
174
175
176struct lockdep_map {
177 struct lock_class_key *key;
178 struct lock_class *class_cache[NR_LOCKDEP_CACHING_CLASSES];
179 const char *name;
180 u8 wait_type_outer;
181 u8 wait_type_inner;
182 u8 lock_type;
183
184#ifdef CONFIG_LOCK_STAT
185 int cpu;
186 unsigned long ip;
187#endif
188};
189
190struct pin_cookie { unsigned int val; };
191
192#else
193
194
195
196
197struct lock_class_key { };
198
199
200
201
202struct lockdep_map { };
203
204struct pin_cookie { };
205
206#endif
207
208#endif
209