On 2/20/23 6:26 PM, Mike Rapoport wrote:
Hi,
On Thu, Feb 02, 2023 at 04:29:12PM +0500, Muhammad Usama Anjum wrote:
This IOCTL, PAGEMAP_SCAN on pagemap file can be used to get and/or clear the info about page table entries. The following operations are supported in this ioctl:
- Get the information if the pages have been written-to (PAGE_IS_WRITTEN), file mapped (PAGE_IS_FILE), present (PAGE_IS_PRESENT) or swapped (PAGE_IS_SWAPPED).
- Write-protect the pages (PAGEMAP_WP_ENGAGE) to start finding which pages have been written-to.
- Find pages which have been written-to and write protect the pages (atomic PAGE_IS_WRITTEN + PAGEMAP_WP_ENGAGE)
+/*
- struct pagemap_scan_arg - Pagemap ioctl argument
- @start: Starting address of the region
- @len: Length of the region (All the pages in this length are included)
- @vec: Address of page_region struct array for output
- @vec_len: Length of the page_region struct array
- @max_pages: Optional max return pages
- @flags: Flags for the IOCTL
- @required_mask: Required mask - All of these bits have to be set in the PTE
- @anyof_mask: Any mask - Any of these bits are set in the PTE
- @excluded_mask: Exclude mask - None of these bits are set in the PTE
- @return_mask: Bits that are to be reported in page_region
- */
+struct pagemap_scan_arg {
- __u64 start;
- __u64 len;
- __u64 vec;
- __u64 vec_len;
- __u32 max_pages;
- __u32 flags;
- __u64 required_mask;
- __u64 anyof_mask;
- __u64 excluded_mask;
- __u64 return_mask;
+};
After Nadav's comment I've realized I missed the API part :)
A few quick notes for now:
- The arg struct is fixed, so it would be impossible to extend the API
later. Following the clone3() example, I'd add 'size' field to the pagemam_scan_arg so that it would be possible to add new fields afterwards.
- Please make flags __u64, just in case
- Put size and flags at the beginning of the struct, e.g.
strucr pagemap_scan_arg { size_t size; __u64 flags; /* all the rest */ };
Updated. Thank you so much!
+/* Special flags */ +#define PAGEMAP_WP_ENGAGE (1 << 0)
#endif /* _UAPI_LINUX_FS_H */
2.30.2