Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\nommu.c Create Date:2022-07-28 14:37:16
Last Modify:2020-03-17 21:26:27 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:set up a private mapping or an anonymous shared mapping

Proto:static int do_mmap_private(struct vm_area_struct *vma, struct vm_region *region, unsigned long len, unsigned long capabilities)

Type:int

Parameter:

TypeParameterName
struct vm_area_struct *vma
struct vm_region *region
unsigned longlen
unsigned longcapabilities
1018  If capabilities & Can be mapped directly (MAP_SHARED) Then
1019  ret = call_mmap(File we map to (can be NULL). , vma)
1020  If ret == 0 Then
1023  vm_top = vm_end
1024  Return 0
1026  If ret != -ENOSYS Then Return ret
1039  order = get_order - Determine the allocation order of a memory size*@size: The size for which to get the order* Determine the allocation order of a particular sized block of memory
1040  total = 1 << order
1041  point = len >> PAGE_SHIFT determines the page size
1044  If sysctl_nr_trim_pages && total - point >= sysctl_nr_trim_pages Then total = point
1047  base = alloc_pages_exact(total << PAGE_SHIFT determines the page size , GFP_KERNEL)
1048  If Not base Then Go to enomem
1051  atomic_long_add(total, & mmap_pages_allocated)
1053  VMA vm_flags = Flags, see mm.h. |= VM_MAPPED_COPY
1054  start address of region = base
1055  gion initialised to here = start address of region + len
1056  gion allocated to here = start address of region + (total << PAGE_SHIFT determines the page size )
1058  Our start address within vm_mm. = start address of region
1059  The first byte after our end addresswithin vm_mm. = start address of region + len
1061  If File we map to (can be NULL). Then
1065  fpos = Offset (within vm_file) in PAGE_SIZEunits
1066  fpos <<= PAGE_SHIFT determines the page size
1068  ret = kernel_read(File we map to (can be NULL). , base, len, & fpos)
1069  If ret < 0 Then Go to error_free
1073  If ret < len Then memset(base + ret, 0, len - ret)
1076  Else
1077  vma_set_anonymous(vma)
1080  Return 0
1082  error_free :
1083  a contiguous series of pages
1084  start address of region = Our start address within vm_mm. = 0
1085  gion initialised to here = The first byte after our end addresswithin vm_mm. = 0
1086  gion allocated to here = 0
1087  Return ret
1089  enomem :
1090  pr_err("Allocation of length %lu from process %d (%s) failed\n", len, pid, comm)
1092  Show free area list (used inside shift_scroll-lock stuff)* We also calculate the percentage fragmentation
1093  Return -ENOMEM
Caller
NameDescribe
do_mmaphandle mapping creation for uClinux