Lines Matching +full:c +full:- +full:define +full:- +full:name
1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
6 * Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra
8 * see Documentation/locking/lockdep-design.rst for more details.
11 #define __LINUX_LOCKDEP_H
41 to->class_cache[i] = NULL; in lockdep_copy_map()
56 /* used by BFS to record whether "prev -> this" only has -(*R)-> */
60 * The parent field is used to implement breadth-first search, and the
67 * struct lock_chain - lock dependency chain record
86 * Initialization, self-test and debugging-output methods:
100 #define LOCKDEP_RECURSION_BITS 16
101 #define LOCKDEP_OFF (1U << LOCKDEP_RECURSION_BITS)
102 #define LOCKDEP_RECURSION_MASK (LOCKDEP_OFF - 1)
109 #define lockdep_off() \
111 current->lockdep_recursion += LOCKDEP_OFF; \
114 #define lockdep_on() \
116 current->lockdep_recursion -= LOCKDEP_OFF; \
128 extern void lockdep_init_map_type(struct lockdep_map *lock, const char *name,
132 lockdep_init_map_waits(struct lockdep_map *lock, const char *name, in lockdep_init_map_waits() argument
135 lockdep_init_map_type(lock, name, key, subclass, inner, outer, LD_LOCK_NORMAL); in lockdep_init_map_waits()
139 lockdep_init_map_wait(struct lockdep_map *lock, const char *name, in lockdep_init_map_wait() argument
142 lockdep_init_map_waits(lock, name, key, subclass, inner, LD_WAIT_INV); in lockdep_init_map_wait()
145 static inline void lockdep_init_map(struct lockdep_map *lock, const char *name, in lockdep_init_map() argument
148 lockdep_init_map_wait(lock, name, key, subclass, LD_WAIT_INV); in lockdep_init_map()
152 * Reinitialize a lock key - for cases where there is special locking or
154 * of dependencies wrong: they are either too broad (they need a class-split)
155 * or they are too narrow (they suffer from a false class-split):
157 #define lockdep_set_class(lock, key) \
158 lockdep_init_map_type(&(lock)->dep_map, #key, key, 0, \
159 (lock)->dep_map.wait_type_inner, \
160 (lock)->dep_map.wait_type_outer, \
161 (lock)->dep_map.lock_type)
163 #define lockdep_set_class_and_name(lock, key, name) \ argument
164 lockdep_init_map_type(&(lock)->dep_map, name, key, 0, \
165 (lock)->dep_map.wait_type_inner, \
166 (lock)->dep_map.wait_type_outer, \
167 (lock)->dep_map.lock_type)
169 #define lockdep_set_class_and_subclass(lock, key, sub) \
170 lockdep_init_map_type(&(lock)->dep_map, #key, key, sub, \
171 (lock)->dep_map.wait_type_inner, \
172 (lock)->dep_map.wait_type_outer, \
173 (lock)->dep_map.lock_type)
175 #define lockdep_set_subclass(lock, sub) \
176 lockdep_init_map_type(&(lock)->dep_map, #lock, (lock)->dep_map.key, sub,\
177 (lock)->dep_map.wait_type_inner, \
178 (lock)->dep_map.wait_type_outer, \
179 (lock)->dep_map.lock_type)
189 #define lockdep_set_novalidate_class(lock) \
199 #define lockdep_set_notrack_class(lock) \
205 #define lockdep_match_class(lock, key) lockdep_match_key(&(lock)->dep_map, key)
210 return lock->key == key; in lockdep_match_key()
219 * 1: read-acquire (no recursion allowed)
220 * 2: read-acquire with same-instance recursion allowed
224 * 0: simple checks (freeing, held-at-exit-time, etc.)
238 #define LOCK_STATE_UNKNOWN -1
239 #define LOCK_STATE_NOT_HELD 0
240 #define LOCK_STATE_HELD 1
243 * Same "read" as for lock_acquire(), except -1 means any.
249 return lock_is_held_type(lock, -1); in lock_is_held()
252 #define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map)
253 #define lockdep_is_held_type(lock, r) lock_is_held_type(&(lock)->dep_map, (r))
255 extern void lock_set_class(struct lockdep_map *lock, const char *name,
259 #define lock_set_novalidate_class(l, n, i) \
265 lock_set_class(lock, lock->name, lock->key, subclass, ip); in lock_set_subclass()
270 #define NIL_COOKIE (struct pin_cookie){ .val = 0U, }
276 #define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0)
278 #define lockdep_assert(cond) \
281 #define lockdep_assert_once(cond) \
284 #define lockdep_assert_held(l) \
287 #define lockdep_assert_not_held(l) \
290 #define lockdep_assert_held_write(l) \
293 #define lockdep_assert_held_read(l) \
296 #define lockdep_assert_held_once(l) \
299 #define lockdep_assert_none_held_once() \
300 lockdep_assert_once(!current->lockdep_depth)
302 #define lockdep_recursing(tsk) ((tsk)->lockdep_recursion)
304 #define lockdep_pin_lock(l) lock_pin_lock(&(l)->dep_map)
305 #define lockdep_repin_lock(l,c) lock_repin_lock(&(l)->dep_map, (c)) argument
306 #define lockdep_unpin_lock(l,c) lock_unpin_lock(&(l)->dep_map, (c)) argument
312 #define DEFINE_WAIT_OVERRIDE_MAP(_name, _wait_type) \
314 .name = #_name "-wait-type-override", \
336 # define lock_acquire(l, s, t, r, c, n, i) do { } while (0) argument
337 # define lock_release(l, i) do { } while (0)
338 # define lock_downgrade(l, i) do { } while (0)
339 # define lock_set_class(l, n, key, s, i) do { (void)(key); } while (0)
340 # define lock_set_novalidate_class(l, n, i) do { } while (0)
341 # define lock_set_subclass(l, s, i) do { } while (0)
342 # define lockdep_init() do { } while (0)
343 # define lockdep_init_map_type(lock, name, key, sub, inner, outer, type) \ argument
344 do { (void)(name); (void)(key); } while (0)
345 # define lockdep_init_map_waits(lock, name, key, sub, inner, outer) \ argument
346 do { (void)(name); (void)(key); } while (0)
347 # define lockdep_init_map_wait(lock, name, key, sub, inner) \ argument
348 do { (void)(name); (void)(key); } while (0)
349 # define lockdep_init_map(lock, name, key, sub) \ argument
350 do { (void)(name); (void)(key); } while (0)
351 # define lockdep_set_class(lock, key) do { (void)(key); } while (0)
352 # define lockdep_set_class_and_name(lock, key, name) \ argument
353 do { (void)(key); (void)(name); } while (0)
354 #define lockdep_set_class_and_subclass(lock, key, sub) \
356 #define lockdep_set_subclass(lock, sub) do { } while (0)
358 #define lockdep_set_novalidate_class(lock) do { } while (0)
359 #define lockdep_set_notrack_class(lock) do { } while (0)
362 * We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP
367 # define lockdep_reset() do { debug_locks = 1; } while (0)
368 # define lockdep_free_key_range(start, size) do { } while (0)
369 # define lockdep_sys_exit() do { } while (0)
379 #define lockdep_depth(tsk) (0)
382 * Dummy forward declarations, allow users to write less ifdef-y code
387 #define lockdep_is_held_type(l, r) (1)
389 #define lockdep_assert(c) do { } while (0) argument
390 #define lockdep_assert_once(c) do { } while (0) argument
392 #define lockdep_assert_held(l) do { (void)(l); } while (0)
393 #define lockdep_assert_not_held(l) do { (void)(l); } while (0)
394 #define lockdep_assert_held_write(l) do { (void)(l); } while (0)
395 #define lockdep_assert_held_read(l) do { (void)(l); } while (0)
396 #define lockdep_assert_held_once(l) do { (void)(l); } while (0)
397 #define lockdep_assert_none_held_once() do { } while (0)
399 #define lockdep_recursing(tsk) (0)
401 #define NIL_COOKIE (struct pin_cookie){ }
403 #define lockdep_pin_lock(l) ({ struct pin_cookie cookie = { }; cookie; })
404 #define lockdep_repin_lock(l, c) do { (void)(l); (void)(c); } while (0) argument
405 #define lockdep_unpin_lock(l, c) do { (void)(l); (void)(c); } while (0) argument
407 #define DEFINE_WAIT_OVERRIDE_MAP(_name, _wait_type) \
415 #define lock_set_cmp_fn(lock, ...) lockdep_set_lock_cmp_fn(&(lock)->dep_map, __VA_ARGS__)
417 #define lock_set_cmp_fn(lock, ...) do { } while (0)
430 #define STATIC_LOCKDEP_MAP_INIT(_name, _key) \
431 { .name = (_name), .key = (void *)(_key), }
441 #define LOCK_CONTENDED(_lock, try, lock) \
444 lock_contended(&(_lock)->dep_map, _RET_IP_); \
447 lock_acquired(&(_lock)->dep_map, _RET_IP_); \
450 #define LOCK_CONTENDED_RETURN(_lock, try, lock) \
454 lock_contended(&(_lock)->dep_map, _RET_IP_); \
458 lock_acquired(&(_lock)->dep_map, _RET_IP_); \
464 #define lock_contended(lockdep_map, ip) do {} while (0)
465 #define lock_acquired(lockdep_map, ip) do {} while (0)
467 #define LOCK_CONTENDED(_lock, try, lock) \
470 #define LOCK_CONTENDED_RETURN(_lock, try, lock) \
487 #define force_read_lock_recursive 0
494 #define read_lock_is_recursive() 0
498 * For trivial one-depth nesting of a lock-class, the following
499 * global define can be used. (Subsystems with multiple levels
500 * of nesting should define their own lock-nesting subclasses.)
502 #define SINGLE_DEPTH_NESTING 1
506 * on the per lock-class debug mode:
509 #define lock_acquire_exclusive(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, n, i)
510 #define lock_acquire_shared(l, s, t, n, i) lock_acquire(l, s, t, 1, 1, n, i)
511 #define lock_acquire_shared_recursive(l, s, t, n, i) lock_acquire(l, s, t, 2, 1, n, i)
513 #define spin_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i)
514 #define spin_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i)
515 #define spin_release(l, i) lock_release(l, i)
517 #define rwlock_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i)
518 #define rwlock_acquire_read(l, s, t, i) \
526 #define rwlock_release(l, i) lock_release(l, i)
528 #define seqcount_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i)
529 #define seqcount_acquire_read(l, s, t, i) lock_acquire_shared_recursive(l, s, t, NULL, i)
530 #define seqcount_release(l, i) lock_release(l, i)
532 #define mutex_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i)
533 #define mutex_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i)
534 #define mutex_release(l, i) lock_release(l, i)
536 #define rwsem_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i)
537 #define rwsem_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i)
538 #define rwsem_acquire_read(l, s, t, i) lock_acquire_shared(l, s, t, NULL, i)
539 #define rwsem_release(l, i) lock_release(l, i)
541 #define lock_map_acquire(l) lock_acquire_exclusive(l, 0, 0, NULL, _THIS_IP_)
542 #define lock_map_acquire_try(l) lock_acquire_exclusive(l, 0, 1, NULL, _THIS_IP_)
543 #define lock_map_acquire_read(l) lock_acquire_shared_recursive(l, 0, 0, NULL, _THIS_IP_)
544 #define lock_map_acquire_tryread(l) lock_acquire_shared_recursive(l, 0, 1, NULL, _THIS_IP_)
545 #define lock_map_release(l) lock_release(l, _THIS_IP_)
546 #define lock_map_sync(l) lock_sync(l, 0, 0, 1, NULL, _THIS_IP_)
549 # define might_lock(lock) \
551 typecheck(struct lockdep_map *, &(lock)->dep_map); \
552 lock_acquire(&(lock)->dep_map, 0, 0, 0, 1, NULL, _THIS_IP_); \
553 lock_release(&(lock)->dep_map, _THIS_IP_); \
555 # define might_lock_read(lock) \
557 typecheck(struct lockdep_map *, &(lock)->dep_map); \
558 lock_acquire(&(lock)->dep_map, 0, 0, 1, 1, NULL, _THIS_IP_); \
559 lock_release(&(lock)->dep_map, _THIS_IP_); \
561 # define might_lock_nested(lock, subclass) \
563 typecheck(struct lockdep_map *, &(lock)->dep_map); \
564 lock_acquire(&(lock)->dep_map, subclass, 0, 1, 1, NULL, \
566 lock_release(&(lock)->dep_map, _THIS_IP_); \
573 #define __lockdep_enabled (debug_locks && !this_cpu_read(lockdep_recursion))
575 #define lockdep_assert_irqs_enabled() \
580 #define lockdep_assert_irqs_disabled() \
585 #define lockdep_assert_in_irq() \
590 #define lockdep_assert_no_hardirq() \
596 #define lockdep_assert_preemption_enabled() \
604 #define lockdep_assert_preemption_disabled() \
613 * Acceptable for protecting per-CPU resources accessed from BH.
614 * Much like in_softirq() - semantics are ambiguous, use carefully.
616 #define lockdep_assert_in_softirq() \
625 # define might_lock(lock) do { } while (0)
626 # define might_lock_read(lock) do { } while (0)
627 # define might_lock_nested(lock, subclass) do { } while (0)
629 # define lockdep_assert_irqs_enabled() do { } while (0)
630 # define lockdep_assert_irqs_disabled() do { } while (0)
631 # define lockdep_assert_in_irq() do { } while (0)
632 # define lockdep_assert_no_hardirq() do { } while (0)
634 # define lockdep_assert_preemption_enabled() do { } while (0)
635 # define lockdep_assert_preemption_disabled() do { } while (0)
636 # define lockdep_assert_in_softirq() do { } while (0)
637 # define lockdep_assert_in_softirq_func() do { } while (0)
642 # define lockdep_assert_RT_in_threaded_ctx() do { \
643 WARN_ONCE(debug_locks && !current->lockdep_recursion && \
645 !(current->hardirq_threaded || current->irq_config), \
651 # define lockdep_assert_RT_in_threaded_ctx() do { } while (0)