]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/ioctl_pagemap_scan.2
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man2 / ioctl_pagemap_scan.2
CommitLineData
f470ae64
MUA
1.\" This manpage is Copyright (C) 2023 Collabora;
2.\" Written by Muhammad Usama Anjum <usama.anjum@collabora.com>
3.\"
4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
5.\"
6.TH ioctl_pagemap_scan 2 2023-10-17 "Linux man-pages (unreleased)"
7.SH NAME
8ioctl_pagemap_scan \- get and/or clear page flags
9.SH LIBRARY
10Standard C library
11.RI ( libc ", " \-lc )
12.SH SYNOPSIS
13.nf
14.BR "#include <linux/fs.h>" " /* Definition of " "struct pm_scan_arg" ,
15.BR " struct page_region" ", and " PAGE_IS_* " constants */"
16.B #include <sys/ioctl.h>
c6d039a3 17.P
f470ae64
MUA
18.BI "int ioctl(int " pagemap_fd ", PAGEMAP_SCAN, struct pm_scan_arg *" arg );
19.fi
20.SH DESCRIPTION
21This
22.BR ioctl (2)
23is used to get and optionally clear some specific flags from page table entries.
24The information is returned with
25.B PAGE_SIZE
26granularity.
c6d039a3 27.P
f470ae64
MUA
28To start tracking the written state (flag) of a page or range of memory,
29the
30.B UFFD_FEATURE_WP_ASYNC
31must be enabled by
32.B UFFDIO_API
33.BR ioctl (2)
34on
35.B userfaultfd
36and memory range must be registered with
37.B UFFDIO_REGISTER
38.BR ioctl (2)
39in
40.B UFFDIO_REGISTER_MODE_WP
41mode.
42.SS Supported page flags
43The following page table entry flags are supported:
44.TP
45.B PAGE_IS_WPALLOWED
46The page has asynchronous write-protection enabled.
47.TP
48.B PAGE_IS_WRITTEN
49The page has been written to from the time it was write protected.
50.TP
51.B PAGE_IS_FILE
52The page is file backed.
53.TP
54.B PAGE_IS_PRESENT
55The page is present in the memory.
56.TP
57.B PAGE_IS_SWAPPED
58The page is swapped.
59.TP
60.B PAGE_IS_PFNZERO
61The page has zero PFN.
62.TP
63.B PAGE_IS_HUGE
64The page is THP or Hugetlb backed.
65.SS Supported operations
66The get operation is always performed
67if the output buffer is specified.
68The other operations are as following:
69.TP
70.B PM_SCAN_WP_MATCHING
71Write protect the matched pages.
72.TP
73.B PM_SCAN_CHECK_WPASYNC
74Abort the scan
75when a page is found
76which doesn't have the Userfaultfd Asynchronous Write protection enabled.
77.SS The \f[I]struct pm_scan_arg\f[] argument
78.EX
79struct pm_scan_arg {
80 __u64 size;
81 __u64 flags;
82 __u64 start;
83 __u64 end;
84 __u64 walk_end;
85 __u64 vec;
86 __u64 vec_len;
87 __u64 max_pages
88 __u64 category_inverted;
89 __u64 category_mask;
90 __u64 category_anyof_mask
91 __u64 return_mask;
92};
93.EE
94.TP
95.B size
96This field should be set to the size of the structure in bytes,
97as in
98.IR sizeof(struct\~pm_scan_arg) .
99.TP
100.B flags
101The operations to be performed are specified in it.
102.TP
103.B start
104The starting address of the scan is specified in it.
105.TP
106.B end
107The ending address of the scan is specified in it.
108.TP
109.B walk_end
110The kernel returns the scan's ending address in it.
111The
112.I walk_end
113equal to
114.I end
115means that scan has completed on the entire range.
116.TP
117.B vec
118The address of
119.I page_region
120array for output.
121.IP
122.in +4n
123.EX
124struct page_region {
125 __u64 start;
126 __u64 end;
127 __u64 categories;
128};
129.EE
130.in
131.TP
132.B vec_len
133The length of the
134.I page_region
135struct array.
136.TP
137.B max_pages
138It is the optional limit for the number of output pages required.
139.TP
140.B category_inverted
141.BI PAGE_IS_ *
142categories which values match if 0 instead of 1.
143.TP
144.B category_mask
145Skip pages for which any
146.BI PAGE_IS_ *
147category doesn't match.
148.TP
149.B category_anyof_mask
150Skip pages for which no
151.BI PAGE_IS_ *
152category matches.
153.TP
154.B return_mask
155.BI PAGE_IS_ *
156categories that are to be reported in
157.IR page_region .
158.SH RETURN VALUE
159On error, \-1 is returned, and
160.I errno
161is set to indicate the error.
162.SH ERRORS
163Error codes can be one of, but are not limited to, the following:
164.TP
165.B EINVAL
166Invalid arguments i.e.,
167invalid
168.I size
169of the argument,
170invalid
171.IR flags ,
172invalid
173.IR categories ,
174the
175.I start
176address isn't aligned with
177.BR PAGE_SIZE ,
178or
179.I vec_len
180is specified when
181.I vec
182is NULL.
183.TP
184.B EFAULT
185Invalid
186.I arg
187pointer,
188invalid
189.I vec
190pointer,
191or invalid address range specified by
192.I start
193and
194.IR end .
195.TP
196.B ENOMEM
197No memory is available.
198.TP
199.B EINTR
200Fetal signal is pending.
201.SH STANDARDS
202Linux.
203.SH HISTORY
204Linux 6.7.
205.SH SEE ALSO
206.BR ioctl (2)