Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:The madvise(2) system call

Proto:SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)

Type:

Parameter:Nothing

1051  unmapped_error = 0
1052  error = -EINVAL
1057  start = Architectures that support memory tagging (assigning tags to memory regions,* embedding these tags into addresses that point to these memory regions, and* checking that the memory and the pointer tags match on memory accesses)(start)
1059  If Not madvise_behavior_valid(behavior) Then Return error
1062  If Not st whether an address (unsigned long or pointer) is aligned to PAGE_SIZE (start) Then Return error
1064  len = align the pointer to the (next) page boundary (len_in)
1067  If len_in && Not len Then Return error
1070  end = start + len
1071  If end < start Then Return error
1074  error = 0
1075  If end == start Then Return error
1079  If (behavior == poison a page for testing || behavior == soft offline page for testing ) Then Return Error injection support for memory error handling.
1083  write = Any behaviour which results in changes to the vma->vm_flags needs to* take mmap_sem for writing. Others, which simply traverse vmas, need* to only take it for reading.
1084  If write Then
1085  If lock for writing Then Return -EINTR
1087  Else
1088  lock for reading
1096  vma = Same as find_vma, but also return a pointer to the previous VMA in *pprev.
1097  If vma && start > Our start address within vm_mm. Then prev = vma
1100  blk_start_plug( & plug)
1101  cycle
1103  error = -ENOMEM
1104  If Not vma Then Go to out
1111  If start >= end Then Go to out
1116  tmp = The first byte after our end addresswithin vm_mm.
1117  If end < tmp Then tmp = end
1121  error = madvise_vma(vma, & prev, start, tmp, behavior)
1122  If error Then Go to out
1124  start = tmp
1125  If prev && start < The first byte after our end addresswithin vm_mm. Then start = The first byte after our end addresswithin vm_mm.
1127  error = unmapped_error
1128  If start >= end Then Go to out
1130  If prev Then vma = linked list of VM areas per task, sorted by address
1132  Else vma = Look up the first VMA which satisfies addr < vm_end, NULL if none.
1135  out :
1136  blk_finish_plug( & plug)
1137  If write Then lease a write lock
1139  Else lease a read lock
1142  Return error