Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\locking\lockdep.c Create Date:2022-07-28 09:49:45
Last Modify:2020-03-17 14:16:01 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Register a lock's class in the hash-table, if the class is not present* yet. Otherwise we look it up. We cache the result in the lock object* itself, so actual lookup of the hash should be once per lock object.

Proto:static struct lock_class *register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)

Type:struct lock_class

Parameter:

TypeParameterName
struct lockdep_map *lock
unsigned intsubclass
intforce
1182  DEBUG_LOCKS_WARN_ON(!Some architectures don't define arch_irqs_disabled(), so even if either* definition would be fine we need to use different ones for the time being* to avoid build issues.())
1184  class = look_up_lock_class(lock, subclass)
1185  If Value is more likely to compile time(class) Then Go to out_set_class_cache
1188  If Not key Then
1189  If Not Static locks do not have their class-keys yet - for them the key is* the lock object itself. If the lock is in the per cpu area, the* canonical address of the lock (per cpu offset removed) is used. Then Return NULL
1191  Else if Not Is this the address of a static object: && Not Check whether a key has been registered as a dynamic key. Then
1192  Return NULL
1195  key = subkeys + subclass
1196  hash_head = classhashentry(key)
1198  If Not graph_lock() Then
1199  Return NULL
1206  If key == key Then Go to out_unlock_set
1210  Initialize the lock_classes[] array elements, the free_lock_classes list* and also the delayed_free structure.
1213  class = list_first_entry_or_null - get the first element from a list*@ptr: the list head to take the element from.*@type: the type of the struct this is embedded in.*@member: the name of the list_head within the struct.( & free_lock_classes, typeof( * class), lock_entry)
1215  If Not class Then
1217  Return NULL
1220  print_lockdep_off("BUG: MAX_LOCKDEP_KEYS too low!")
1221  dump_stack()
1222  Return NULL
1224  nr_lock_classes++
1225  __set_bit - Set a bit in memory*@nr: the bit to set*@addr: the address to start counting from* Unlike set_bit(), this function is non-atomic. If it is called on the same* region of memory concurrently, the effect may be that only one operation* succeeds.
1226  debug_atomic_inc(nr_unused_locks)
1227  key = key
1228  name = name
1229  subclass = subclass
1230  WARN_ON_ONCE(!list_empty - tests whether a list is empty*@head: the list to test.)
1231  WARN_ON_ONCE(!list_empty - tests whether a list is empty*@head: the list to test.)
1232  name_version = To make lock name printouts unique, we calculate a unique* class->name_version generation counter. The caller must hold the graph* lock.
1237  adds the specified element to the specified hlist
1242  list_move_tail - delete from one list and add as another's tail*@list: the entry to move*@head: the head that will follow our entry
1244  If verbose(class) Then
1245  graph_unlock()
1247  printk("\nnew class %px: %s", key, name)
1248  If name_version > 1 Then printk(Annotation for a "continued" line of log printout (only done after a* line that had no enclosing \n). Only to be used by core/arch code* during early bootup (a continued line is not SMP-safe otherwise)."#%d", name_version)
1250  printk(Annotation for a "continued" line of log printout (only done after a* line that had no enclosing \n). Only to be used by core/arch code* during early bootup (a continued line is not SMP-safe otherwise)."\n")
1251  dump_stack()
1253  If Not graph_lock() Then
1254  Return NULL
1257  out_unlock_set :
1258  graph_unlock()
1260  out_set_class_cache :
1261  If Not subclass || force Then class_cache[0] = class
1263  Else if subclass < NR_LOCKDEP_CACHING_CLASSES Then class_cache[subclass] = class
1270  If DEBUG_LOCKS_WARN_ON(subclass != subclass) Then Return NULL
1273  Return class
Caller
NameDescribe
lockdep_init_mapInitialize a lock instance's lock-class mapping info:
__lock_acquireThis gets called for every mutex_lock*()/spin_lock*() operation
__lock_set_class