xref: /freebsd/share/man/man9/vm_page_bits.9 (revision ca987d4641cdcd7f27e153db17c5bf064934faf5)
1.\"
2.\" Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice(s), this list of conditions and the following disclaimer as
9.\"    the first lines of this file unmodified other than the possible
10.\"    addition of one or more copyright notices.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice(s), this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
16.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
19.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25.\" DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
29.Dd December 1, 2001
30.Dt VM_PAGE_BITS 9
31.Os
32.Sh NAME
33.Nm vm_page_bits ,
34.Nm vm_page_set_validclean ,
35.Nm vm_page_clear_dirty ,
36.Nm vm_page_set_invalid ,
37.Nm vm_page_zero_invalid ,
38.Nm vm_page_is_valid ,
39.Nm vm_page_test_dirty ,
40.Nm vm_page_dirty ,
41.Nm vm_page_undirty
42.Nd "manage page clean and dirty bits"
43.Sh SYNOPSIS
44.In sys/param.h
45.In vm/vm.h
46.In vm/vm_page.h
47.Ft int
48.Fn vm_page_bits "int base" "int size"
49.Ft void
50.Fn vm_page_set_validclean "vm_page_t m" "int base" "int size"
51.Ft void
52.Fn vm_page_clear_dirty "vm_page_t m" "int base" "int size"
53.Ft void
54.Fn vm_page_set_invalid "vm_page_t m" "int base" "int size"
55.Ft void
56.Fn vm_page_zero_invalid "vm_page_t m" "boolean_t setvalid"
57.Ft int
58.Fn vm_page_is_valid "vm_page_t m" "int base" "int size"
59.Ft void
60.Fn vm_page_test_dirty "vm_page_t m"
61.Ft void
62.Fn vm_page_dirty "vm_page_t m"
63.Ft void
64.Fn vm_page_undirty "vm_page_t m"
65.Sh DESCRIPTION
66.Fn vm_page_bits
67calculates the bits representing the
68.Dv DEV_BSIZE
69range of bytes between
70.Fa base
71and
72.Fa size .
73The byte range is expected to be within a single page, and if
74.Fa size
75is zero, no bits will be set.
76.Pp
77.Fn vm_page_set_validclean
78flags the byte range between
79.Fa base
80and
81.Fa size
82as valid and clean.
83The range is expected to be
84.Dv DEV_BSIZE
85aligned and no larger than
86.Dv PAGE_SIZE .
87If it is not properly aligned, any unaligned chunks of the
88.Dv DEV_BSIZE
89blocks at the beginning and end of the range will be zeroed.
90.Pp
91If
92.Fa base
93is zero and
94.Fa size
95is one page, the modified bit in the page map is cleared; as well,
96the
97.Dv VPO_NOSYNC
98flag is cleared.
99.Pp
100.Fn vm_page_clear_dirty
101clears the dirty bits within a page in the range between
102.Fa base
103and
104.Fa size .
105The bits representing the range are calculated by calling
106.Fn vm_page_bits .
107.Pp
108.Fn vm_page_set_invalid
109clears the bits in both the valid and dirty flags representing
110the
111.Dv DEV_BSIZE
112blocks between
113.Fa base
114and
115.Fa size
116in the page.
117The bits are calculated by calling
118.Fn vm_page_bits .
119As well as clearing the bits within the page, the generation
120number within the object holding the page is incremented.
121.Pp
122.Fn vm_page_zero_invalid
123zeroes all of the blocks within the page that are currently
124flagged as invalid.
125If
126.Fa setvalid
127is
128.Dv TRUE ,
129all of the valid bits within the page are set.
130.Pp
131In some cases, such as NFS, the valid bits cannot be set
132in order to maintain cache consistency.
133.Pp
134.Fn vm_page_is_valid
135checks to determine if the all of the
136.Dv DEV_BSIZE
137blocks between
138.Fa base
139and
140.Fa size
141of the page are valid.
142If
143.Fa size
144is zero and the page is entirely invalid
145.Fn vm_page_is_valid
146will return
147.Dv TRUE ,
148in all other cases a size of zero will return
149.Dv FALSE .
150.Pp
151.Fn vm_page_test_dirty
152checks if a page has been modified via any of its physical maps,
153and if so, flags the entire page as dirty.
154.Fn vm_page_dirty
155is called to modify the dirty bits.
156.Pp
157.Fn vm_page_dirty
158flags the entire page as dirty.
159It is expected that the page is not currently on the cache queue.
160.Pp
161.Fn vm_page_undirty
162clears all of the dirty bits in a page.
163.Sh NOTES
164None of these functions are allowed to block.
165.Sh AUTHORS
166This manual page was written by
167.An Chad David Aq Mt davidc@acns.ab.ca .
168