Lines Matching defs:class
24 * locks (but of the same class as this lock), this code will detect it.
130 * class/list/hash allocators.
296 struct lock_class_stats lock_stats(struct lock_class *class)
304 &per_cpu(cpu_lock_stats, cpu)[class - lock_classes];
325 void clear_lock_stats(struct lock_class *class)
331 &per_cpu(cpu_lock_stats, cpu)[class - lock_classes];
335 memset(class->contention_point, 0, sizeof(class->contention_point));
336 memset(class->contending_point, 0, sizeof(class->contending_point));
339 static struct lock_class_stats *get_lock_stats(struct lock_class *class)
341 return &this_cpu_ptr(cpu_lock_stats)[class - lock_classes];
497 static int class_filter(struct lock_class *class)
501 if (class->name_version == 1 &&
502 !strcmp(class->name, "lockname"))
504 if (class->name_version == 1 &&
505 !strcmp(class->name, "&struct->lockfield"))
513 static int verbose(struct lock_class *class)
516 return class_filter(class);
677 static char get_usage_char(struct lock_class *class, enum lock_usage_bit bit)
693 if (class->usage_mask & lock_flag(bit + LOCK_USAGE_DIR_MASK)) {
695 if (class->usage_mask & lock_flag(bit))
697 } else if (class->usage_mask & lock_flag(bit))
703 void get_usage_chars(struct lock_class *class, char usage[LOCK_USAGE_CHARS])
708 usage[i++] = get_usage_char(class, LOCK_USED_IN_##__STATE); \
709 usage[i++] = get_usage_char(class, LOCK_USED_IN_##__STATE##_READ);
716 static void __print_lock_name(struct held_lock *hlock, struct lock_class *class)
721 name = class->name;
723 name = __get_key_name(class->key, str);
727 if (class->name_version > 1)
728 printk(KERN_CONT "#%d", class->name_version);
729 if (class->subclass)
730 printk(KERN_CONT "/%d", class->subclass);
731 if (hlock && class->print_fn)
732 class->print_fn(hlock->instance);
736 static void print_lock_name(struct held_lock *hlock, struct lock_class *class)
740 get_usage_chars(class, usage);
743 __print_lock_name(hlock, class);
745 class->wait_type_outer ?: class->wait_type_inner,
746 class->wait_type_inner);
769 * registered class. The rationale here is: since we don't attempt
814 static int very_verbose(struct lock_class *class)
817 return class_filter(class);
863 * class->name_version generation counter. The caller must hold the graph
868 struct lock_class *class;
874 list_for_each_entry(class, &all_lock_classes, lock_entry) {
875 if (new_class->key - new_class->subclass == class->key)
876 return class->name_version;
877 if (class->name && !strcmp(class->name, new_class->name))
878 count = max(count, class->name_version);
890 struct lock_class *class;
914 * NOTE: the class-key must be unique. For dynamic locks, a static
932 hlist_for_each_entry_rcu_notrace(class, hash_head, hash_entry) {
933 if (class->key == key) {
938 WARN_ONCE(class->name != lock->name &&
940 "Looking for class \"%s\" with key %ps, but found a different class \"%s\" with the same key\n",
941 lock->name, lock->key, class->name);
942 return class;
950 * Static locks do not have their class-keys yet - for them the key is
962 * objects as class key for static objects, check whether the
1012 struct lock_class *class;
1016 class = &lock_classes[i];
1017 if (in_list(e, &class->locks_after) ||
1018 in_list(e, &class->locks_before))
1030 printk(KERN_INFO "class %s: mismatch for lock entry %ld; class %s <> %s",
1035 e->class && e->class->name ? e->class->name :
1070 static bool in_any_zapped_class_list(struct lock_class *class)
1076 if (in_list(&class->lock_entry, &pf->zapped))
1085 struct lock_class *class;
1093 class = &lock_classes[i];
1094 if (!in_list(&class->lock_entry, &all_lock_classes) &&
1095 !in_list(&class->lock_entry, &free_lock_classes) &&
1096 !in_any_zapped_class_list(class)) {
1097 printk(KERN_INFO "class %px/%s is not in any class list\n",
1098 class, class->name ? : "(?)");
1105 class = &lock_classes[i];
1106 if (!class_lock_list_valid(class, &class->locks_before))
1108 if (!class_lock_list_valid(class, &class->locks_after))
1122 * Check whether all list entries that are in use occur in a class
1128 printk(KERN_INFO "list entry %d is not in any class list; class %s <> %s\n",
1130 e->class->name ? : "(?)",
1138 * a class lock list.
1143 printk(KERN_INFO "list entry %d occurs in a class list; class %s <> %s\n",
1145 e->class && e->class->name ? e->class->name :
1278 * Register a lock's class in the hash-table, if the class is not present
1287 struct lock_class *class;
1292 class = look_up_lock_class(lock, subclass);
1293 if (likely(class))
1313 hlist_for_each_entry_rcu(class, hash_head, hash_entry) {
1314 if (class->key == key)
1320 /* Allocate a new lock class and add it to the hash. */
1321 class = list_first_entry_or_null(&free_lock_classes, typeof(*class),
1323 if (!class) {
1335 __set_bit(class - lock_classes, lock_classes_in_use);
1337 class->key = key;
1338 class->name = lock->name;
1339 class->subclass = subclass;
1340 WARN_ON_ONCE(!list_empty(&class->locks_before));
1341 WARN_ON_ONCE(!list_empty(&class->locks_after));
1342 class->name_version = count_matching_names(class);
1343 class->wait_type_inner = lock->wait_type_inner;
1344 class->wait_type_outer = lock->wait_type_outer;
1345 class->lock_type = lock->lock_type;
1350 hlist_add_head_rcu(&class->hash_entry, hash_head);
1352 * Remove the class from the free list and add it to the global list
1355 list_move_tail(&class->lock_entry, &all_lock_classes);
1356 idx = class - lock_classes;
1360 if (verbose(class)) {
1364 printk("\nnew class %px: %s", class->key, class->name);
1365 if (class->name_version > 1)
1366 printk(KERN_CONT "#%d", class->name_version);
1380 lock->class_cache[0] = class;
1382 lock->class_cache[subclass] = class;
1385 * Hash collision, did we smoke some? We found a class with a matching
1388 if (DEBUG_LOCKS_WARN_ON(class->subclass != subclass))
1391 return class;
1436 entry->class = this;
1528 lock->class->dep_gen_id = lockdep_dependency_gen_id;
1539 return lock->class->dep_gen_id == lockdep_dependency_gen_id;
1562 * @lock: the lock_list to get its class's dependency list
1568 void *lock_class = lock->class;
1655 * Initialize a lock_list entry @lock belonging to @class as the root for a BFS
1659 struct lock_class *class)
1661 lock->class = class;
1751 if (!lock->class)
1759 * @lock->class->locks_{after,before}) we skip, otherwise go
1879 print_lock_name(NULL, target->class);
1891 struct lock_class *parent = prt->class;
1979 * entry->class.
2006 return hlock_class(hlock) == entry->class && /* Found A -> .. -> B */
2014 * entry->class.
2033 return hlock_class(hlock) == entry->class && /* Found A -> .. -> B */
2110 unsigned long lockdep_count_forward_deps(struct lock_class *class)
2115 __bfs_init_root(&this, class);
2136 unsigned long lockdep_count_backward_deps(struct lock_class *class)
2141 __bfs_init_root(&this, class);
2260 *(unsigned long *)mask |= entry->class->usage_mask;
2262 *(unsigned long *)mask |= (entry->class->usage_mask & LOCKF_IRQ);
2279 return !!(entry->class->usage_mask & *(unsigned long *)mask);
2281 return !!((entry->class->usage_mask & LOCKF_IRQ) & *(unsigned long *)mask);
2286 if (entry->class->lock_type == LD_LOCK_NORMAL)
2315 if (entry->class->lock_type == LD_LOCK_PERCPU &&
2316 DEBUG_LOCKS_WARN_ON(entry->class->wait_type_inner < LD_WAIT_CONFIG))
2329 * at @root->class that matches @bit.
2349 * at @root->class that matches @bit.
2364 static void print_lock_class_header(struct lock_class *class, int depth)
2369 print_lock_name(NULL, class);
2371 printk(KERN_CONT " ops: %lu", debug_class_ops_read(class));
2376 if (class->usage_mask & (1 << bit)) {
2381 print_lock_trace(class->usage_traces[bit], len);
2387 depth, "", class->key, class->key);
2401 * a) lock_list in the ->locks_after list of A, whose ->class is B and
2405 * b) lock_list in the ->locks_before list of B, whose ->class is A
2415 * ->class is A, as a result BFS will search all dependencies starting with
2439 * , so it's natural that we start from @leaf and print every ->class and
2453 print_lock_class_header(entry->class, depth);
2483 * Another thing to notice here is that ->class of L2 <- L1 is L1, while the
2500 print_lock_class_header(entry->class, depth);
2529 struct lock_class *safe_class = safe_entry->class;
2530 struct lock_class *unsafe_class = unsafe_entry->class;
2620 print_lock_name(NULL, backwards_entry->class);
2623 print_lock_trace(backwards_entry->class->usage_traces[bit1], 1);
2626 print_lock_name(NULL, forwards_entry->class);
2630 print_lock_trace(forwards_entry->class->usage_traces[bit2], 1);
2870 backward_mask = original_mask(target_entry1->class->usage_mask & LOCKF_ENABLED_IRQ_ALL);
2884 ret = find_exclusive_match(target_entry->class->usage_mask,
2885 target_entry1->class->usage_mask,
3011 struct lock_class *class = hlock_class(prev);
3029 if (class->cmp_fn) {
3031 class->cmp_fn(prev->instance, next->instance));
3045 * Check whether we are holding such a class already.
3051 * lock class is held but nest_lock is also held, i.e. we rely on the
3057 struct lock_class *class;
3073 * lock class (i.e. read_lock(lock)+read_lock(lock)):
3078 class = hlock_class(prev);
3080 if (class->cmp_fn &&
3081 class->cmp_fn(prev->instance, next->instance) < 0)
3130 * of the class name. It is better to trigger a use-after free
3131 * and to have the class name most of the time instead of not
3132 * having the class name available.
3135 "Detected use-after-free of lock class %px/%s\n",
3139 "Detected use-after-free of lock class %px/%s\n",
3146 struct lock_class *class = hlock_class(prev);
3148 if (class->cmp_fn &&
3149 class->cmp_fn(prev->instance, next->instance) < 0)
3179 if (entry->class == hlock_class(next)) {
3201 if (entry->class == hlock_class(prev)) {
3337 * Bit 15 - always set to 1 (it is not a class index)
3818 struct lock_class *class = hlock_class(hlock);
3826 if (very_verbose(class)) {
3828 "%016Lx tail class: [%px] %s\n",
3830 class->key, class->name);
3836 if (very_verbose(class)) {
3837 printk("\nnew hash chain, key: %016Lx tail class: [%px] %s\n",
3838 (unsigned long long)chain_key, class->key, class->name);
3901 * same lock class) nor deadlock (because the nest_lock
3958 * it registered lock class index?
3989 struct lock_class *class = hlock_class(lock);
3995 __print_lock_name(lock, class);
3999 __print_lock_name(lock, class);
4091 print_lock_name(NULL, other->class);
4109 middle ? middle->class : root->class, other->class);
4112 middle ? middle->class : other->class, root->class);
4152 if (target_entry->class->usage_mask & lock_flag(bit)) {
4187 if (target_entry->class->usage_mask & lock_flag(bit)) {
4221 static int HARDIRQ_verbose(struct lock_class *class)
4224 return class_filter(class);
4229 static int SOFTIRQ_verbose(struct lock_class *class)
4232 return class_filter(class);
4237 static int (*state_verbose_f[])(struct lock_class *class) = {
4245 struct lock_class *class)
4247 return state_verbose_f[bit >> LOCK_USAGE_DIR_MASK](class);
4877 struct lock_class *class = hlock_class(prev);
4878 u8 prev_inner = class->wait_type_inner;
4894 if (unlikely(class->lock_type == LD_LOCK_WAIT_OVERRIDE))
4933 * Initialize a lock instance's lock-class mapping info:
4968 * Sanity check, the lock-class key must either have been allocated
5007 struct lock_class *class = lock->class_cache[0];
5013 if (!class)
5014 class = register_lock_class(lock, 0, 0);
5016 if (class) {
5017 WARN_ON(class->cmp_fn && class->cmp_fn != cmp_fn);
5018 WARN_ON(class->print_fn && class->print_fn != print_fn);
5020 class->cmp_fn = cmp_fn;
5021 class->print_fn = print_fn;
5081 struct lock_class *class = NULL;
5098 class = lock->class_cache[subclass];
5102 if (unlikely(!class)) {
5103 class = register_lock_class(lock, subclass, 0);
5104 if (!class)
5108 debug_class_ops_inc(class);
5110 if (very_verbose(class)) {
5112 printk("\nacquire class [%px] %s", class->key, class->name);
5113 if (class->name_version > 1)
5114 printk(KERN_CONT "#%d", class->name_version);
5132 class_idx = class - lock_classes;
5159 if (DEBUG_LOCKS_WARN_ON(!class))
5193 * the hash, not class->key.
5301 const struct lock_class *class = lock->class_cache[0];
5303 if (!class)
5304 class = look_up_lock_class(lock, 0);
5307 * If look_up_lock_class() failed to find a class, we're trying
5312 if (!class)
5323 if (hlock->class_idx == class - lock_classes)
5406 struct lock_class *class;
5414 * This function is about (re)setting the class of a held lock,
5430 class = register_lock_class(lock, subclass, 0);
5431 hlock->class_idx = class - lock_classes;
5460 * This function is about (re)setting the class of a held lock,
5764 struct lock_class *class = look_up_lock_class(lock, subclass);
5767 /* if it doesn't have a class (yet), it certainly hasn't been used yet */
5768 if (!class)
5778 if (!(class->usage_mask & mask))
5781 hlock->class_idx = class - lock_classes;
6172 /* Remove a class from a lock chain. Must be called with the graph lock held. */
6175 struct lock_class *class)
6181 if (chain_hlock_class_idx(chain_hlocks[i]) != class - lock_classes)
6184 * Each lock class occurs at most once in a lock chain so once
6210 struct lock_class *class)
6219 remove_class_from_lock_chain(pf, chain, class);
6225 * Remove all references to a lock class. The caller must hold the graph lock.
6227 static void zap_class(struct pending_free *pf, struct lock_class *class)
6232 WARN_ON_ONCE(!class->key);
6240 if (entry->class != class && entry->links_to != class)
6246 if (list_empty(&class->locks_after) &&
6247 list_empty(&class->locks_before)) {
6248 list_move_tail(&class->lock_entry, &pf->zapped);
6249 hlist_del_rcu(&class->hash_entry);
6250 WRITE_ONCE(class->key, NULL);
6251 WRITE_ONCE(class->name, NULL);
6253 __clear_bit(class - lock_classes, lock_classes_in_use);
6254 if (class - lock_classes == max_lock_class_idx)
6257 WARN_ONCE(true, "%s() failed for class %s\n", __func__,
6258 class->name);
6261 remove_class_from_lock_chains(pf, class);
6265 static void reinit_class(struct lock_class *class)
6267 WARN_ON_ONCE(!class->lock_entry.next);
6268 WARN_ON_ONCE(!list_empty(&class->locks_after));
6269 WARN_ON_ONCE(!list_empty(&class->locks_before));
6270 memset_startat(class, 0, key);
6271 WARN_ON_ONCE(!class->lock_entry.next);
6272 WARN_ON_ONCE(!list_empty(&class->locks_after));
6273 WARN_ON_ONCE(!list_empty(&class->locks_before));
6321 struct lock_class *class;
6325 list_for_each_entry(class, &pf->zapped, lock_entry)
6326 reinit_class(class);
6368 * Remove all lock classes from the class hash table and from the
6376 struct lock_class *class;
6383 hlist_for_each_entry_rcu(class, head, hash_entry) {
6384 if (!within(class->key, start, size) &&
6385 !within(class->name, start, size))
6387 zap_class(pf, class);
6455 * registered lock class. The caller must hold either the graph lock or the
6460 struct lock_class *class;
6466 hlist_for_each_entry_rcu(class, head, hash_entry) {
6468 if (lock->class_cache[j] == class)
6479 struct lock_class *class;
6487 * If the class exists we look it up and zap it:
6489 class = look_up_lock_class(lock, j);
6490 if (class)
6491 zap_class(pf, class);