Skip to content

Commit 99bac36

Browse files
author
Kent Overstreet
committed
lockdep: move held_lock to lockdep_types.h
held_lock is embedded in task_struct, and we don't want sched.h pulling in all of lockdep.h Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> Acked-by: Waiman Long <longman@redhat.com>
1 parent e034d49 commit 99bac36

File tree

2 files changed

+57
-57
lines changed

2 files changed

+57
-57
lines changed

include/linux/lockdep.h

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -82,63 +82,6 @@ struct lock_chain {
8282
u64 chain_key;
8383
};
8484

85-
#define MAX_LOCKDEP_KEYS_BITS 13
86-
#define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS)
87-
#define INITIAL_CHAIN_KEY -1
88-
89-
struct held_lock {
90-
/*
91-
* One-way hash of the dependency chain up to this point. We
92-
* hash the hashes step by step as the dependency chain grows.
93-
*
94-
* We use it for dependency-caching and we skip detection
95-
* passes and dependency-updates if there is a cache-hit, so
96-
* it is absolutely critical for 100% coverage of the validator
97-
* to have a unique key value for every unique dependency path
98-
* that can occur in the system, to make a unique hash value
99-
* as likely as possible - hence the 64-bit width.
100-
*
101-
* The task struct holds the current hash value (initialized
102-
* with zero), here we store the previous hash value:
103-
*/
104-
u64 prev_chain_key;
105-
unsigned long acquire_ip;
106-
struct lockdep_map *instance;
107-
struct lockdep_map *nest_lock;
108-
#ifdef CONFIG_LOCK_STAT
109-
u64 waittime_stamp;
110-
u64 holdtime_stamp;
111-
#endif
112-
/*
113-
* class_idx is zero-indexed; it points to the element in
114-
* lock_classes this held lock instance belongs to. class_idx is in
115-
* the range from 0 to (MAX_LOCKDEP_KEYS-1) inclusive.
116-
*/
117-
unsigned int class_idx:MAX_LOCKDEP_KEYS_BITS;
118-
/*
119-
* The lock-stack is unified in that the lock chains of interrupt
120-
* contexts nest ontop of process context chains, but we 'separate'
121-
* the hashes by starting with 0 if we cross into an interrupt
122-
* context, and we also keep do not add cross-context lock
123-
* dependencies - the lock usage graph walking covers that area
124-
* anyway, and we'd just unnecessarily increase the number of
125-
* dependencies otherwise. [Note: hardirq and softirq contexts
126-
* are separated from each other too.]
127-
*
128-
* The following field is used to detect when we cross into an
129-
* interrupt context:
130-
*/
131-
unsigned int irq_context:2; /* bit 0 - soft, bit 1 - hard */
132-
unsigned int trylock:1; /* 16 bits */
133-
134-
unsigned int read:2; /* see lock_acquire() comment */
135-
unsigned int check:1; /* see lock_acquire() comment */
136-
unsigned int hardirqs_off:1;
137-
unsigned int sync:1;
138-
unsigned int references:11; /* 32 bits */
139-
unsigned int pin_count;
140-
};
141-
14285
/*
14386
* Initialization, self-test and debugging-output methods:
14487
*/

include/linux/lockdep_types.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,63 @@ struct lockdep_map {
198198

199199
struct pin_cookie { unsigned int val; };
200200

201+
#define MAX_LOCKDEP_KEYS_BITS 13
202+
#define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS)
203+
#define INITIAL_CHAIN_KEY -1
204+
205+
struct held_lock {
206+
/*
207+
* One-way hash of the dependency chain up to this point. We
208+
* hash the hashes step by step as the dependency chain grows.
209+
*
210+
* We use it for dependency-caching and we skip detection
211+
* passes and dependency-updates if there is a cache-hit, so
212+
* it is absolutely critical for 100% coverage of the validator
213+
* to have a unique key value for every unique dependency path
214+
* that can occur in the system, to make a unique hash value
215+
* as likely as possible - hence the 64-bit width.
216+
*
217+
* The task struct holds the current hash value (initialized
218+
* with zero), here we store the previous hash value:
219+
*/
220+
u64 prev_chain_key;
221+
unsigned long acquire_ip;
222+
struct lockdep_map *instance;
223+
struct lockdep_map *nest_lock;
224+
#ifdef CONFIG_LOCK_STAT
225+
u64 waittime_stamp;
226+
u64 holdtime_stamp;
227+
#endif
228+
/*
229+
* class_idx is zero-indexed; it points to the element in
230+
* lock_classes this held lock instance belongs to. class_idx is in
231+
* the range from 0 to (MAX_LOCKDEP_KEYS-1) inclusive.
232+
*/
233+
unsigned int class_idx:MAX_LOCKDEP_KEYS_BITS;
234+
/*
235+
* The lock-stack is unified in that the lock chains of interrupt
236+
* contexts nest ontop of process context chains, but we 'separate'
237+
* the hashes by starting with 0 if we cross into an interrupt
238+
* context, and we also keep do not add cross-context lock
239+
* dependencies - the lock usage graph walking covers that area
240+
* anyway, and we'd just unnecessarily increase the number of
241+
* dependencies otherwise. [Note: hardirq and softirq contexts
242+
* are separated from each other too.]
243+
*
244+
* The following field is used to detect when we cross into an
245+
* interrupt context:
246+
*/
247+
unsigned int irq_context:2; /* bit 0 - soft, bit 1 - hard */
248+
unsigned int trylock:1; /* 16 bits */
249+
250+
unsigned int read:2; /* see lock_acquire() comment */
251+
unsigned int check:1; /* see lock_acquire() comment */
252+
unsigned int hardirqs_off:1;
253+
unsigned int sync:1;
254+
unsigned int references:11; /* 32 bits */
255+
unsigned int pin_count;
256+
};
257+
201258
#else /* !CONFIG_LOCKDEP */
202259

203260
/*

0 commit comments

Comments
 (0)