Function report |
Source Code:kernel\events\core.c |
Create Date:2022-07-28 13:36:05 |
Last Modify:2022-05-20 07:50:19 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:perf_mmap
Proto:static int perf_mmap(struct file *file, struct vm_area_struct *vma)
Type:int
Parameter:
Type | Parameter | Name |
---|---|---|
struct file * | file | |
struct vm_area_struct * | vma |
5793 | user = current_user() |
5795 | struct ring_buffer * rb = NULL |
5798 | user_extra = 0 , extra = 0 |
5809 | If Not (Flags, see mm.h. & VM_SHARED) Then Return -EINVAL |
5812 | ret = security_perf_event_read(event) |
5818 | If Offset (within vm_file) in PAGE_SIZEunits == 0 Then |
5820 | Else |
5833 | mutex_lock( & mmap_mutex) |
5837 | If Not rb Then Go to aux_unlock |
5840 | aux_offset = READ_ONCE(aux_offset) |
5843 | If aux_offset < perf_data_size(rb) + PAGE_SIZE Then Go to aux_unlock |
5846 | If aux_offset != Offset (within vm_file) in PAGE_SIZEunits << PAGE_SHIFT determines the page size Then Go to aux_unlock |
5850 | If rb_has_aux(rb) && aux_pgoff != Offset (within vm_file) in PAGE_SIZEunits Then Go to aux_unlock |
5857 | If rb_has_aux(rb) && aux_nr_pages != nr_pages Then Go to aux_unlock |
5866 | If rb_has_aux(rb) Then |
5872 | atomic_set( & aux_mmap_count, 1) |
5873 | user_extra = nr_pages |
5875 | Go to accounting |
5888 | WARN_ON_ONCE(parent_ctx) |
5889 | again : |
5890 | mutex_lock( & mmap_mutex) |
5891 | If rb Then |
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 | If user_locked > user_lock_limit Then user_locked = user_lock_limit |
5928 | user_locked += user_extra |
5930 | If user_locked > user_lock_limit Then |
5935 | extra = user_locked - user_lock_limit |
5936 | user_extra -= extra |
5939 | lock_limit = rlimit(RLIMIT_MEMLOCK) |
5941 | locked = atomic64_read( & pinned_vm) + extra |
5943 | If locked > lock_limit && perf_is_paranoid() && Not Check operation authority Then |
5951 | If Flags, see mm.h. & VM_WRITE Then flags |= Buffer handling |
5954 | If Not rb Then |
5959 | If Not rb Then |
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) |
5972 | Else |
5973 | ret = rb_alloc_aux(rb, event, Offset (within vm_file) in PAGE_SIZEunits , nr_pages, aux_watermark, flags) |
5975 | If Not ret Then aux_mmap_locked = extra |
5979 | unlock : |
5980 | If Not ret Then |
5981 | atomic_long_add(user_extra, & locked_vm) |
5982 | atomic64_add(extra, & pinned_vm) |
5984 | atomic_inc( & mmap_count) |
5985 | Else if rb Then |
5986 | atomic_dec( & mmap_count) |
5988 | aux_unlock : |
5995 | Flags, see mm.h. |= Do not copy this vma on fork | Cannot expand with mremap() | Do not include in the core dump |
5998 | If event_mapped Then event_mapped(event, The address space we belong to. ) |
6001 | Return ret |
Source code conversion tool public plug-in interface | X |
---|---|
Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |