Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:__get_user_pages() - pin user pages in memory*@tsk: task_struct of target task*@mm: mm_struct of target mm*@start: starting user address*@nr_pages: number of pages from start to pin*@gup_flags: flags modifying pin behaviour

Proto:static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages, struct vm_area_struct **vmas, int *nonblocking)

Type:long

Parameter:

TypeParameterName
struct task_struct *tsk
struct mm_struct *mm
unsigned longstart
unsigned longnr_pages
unsigned intgup_flags
struct page **pages
struct vm_area_struct **vmas
int *nonblocking
790  ret = 0 , i = 0
791  struct vm_area_struct * vma = NULL
792  struct follow_page_context ctx = {NULL}
794  If Not nr_pages Then Return 0
797  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)
799  VM_BUG_ON(!!pages != !!(gup_flags & do get_page on page ))
806  If Not (gup_flags & get_user_pages read/write w/o permission ) Then gup_flags |= rce NUMA hinting page fault
809  Do
811  foll_flags = gup_flags
817  If Not vma && in_gate_area(mm, start) Then
818  ret = get_gate_page(mm, start & PAGE_MASK, gup_flags, & vma, pages ? & pages[i] : NULL)
821  If ret Then Go to out
823  page_mask = 0
824  Go to next_page
827  If Not vma || check_vma_flags(vma, gup_flags) Then
828  ret = -EFAULT
829  Go to out
831  If is_vm_hugetlb_page(vma) Then
835  Continue
838  retry :
845  Go to out
847  cond_resched()
849  page = llow_page_mask - look up a page descriptor from a user-virtual address*@vma: vm_area_struct mapping @address*@address: virtual address to look up*@flags: flags modifying lookup behaviour*@ctx: contains dev_pagemap for %ZONE_DEVICE memory pinning and a*
850  If Not page Then
854  Case ret == 0
855  Go to retry
856  Case ret == -EBUSY
857  ret = 0
859  Case ret == -EFAULT
860  Case ret == -ENOMEM
861  Case ret == -EHWPOISON
862  Go to out
863  Case ret == -ENOENT
864  Go to next_page
866  BUG()
867  Else if PTR_ERR(page) == -EEXIST Then
872  Go to next_page
873  Else if IS_ERR(page) Then
874  ret = PTR_ERR(page)
875  Go to out
877  If pages Then
878  pages[i] = page
881  page_mask = 0
883  next_page :
884  If vmas Then
885  vmas[i] = vma
886  page_mask = 0
888  page_increm = 1 + ( ~(start >> PAGE_SHIFT determines the page size ) & page_mask)
889  If page_increm > nr_pages Then page_increm = nr_pages
891  i += page_increm
892  start += page_increm * PAGE_SIZE
893  nr_pages -= page_increm
894  When nr_pages cycle
895  out :
896  If pgmap Then put_dev_pagemap(pgmap)
898  Return If i Then i Else ret
Caller
NameDescribe
__get_user_pages_locked
populate_vma_page_rangepopulate_vma_page_range() - populate a range of pages in the vma