Visit Our UNIX and Linux User Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #683
Difficulty: Medium
According to both NetMarketShare and WikiMedia, Safari has a desktop market share of over 6% in 2019.
True or False?
Linux & Unix Commands - Search Man Pages

__get_user_pages(9) [centos man page]

__GET_USER_PAGES(9)					    Memory Management in Linux					       __GET_USER_PAGES(9)

NAME
__get_user_pages - pin user pages in memory SYNOPSIS
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); 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 gup_flags flags modifying pin behaviour 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. nonblocking whether waiting for disk IO or mmap_sem contention 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 gup_flags & FOLL_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. If nonblocking != NULL, __get_user_pages will not wait for disk IO or mmap_sem contention, and if waiting is needed to pin all pages, *nonblocking will be set to 0. In most cases, get_user_pages or get_user_pages_fast should be used instead of __get_user_pages. __get_user_pages should be used only if you need some special gup_flags. COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 __GET_USER_PAGES(9)

Check Out this Related Man Page

SF_BUF(9)						   BSD Kernel Developer's Manual						 SF_BUF(9)

NAME
sf_buf -- manage temporary kernel address space mapping for memory pages SYNOPSIS
#include <sys/sf_buf.h> struct sf_buf * sf_buf_alloc(struct vm_page *m, int flags); void sf_buf_free(struct sf_buf *sf); vm_offset_t sf_buf_kva(struct sf_buf *sf); struct vm_page * sf_buf_page(struct sf_buf *sf); DESCRIPTION
The sf_buf interface, historically the sendfile(2) buffer interface, allows kernel subsystems to manage temporary kernel address space map- pings for physical memory pages. On systems with a direct memory map region (allowing all physical pages to be visible in the kernel address space at all times), the struct sf_buf will point to an address in the direct map region; on systems without a direct memory map region, the struct sf_buf will manage a temporary kernel address space mapping valid for the lifetime of the struct sf_buf. Call sf_buf_alloc() to allocate a struct sf_buf for a physical memory page. sf_buf_alloc() is not responsible for arranging for the page to be present in physical memory; the caller should already have arranged for the page to be wired, i.e., by calling vm_page_wire(9). Several flags may be passed to sf_buf_alloc(): SFB_CATCH Cause sf_buf_alloc() to abort and return NULL if a signal is received waiting for a struct sf_buf to become available. SFB_NOWAIT Cause sf_buf_alloc() to return NULL rather than sleeping if a struct sf_buf is not immediately available. SFB_CPUPRIVATE Cause sf_buf_alloc() to only arrange that the temporary mapping be valid on the current CPU, avoiding unnecessary TLB shoot- downs for mappings that will only be accessed on a single CPU at a time. The caller must ensure that accesses to the virtual address occur only on the CPU from which sf_buf_alloc() was invoked, perhaps by using sched_pin(). Call sf_buf_kva() to return a kernel mapped address for the page. Call sf_buf_page() to return a pointer to the page originally passed into sf_buf_alloc(). Call sf_buf_free() to release the struct sf_buf reference. The caller is responsible for releasing any wiring they have previously acquired on the physical page; sf_buf_free() releases only the temporary kernel address space mapping, not the page itself. Uses of this interface include managing mappings of borrowed pages from user memory, such as in zero-copy socket I/O, or pages of memory from the buffer cache referenced by mbuf external storage for sendfile(2). SEE ALSO
sendfile(2), vm_page_wire(9) AUTHORS
The struct sf_buf API was designed and implemented by Alan L. Cox. This manual page was written by Robert N. M. Watson. BSD
January 28, 2007 BSD

Featured Tech Videos