函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\mmap.c Create Date:2022-07-27 16:16:52
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:mmap_region

函数原型:unsigned long mmap_region(struct file *file, unsigned long addr, unsigned long len, vm_flags_t vm_flags, unsigned long pgoff, struct list_head *uf)

返回类型:unsigned long

参数:

类型参数名称
struct file *file
unsigned longaddr
unsigned longlen
vm_flags_tvm_flags
unsigned longpgoff
struct list_head *uf
1693  mm等于mm
1697  charged等于0
1700  如果非Return true if the calling process may expand its vm space by the passed* number of pages
1707  nr_pages等于count_vma_pages_range(mm, addr, addr + len)
1709  如果非Return true if the calling process may expand its vm space by the passed* number of pages则返回:负ENOMEM
1715 find_vma_links(mm, addr, addr + len, & prev, & rb_link, & rb_parent)循环
1717  如果do_munmap(mm, addr, len, uf)则返回:负ENOMEM
1724  如果We account for memory if it's a private writeable mapping,* not hugepages and VM_NORESERVE wasn't set.
1725  charged等于len右移PAGE_SHIFT determines the page size
1726  如果security_vm_enough_memory_mm(mm, charged)则返回:负ENOMEM
1728  vm_flags或等于Is a VM accounted object
1734  vma等于Given a mapping request (addr,end,vm_flags,file,pgoff), figure out* whether that can be merged with its predecessor or its successor
1736  如果vma则转到:out
1744  vma等于vm_area_alloc(mm)
1745  如果非vma
1746  error等于负ENOMEM
1747  转到:unacct_error
1750  Our start address within vm_mm. 等于addr
1751  The first byte after our end addresswithin vm_mm. 等于addrlen
1752  Flags, see mm.h. 等于vm_flags
1753  Access permissions of this VMA. 等于vm_get_page_prot(vm_flags)
1754  Offset (within vm_file) in PAGE_SIZEunits 等于pgoff
1756  如果file
1757  如果vm_flags按位与ETXTBSY on write attempts..
1759  如果error则转到:free_vma
1762  如果vm_flags按位与VM_SHARED
1764  如果error则转到:allow_write_and_free_vma
1773  File we map to (can be NULL). 等于get_file(file)
1774  error等于call_mmap(file, vma)
1775  如果error则转到:unmap_and_free_vma
1785  WARN_ON_ONCE(addr != Our start address within vm_mm. )
1787  addr等于Our start address within vm_mm.
1788  vm_flags等于Flags, see mm.h.
1789  否则如果vm_flags按位与VM_SHARED
1790  error等于shmem_zero_setup - setup a shared anonymous mapping*@vma: the vma to be mmapped is prepared by do_mmap_pgoff
1791  如果error则转到:free_vma
1793  否则
1794  vma_set_anonymous(vma)
1797  vma_link(mm, vma, prev, rb_link, rb_parent)
1799  如果file
1800  如果vm_flags按位与VM_SHAREDmapping_unmap_writable(f_mapping)
1802  如果vm_flags按位与ETXTBSY on write attempts.. allow_write_access(file)
1805  file等于File we map to (can be NULL).
1806  out :
1807  perf_event_mmap(vma)
1809  vm_stat_account(mm, vm_flags, len >> PAGE_SHIFT determines the page size )
1810  如果vm_flags按位与VM_LOCKED
1811  如果vm_flags按位与Special vmas that are non-mergable, non-mlock()able.* Note: mm/huge_memory.c VM_NO_THP depends on this definition.vma_is_dax(vma)或is_vm_hugetlb_page(vma)或vma恒等于get_gate_vma(mm)则Flags, see mm.h. 与等于This mask is used to clear all the VMA flags used by mlock
1815  否则 Pages that have PG_mlocked set 加等于len右移PAGE_SHIFT determines the page size
1819  如果fileCalled from mmap_region/vma_adjust with mm->mmap_sem acquired.* Currently we ignore all errors and always return 0, the callers* can't handle the failure anyway.
1829  Flags, see mm.h. 或等于VM_SOFTDIRTY
1831  Update vma->vm_page_prot to reflect vma->vm_flags.
1833  返回:addr
1835  unmap_and_free_vma :
1836  File we map to (can be NULL). = NULL
1837  fput(file)
1840  unmap_region(mm, vma, prev, Our start address within vm_mm. , The first byte after our end addresswithin vm_mm. )
1841  charged等于0
1842  如果vm_flags按位与VM_SHAREDmapping_unmap_writable(f_mapping)
1844  allow_write_and_free_vma :
1845  如果vm_flags按位与ETXTBSY on write attempts.. allow_write_access(file)
1847  free_vma :
1848  vm_area_free(vma)
1849  unacct_error :
1850  如果chargedvm_unacct_memory(charged)
1852  返回:error
调用者
名称描述
do_mmapThe caller must hold down_write(¤t->mm->mmap_sem).