函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\locking\lockdep.c Create Date:2022-07-27 10:50:14
Last Modify:2020-03-17 14:16:01 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:This gets called for every mutex_lock*()/spin_lock*() operation

函数原型: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)

返回类型:int

参数:

类型参数名称
struct lockdep_map *lock
unsigned intsubclass
inttrylock
intread
intcheck
inthardirqs_off
struct lockdep_map *nest_lock
unsigned longip
intreferences
intpin_count
3816  curr等于当前进程
3817  struct lock_class * class = NULL
3820  chain_head等于0
3824  如果此条件成立可能性小(为编译器优化)(!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)则返回:0
3827  如果非r sysctl key恒等于__lockdep_no_validate__check等于0
3830  如果subclass小于NR_LOCKDEP_CACHING_CLASSESclass等于class_cache[subclass]
3835  如果此条件成立可能性小(为编译器优化)(!class)则
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  如果非class则返回:0
3841  debug_class_ops_inc(class)
3843  如果very_verbose(class)则
3844  printk("\nacquire class [%px] %s", key, name)
3845  如果name_version大于1则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  如果DEBUG_LOCKS_WARN_ON(depth >= MAX_LOCK_DEPTH)则返回:0
3863  class_idx等于classlock_classes
3865  如果depth
3866  hlock等于held_locksdepth减1
3867  如果class_idx恒等于class_idxnest_lock
3868  如果非referencesreferences自加
3871  如果非referencesreferences自加
3874  references加等于references
3877  如果DEBUG_LOCKS_WARN_ON(references < references)则返回:0
3880  返回:2
3884  hlock等于held_locksdepth
3889  如果DEBUG_LOCKS_WARN_ON(!class)则返回: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等于非非hardirqs_off
3900  references等于references
3905  pin_count等于pin_count
3908  如果非mark_usage(curr, hlock, check)则返回:0
3924  如果DEBUG_LOCKS_WARN_ON(!st_bit - Determine whether a bit is set*@nr: bit number to test*@addr: Address to start counting from)则返回:0
3927  chain_key等于curr_chain_key
3928  如果非depth
3932  如果DEBUG_LOCKS_WARN_ON(chain_key != INITIAL_CHAIN_KEY)则返回:0
3934  chain_head等于1
3937  prev_chain_key等于chain_key
3938  如果separate_irq_context(curr, hlock)则
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  如果nest_lock且非__lock_is_held(nest_lock, - 1)则
3945  print_lock_nested_lock_not_held(curr, hlock, ip)
3946  返回:0
3949  如果非The locking-testsuite uses to get a* 'silent failure': nothing is printed to the console when* a locking bug is detected.
3950  WARN_ON_ONCE(depth && !key)
3951  WARN_ON_ONCE(!key)
3954  如果非validate_chain(curr, hlock, chain_head, chain_key)则返回: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  如果此条件成立可能性小(为编译器优化)(lockdep_depth >= MAX_LOCK_DEPTH)则
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(当前进程)
3971  debug_show_all_locks()
3972  dump_stack()
3974  返回:0
3977  如果此条件成立可能性小(为编译器优化)(lockdep_depth > max_lockdep_depth)则max_lockdep_depth等于lockdep_depth
3980  返回:1
调用者
名称描述
reacquire_held_locks
lock_acquireWe are not always called with irqs disabled - do that here,* and also avoid lockdep recursion: