0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __LINUX_LOCKDEP_TYPES_H
0011 #define __LINUX_LOCKDEP_TYPES_H
0012
0013 #include <linux/types.h>
0014
0015 #define MAX_LOCKDEP_SUBCLASSES 8UL
0016
0017 enum lockdep_wait_type {
0018 LD_WAIT_INV = 0,
0019
0020 LD_WAIT_FREE,
0021 LD_WAIT_SPIN,
0022
0023 #ifdef CONFIG_PROVE_RAW_LOCK_NESTING
0024 LD_WAIT_CONFIG,
0025 #else
0026 LD_WAIT_CONFIG = LD_WAIT_SPIN,
0027 #endif
0028 LD_WAIT_SLEEP,
0029
0030 LD_WAIT_MAX,
0031 };
0032
0033 enum lockdep_lock_type {
0034 LD_LOCK_NORMAL = 0,
0035 LD_LOCK_PERCPU,
0036 LD_LOCK_MAX,
0037 };
0038
0039 #ifdef CONFIG_LOCKDEP
0040
0041
0042
0043
0044
0045
0046
0047
0048 #define XXX_LOCK_USAGE_STATES 2
0049 #define LOCK_TRACE_STATES (XXX_LOCK_USAGE_STATES*4 + 2)
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 #define NR_LOCKDEP_CACHING_CLASSES 2
0061
0062
0063
0064
0065
0066
0067
0068
0069 struct lockdep_subclass_key {
0070 char __one_byte;
0071 } __attribute__ ((__packed__));
0072
0073
0074 struct lock_class_key {
0075 union {
0076 struct hlist_node hash_entry;
0077 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES];
0078 };
0079 };
0080
0081 extern struct lock_class_key __lockdep_no_validate__;
0082
0083 struct lock_trace;
0084
0085 #define LOCKSTAT_POINTS 4
0086
0087
0088
0089
0090
0091 struct lock_class {
0092
0093
0094
0095 struct hlist_node hash_entry;
0096
0097
0098
0099
0100
0101
0102 struct list_head lock_entry;
0103
0104
0105
0106
0107
0108
0109 struct list_head locks_after, locks_before;
0110
0111 const struct lockdep_subclass_key *key;
0112 unsigned int subclass;
0113 unsigned int dep_gen_id;
0114
0115
0116
0117
0118 unsigned long usage_mask;
0119 const struct lock_trace *usage_traces[LOCK_TRACE_STATES];
0120
0121
0122
0123
0124
0125 int name_version;
0126 const char *name;
0127
0128 u8 wait_type_inner;
0129 u8 wait_type_outer;
0130 u8 lock_type;
0131
0132
0133 #ifdef CONFIG_LOCK_STAT
0134 unsigned long contention_point[LOCKSTAT_POINTS];
0135 unsigned long contending_point[LOCKSTAT_POINTS];
0136 #endif
0137 } __no_randomize_layout;
0138
0139 #ifdef CONFIG_LOCK_STAT
0140 struct lock_time {
0141 s64 min;
0142 s64 max;
0143 s64 total;
0144 unsigned long nr;
0145 };
0146
0147 enum bounce_type {
0148 bounce_acquired_write,
0149 bounce_acquired_read,
0150 bounce_contended_write,
0151 bounce_contended_read,
0152 nr_bounce_types,
0153
0154 bounce_acquired = bounce_acquired_write,
0155 bounce_contended = bounce_contended_write,
0156 };
0157
0158 struct lock_class_stats {
0159 unsigned long contention_point[LOCKSTAT_POINTS];
0160 unsigned long contending_point[LOCKSTAT_POINTS];
0161 struct lock_time read_waittime;
0162 struct lock_time write_waittime;
0163 struct lock_time read_holdtime;
0164 struct lock_time write_holdtime;
0165 unsigned long bounces[nr_bounce_types];
0166 };
0167
0168 struct lock_class_stats lock_stats(struct lock_class *class);
0169 void clear_lock_stats(struct lock_class *class);
0170 #endif
0171
0172
0173
0174
0175
0176 struct lockdep_map {
0177 struct lock_class_key *key;
0178 struct lock_class *class_cache[NR_LOCKDEP_CACHING_CLASSES];
0179 const char *name;
0180 u8 wait_type_outer;
0181 u8 wait_type_inner;
0182 u8 lock_type;
0183
0184 #ifdef CONFIG_LOCK_STAT
0185 int cpu;
0186 unsigned long ip;
0187 #endif
0188 };
0189
0190 struct pin_cookie { unsigned int val; };
0191
0192 #else
0193
0194
0195
0196
0197 struct lock_class_key { };
0198
0199
0200
0201
0202 struct lockdep_map { };
0203
0204 struct pin_cookie { };
0205
0206 #endif
0207
0208 #endif