Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

vm_insert_page(9) [centos man page]

VM_INSERT_PAGE(9)					    Memory Management in Linux						 VM_INSERT_PAGE(9)

vm_insert_page - insert single page into user vma SYNOPSIS
int vm_insert_page(struct vm_area_struct * vma, unsigned long addr, struct page * page); ARGUMENTS
vma user vma to map to addr target user address of this page page source kernel page DESCRIPTION
This allows drivers to insert individual pages they've allocated into a user vma. The page has to be a nice clean _individual_ kernel allocation. If you allocate a compound page, you need to have marked it as such (__GFP_COMP), or manually just split the page up yourself (see split_page). NOTE! Traditionally this was done with "remap_pfn_range" which took an arbitrary page protection parameter. This doesn't allow that. Your vma protection will have to be set up correctly, which means that if you want a shared writable mapping, you'd better ask for a shared writable mapping! The page does not need to be reserved. Usually this function is called from f_op->mmap handler under mm->mmap_sem write-lock, so it can change vma->vm_flags. Caller must set VM_MIXEDMAP on vma if it wants to call this function from other places, for example from page-fault handler. COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 VM_INSERT_PAGE(9)

Check Out this Related Man Page

GET_USER_PAGES(9)					    Memory Management in Linux						 GET_USER_PAGES(9)

get_user_pages - pin user pages in memory SYNOPSIS
int get_user_pages(struct task_struct * tsk, struct mm_struct * mm, unsigned long start, int nr_pages, int write, int force, struct page ** pages, struct vm_area_struct ** vmas); ARGUMENTS
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 write whether pages will be written to by the caller force whether to force write access even if user mapping is readonly. This will result in the page being COWed even in MAP_SHARED mappings. You do not want this. pages array that receives pointers to the pages pinned. Should be at least nr_pages long. Or NULL, if caller only intends to ensure the pages are faulted in. vmas array of pointers to vmas corresponding to each page. Or NULL if the caller does not require them. DESCRIPTION
Returns number of pages pinned. This may be fewer than the number requested. If nr_pages is 0 or negative, returns 0. If no pages were pinned, returns -errno. Each page returned must be released with a put_page call when it is finished with. vmas will only remain valid while mmap_sem is held. Must be called with mmap_sem held for read or write. get_user_pages walks a process's page tables and takes a reference to each struct page that each user address corresponds to at a given instant. That is, it takes the page that would be accessed if a user thread accesses the given user virtual address at that instant. This does not guarantee that the page exists in the user mappings when get_user_pages returns, and there may even be a completely different page there in some cases (eg. if mmapped pagecache has been invalidated and subsequently re faulted). However it does guarantee that the page won't be freed completely. And mostly callers simply care that the page contains data that was valid *at some point in time*. Typically, an IO or similar operation cannot guarantee anything stronger anyway because locks can't be held over the syscall boundary. If write=0, the page must not be written to. If the page is written to, set_page_dirty (or set_page_dirty_lock, as appropriate) must be called after the page is finished with, and before put_page is called. get_user_pages is typically used for fewer-copy IO operations, to get a handle on the memory by some means other than accesses via the user virtual addresses. The pages may be submitted for DMA to devices or accessed via their kernel linear mapping (via the kmap APIs). Care should be taken to use the correct cache flushing APIs. See also get_user_pages_fast, for performance critical applications. COPYRIGHT
Kernel Hackers Manual 2.6. July 2010 GET_USER_PAGES(9)
Man Page