函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\events\core.c Create Date:2022-07-27 14:55:46
Last Modify:2022-05-20 07:50:19 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:perf_mmap

函数原型:static int perf_mmap(struct file *file, struct vm_area_struct *vma)

返回类型:int

参数:

类型参数名称
struct file *file
struct vm_area_struct *vma
5791  event等于 needed for tty driver, and maybe others
5793  user等于current_user()
5795  struct ring_buffer * rb = NULL
5798  user_extra等于0, extra等于0
5799  ret等于0, flags等于0
5806  如果cpu恒等于负1且inherit则返回:负EINVAL
5809  如果非Flags, see mm.h. 按位与VM_SHARED的值则返回:负EINVAL
5812  ret等于security_perf_event_read(event)
5813  如果ret则返回:ret
5816  vma_size等于The first byte after our end addresswithin vm_mm. Our start address within vm_mm.
5818  如果Offset (within vm_file) in PAGE_SIZEunits 恒等于0则
5819  nr_pages等于vma_sizePAGE_SIZE减1
5820  否则
5828  如果非rb则返回:负EINVAL
5831  nr_pages等于vma_sizePAGE_SIZE
5833  mutex_lock( & mmap_mutex)
5834  ret等于负EINVAL
5836  rb等于rb
5837  如果非rb则转到:aux_unlock
5840  aux_offset等于READ_ONCE(aux_offset)
5841  aux_size等于READ_ONCE(aux_size)
5843  如果aux_offset小于perf_data_size(rb)加PAGE_SIZE则转到:aux_unlock
5846  如果aux_offset不等于Offset (within vm_file) in PAGE_SIZEunits 左移PAGE_SHIFT determines the page size 位则转到:aux_unlock
5850  如果rb_has_aux(rb)且aux_pgoff不等于Offset (within vm_file) in PAGE_SIZEunits 则转到:aux_unlock
5853  如果aux_size不等于vma_sizeaux_size不等于nr_pagesPAGE_SIZE则转到:aux_unlock
5857  如果rb_has_aux(rb)且aux_nr_pages不等于nr_pages则转到:aux_unlock
5860  如果非s_power_of_2() - check if a value is a power of two*@n: the value to check* Determine whether some value is a power of two, where zero is* *not* considered a power of two.* Return: true if @n is a power of 2, otherwise false.则转到:aux_unlock
5863  如果非atomic_inc_not_zero - increment unless the number is zero*@v: pointer of type atomic_t* Atomically increments @v by 1, if @v is non-zero.* Returns true if the increment was done.则转到:aux_unlock
5866  如果rb_has_aux(rb)则
5868  ret等于0
5869  转到:unlock
5872  atomic_set( & aux_mmap_count, 1)
5873  user_extra等于nr_pages
5875  转到:accounting
5882  如果nr_pages不等于0且非s_power_of_2() - check if a value is a power of two*@n: the value to check* Determine whether some value is a power of two, where zero is* *not* considered a power of two.* Return: true if @n is a power of 2, otherwise false.则返回:负EINVAL
5885  如果vma_size不等于PAGE_SIZE乘1加nr_pages的和则返回:负EINVAL
5888  WARN_ON_ONCE(parent_ctx)
5889  again :
5890  mutex_lock( & mmap_mutex)
5891  如果rb
5892  如果nr_pages不等于nr_pages
5893  ret等于负EINVAL
5894  转到:unlock
5904  转到:again
5907  转到:unlock
5910  user_extra等于nr_pages加1
5912  accounting :
5913  user_lock_limit等于Minimum for 512 kiB + 1 user control page 右移PAGE_SHIFT determines the page size 减10位
5918  user_lock_limit乘等于num_online_cpus()
5920  user_locked等于atomic_long_read( & locked_vm)
5926  如果user_locked大于user_lock_limituser_locked等于user_lock_limit
5928  user_locked加等于user_extra
5930  如果user_locked大于user_lock_limit
5935  extra等于user_lockeduser_lock_limit
5936  user_extra减等于extra
5939  lock_limit等于rlimit(RLIMIT_MEMLOCK)
5940  lock_limit右移等于PAGE_SHIFT determines the page size
5941  locked等于atomic64_read( & pinned_vm)加extra
5943  如果locked大于lock_limitperf_is_paranoid()且非操作权限检查
5945  ret等于负EPERM
5946  转到:unlock
5949  WARN_ON(!rb && rb)
5951  如果Flags, see mm.h. 按位与VM_WRITEflags或等于Buffer handling
5954  如果非rb
5955  rb等于rb_alloc(nr_pages, watermark ? wakeup_watermark : 0, cpu, flags)
5959  如果非rb
5960  ret等于负ENOMEM
5961  转到:unlock
5964  atomic_set( & mmap_count, 1)
5965  mmap_user等于get_current_user - Get the current task's user_struct* Get the user record of the current task, pinning it so that it can't go* away.()
5966  mmap_locked等于extra
5968  ring_buffer_attach(event, rb)
5970  perf_event_init_userpage(event)
5971  Callers need to ensure there can be no nesting of this function, otherwise* the seqlock logic goes bad. We can not serialize this because the arch* code calls this from NMI context.
5972  否则
5973  ret等于rb_alloc_aux(rb, event, Offset (within vm_file) in PAGE_SIZEunits , nr_pages, aux_watermark, flags)
5975  如果非retaux_mmap_locked等于extra
5979  unlock :
5980  如果非ret
5981  atomic_long_add(user_extra, & locked_vm)
5982  atomic64_add(extra, & pinned_vm)
5984  atomic_inc( & mmap_count)
5985  否则如果rb
5986  atomic_dec( & mmap_count)
5988  aux_unlock :
5989  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
5995  Flags, see mm.h. 或等于Do not copy this vma on fork 按位或Cannot expand with mremap() 按位或Do not include in the core dump
5996  Function pointers to deal with this struct. 等于perf_mmap_vmops
5998  如果event_mappedevent_mapped(event, The address space we belong to. )
6001  返回:ret