Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:This gets called for every mutex_lock*()/spin_lock*() operation

Proto:static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, int trylock, int read, int check, int hardirqs_off, struct lockdep_map *nest_lock, unsigned long ip, int references, int pin_count)

Type:int

Parameter:

TypeParameterName
struct lockdep_map *lock
unsigned intsubclass
inttrylock
intread
intcheck
inthardirqs_off
struct lockdep_map *nest_lock
unsigned longip
intreferences
intpin_count
3816  curr = current process
3817  struct lock_class * class = NULL
3820  chain_head = 0
3824  If Value for the false possibility is greater at compile time(!We want to turn all lock-debugging facilities on/off at once,* via a global flag. The reason is that once a single bug has been* detected and reported, there might be cascade of followup bugs* that would just muddy the log. So we report the first one and) Then Return 0
3827  If Not r sysctl || key == __lockdep_no_validate__ Then check = 0
3830  If subclass < NR_LOCKDEP_CACHING_CLASSES Then class = class_cache[subclass]
3835  If Value for the false possibility is greater at compile time(!class) Then
3836  class = 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.
3837  If Not class Then Return 0
3841  debug_class_ops_inc(class)
3843  If very_verbose(class) Then
3844  printk("\nacquire class [%px] %s", key, name)
3845  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)
3847  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")
3848  dump_stack()
3856  depth = lockdep_depth
3860  If DEBUG_LOCKS_WARN_ON(depth >= MAX_LOCK_DEPTH) Then Return 0
3863  class_idx = class - lock_classes
3865  If depth Then
3866  hlock = held_locks + depth - 1
3867  If class_idx == class_idx && nest_lock Then
3868  If Not references Then references++
3871  If Not references Then references++
3877  If DEBUG_LOCKS_WARN_ON(references < references) Then Return 0
3880  Return 2
3884  hlock = held_locks + depth
3889  If DEBUG_LOCKS_WARN_ON(!class) Then Return 0
3891  class_idx = class_idx
3892  acquire_ip = ip
3893  instance = lock
3894  nest_lock = nest_lock
3895  irq_context = task_irq_context(curr)
3896  trylock = trylock
3897  read = read
3898  check = check
3899  hardirqs_off = Not Not hardirqs_off
3900  references = references
3905  pin_count = pin_count
3908  If Not mark_usage(curr, hlock, check) Then Return 0
3924  If DEBUG_LOCKS_WARN_ON(!st_bit - Determine whether a bit is set*@nr: bit number to test*@addr: Address to start counting from) Then Return 0
3927  chain_key = curr_chain_key
3928  If Not depth Then
3932  If DEBUG_LOCKS_WARN_ON(chain_key != INITIAL_CHAIN_KEY) Then Return 0
3934  chain_head = 1
3937  prev_chain_key = chain_key
3938  If separate_irq_context(curr, hlock) Then
3939  chain_key = INITIAL_CHAIN_KEY
3940  chain_head = 1
3942  chain_key = The hash key of the lock dependency chains is a hash itself too:* it's a hash of all locks taken up to that lock, including that lock.* It's a 64-bit hash, because it's important for the keys to be* unique.
3944  If nest_lock && Not __lock_is_held(nest_lock, - 1) Then
3945  print_lock_nested_lock_not_held(curr, hlock, ip)
3946  Return 0
3949  If Not The locking-testsuite uses to get a 'silent failure': nothing is printed to the console when a locking bug is detected Then
3950  WARN_ON_ONCE(depth && !key)
3951  WARN_ON_ONCE(!key)
3954  If Not validate_chain(curr, hlock, chain_head, chain_key) Then Return 0
3957  curr_chain_key = chain_key
3958  lockdep_depth++
3959  We are building curr_chain_key incrementally, so double-check* it from scratch, to make sure that it's done correctly:
3964  If Value for the false possibility is greater at compile time(lockdep_depth >= MAX_LOCK_DEPTH) Then
3965  Generic 'turn off all lock debugging' function:
3966  print_lockdep_off("BUG: MAX_LOCK_DEPTH too low!")
3967  printk(debug-level messages "depth: %i max: %lu!\n", lockdep_depth, MAX_LOCK_DEPTH)
3970  lockdep_print_held_locks(current process)
3971  debug_show_all_locks()
3972  dump_stack()
3974  Return 0
3977  If Value for the false possibility is greater at compile time(lockdep_depth > max_lockdep_depth) Then max_lockdep_depth = lockdep_depth
3980  Return 1
Caller
NameDescribe
reacquire_held_locks
lock_acquireWe are not always called with irqs disabled - do that here,* and also avoid lockdep recursion: