logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

PAGEMAP_SCAN - get and/or clear page flags

Description

This ioctl(2) is used to get and optionally clear some specific flags from page table entries. The information is returned with PAGE_SIZE granularity. To start tracking the written state (flag) of a page or range of memory, the UFFD_FEATURE_WP_ASYNC must be enabled by UFFDIO_APIioctl(2) on userfaultfd and memory range must be registered with UFFDIO_REGISTERioctl(2) in UFFDIO_REGISTER_MODE_WP mode. Supportedpageflags 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. Supportedoperations 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. Thestructpm_scan_argargumentsize This field should be set to the size of the structure in bytes, as in sizeof(structpm_scan_arg). flags The operations to be performed are specified in it. start The starting address of the scan is specified in it. end The ending address of the scan is specified in it. walk_end The kernel returns the scan's ending address in it. The walk_end equal to end means that scan has completed on the entire range. vec The address of page_region array for output. vec_len The length of the page_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 any PAGE_IS_* category doesn't match. category_anyof_mask Skip pages for which no PAGE_IS_* category matches. return_maskPAGE_IS_* categories that are to be reported in page_region.

Errors

Error codes can be one of, but are not limited to, the following: EINVAL Invalid arguments i.e., invalid size of the argument, invalid flags, invalid categories, the start address isn't aligned with PAGE_SIZE, or vec_len is specified when vec is NULL. EFAULT Invalid arg pointer, invalid vec pointer, or invalid address range specified by start and end. ENOMEM No memory is available. EINTR Fetal signal is pending.

History

Linux 6.7.

Library

Standard C library (libc, -lc)

Name

PAGEMAP_SCAN - get and/or clear page flags

Return Value

On error, -1 is returned, and errno is set to indicate the error.

See Also

ioctl(2) Linux man-pages 6.9.1 2024-06-17 PAGEMAP_SCAN(2const)

Standards

Linux.

Synopsis

#include<linux/fs.h> /* Definition of PAGE* and PM_* constants */ #include<sys/ioctl.h>intioctl(intpagemap_fd,PAGEMAP_SCAN,structpm_scan_arg*arg);#include<linux/fs.h>structpm_scan_arg{__u64size;__u64flags;__u64start;__u64end;__u64walk_end;__u64vec;__u64vec_len;__u64max_pages;__u64category_inverted;__u64category_mask;__u64category_anyof_mask;__u64return_mask;};structpage_region{__u64start;__u64end;__u64categories;};

See Also