Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\mmap.c Create Date:2022-07-28 14:48:44
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:mmap_region

Proto: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)

Type:unsigned long

Parameter:

TypeParameterName
struct file *file
unsigned longaddr
unsigned longlen
vm_flags_tvm_flags
unsigned longpgoff
struct list_head *uf
1693  mm = mm
1697  charged = 0
1700  If Not Return true if the calling process may expand its vm space by the passed* number of pages Then
1707  nr_pages = count_vma_pages_range(mm, addr, addr + len)
1709  If Not Return true if the calling process may expand its vm space by the passed* number of pages Then Return -ENOMEM
1715  When find_vma_links(mm, addr, addr + len, & prev, & rb_link, & rb_parent) cycle
1717  If do_munmap(mm, addr, len, uf) Then Return -ENOMEM
1724  If We account for memory if it's a private writeable mapping,* not hugepages and VM_NORESERVE wasn't set. Then
1725  charged = len >> PAGE_SHIFT determines the page size
1726  If security_vm_enough_memory_mm(mm, charged) Then Return -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  If vma Then Go to out
1744  vma = vm_area_alloc(mm)
1745  If Not vma Then
1746  error = -ENOMEM
1747  Go to unacct_error
1750  Our start address within vm_mm. = addr
1751  The first byte after our end addresswithin vm_mm. = addr + len
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  If file Then
1759  If error Then Go to free_vma
1762  If vm_flags & VM_SHARED Then
1764  If error Then Go to allow_write_and_free_vma
1773  File we map to (can be NULL). = get_file(file)
1774  error = call_mmap(file, vma)
1775  If error Then Go to 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  Else if vm_flags & VM_SHARED Then
1790  error = shmem_zero_setup - setup a shared anonymous mapping*@vma: the vma to be mmapped is prepared by do_mmap_pgoff
1791  If error Then Go to free_vma
1793  Else
1794  vma_set_anonymous(vma)
1797  vma_link(mm, vma, prev, rb_link, rb_parent)
1799  If file Then
1800  If vm_flags & VM_SHARED Then mapping_unmap_writable(f_mapping)
1802  If vm_flags & ETXTBSY on write attempts.. Then 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  If vm_flags & VM_LOCKED Then
1811  If 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) Then Flags, see mm.h. &= This mask is used to clear all the VMA flags used by mlock
1815  Else Pages that have PG_mlocked set += len >> PAGE_SHIFT determines the page size
1819  If file Then Called 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  Return 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  If vm_flags & VM_SHARED Then mapping_unmap_writable(f_mapping)
1844  allow_write_and_free_vma :
1845  If vm_flags & ETXTBSY on write attempts.. Then allow_write_access(file)
1847  free_vma :
1848  vm_area_free(vma)
1849  unacct_error :
1850  If charged Then vm_unacct_memory(charged)
1852  Return error
Caller
NameDescribe
do_mmapThe caller must hold down_write(¤t->mm->mmap_sem).