NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |ERRORS |STANDARDS |HISTORY |SEE ALSO |COLOPHON | |
PAGEMAP_SCAN(2const)PAGEMAP_SCAN(2const)PAGEMAP_SCAN - get and/or clear page flags
Standard C library (libc,-lc)
#include <linux/fs.h>/* Definition ofPAGE*andPM_*constants */#include <sys/ioctl.h>int ioctl(intpagemap_fd, PAGEMAP_SCAN, struct pm_scan_arg *arg);#include <linux/fs.h>struct pm_scan_arg {__u64 size;__u64 flags;__u64 start;__u64 end;__u64 walk_end;__u64 vec;__u64 vec_len;__u64 max_pages;__u64 category_inverted;__u64 category_mask;__u64 category_anyof_mask;__u64 return_mask;};struct page_region {__u64 start;__u64 end;__u64 categories;};Thisioctl(2) is used to get and optionally clear some specific flags from page table entries. The information is returned withPAGE_SIZEgranularity. To start tracking the written state (flag) of a page or range of memory, theUFFD_FEATURE_WP_ASYNCmust be enabled byUFFDIO_APIioctl(2) onuserfaultfdand memory range must be registered withUFFDIO_REGISTER ioctl(2) inUFFDIO_REGISTER_MODE_WPmode.Supported page flags The following page table entry flags are supported:PAGE_IS_WPALLOWED The page has asynchronous write-protection enabled.PAGE_IS_WRITTEN The page has been written to from the time it was write protected.PAGE_IS_FILE The page is file backed.PAGE_IS_PRESENT The page is present in the memory.PAGE_IS_SWAPPED The page is swapped.PAGE_IS_PFNZERO The page has zero PFN.PAGE_IS_HUGE The page is THP or Hugetlb backed.Supported operations The get operation is always performed if the output buffer is specified. The other operations are as following:PM_SCAN_WP_MATCHING Write protect the matched pages.PM_SCAN_CHECK_WPASYNC Abort the scan when a page is found which doesn't have the Userfaultfd Asynchronous Write protection enabled.Thestruct pm_scan_arg argumentsizeThis field should be set to the size of the structure in bytes, as insizeof(struct pm_scan_arg).flagsThe operations to be performed are specified in it.startThe starting address of the scan is specified in it.endThe ending address of the scan is specified in it.walk_end The kernel returns the scan's ending address in it. Thewalk_end equal toend means that scan has completed on the entire range.vecThe address ofpage_region array for output.vec_len The length of thepage_region struct array.max_pages It is the optional limit for the number of output pages required.category_invertedPAGE_IS_* categories which values match if 0 instead of 1.category_mask Skip pages for which anyPAGE_IS_* category doesn't match.category_anyof_mask Skip pages for which noPAGE_IS_* category matches.return_maskPAGE_IS_* categories that are to be reported inpage_region.
On error, -1 is returned, anderrno is set to indicate the error.
Error codes can be one of, but are not limited to, the following:EINVALInvalid arguments i.e., invalidsize of the argument, invalidflags, invalidcategories, thestart address isn't aligned withPAGE_SIZE, orvec_len is specified whenvec is NULL.EFAULTInvalidarg pointer, invalidvec pointer, or invalid address range specified bystart andend.ENOMEMNo memory is available.EINTRFetal signal is pending.
Linux.
Linux 6.7.
ioctl(2)
This page is part of theman-pages (Linux kernel and C library user-space interface documentation) project. Information about the project can be found at ⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report for this manual page, see ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩. This page was obtained from the tarball man-pages-6.15.tar.gz fetched from ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on 2025-08-11. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up- to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgLinux man-pages 6.15 2025-05-17PAGEMAP_SCAN(2const)Pages that refer to this page:ioctl_fs(2)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |