]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/cpuset_getdomain.2
libc: Fix most issues reported by mandoc
[FreeBSD/FreeBSD.git] / lib / libc / sys / cpuset_getdomain.2
1 .\" Copyright (c) 2018 Jeffrey Roberson
2 .\" 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, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd June 18, 2020
28 .Dt CPUSET_GETDOMAIN 2
29 .Os
30 .Sh NAME
31 .Nm cpuset_getdomain ,
32 .Nm cpuset_setdomain
33 .Nd manage memory domain policy
34 .Sh LIBRARY
35 .Lb libc
36 .Sh SYNOPSIS
37 .In sys/param.h
38 .In sys/domainset.h
39 .Ft int
40 .Fn cpuset_getdomain "cpulevel_t level" "cpuwhich_t which" "id_t id" "size_t setsize" "domainset_t *mask" "int *policy"
41 .Ft int
42 .Fn cpuset_setdomain "cpulevel_t level" "cpuwhich_t which" "id_t id" "size_t setsize" "const domainset_t *mask" "int policy"
43 .Sh DESCRIPTION
44 .Fn cpuset_getdomain
45 and
46 .Fn cpuset_setdomain
47 allow the manipulation of sets of memory domains and allocation policy available
48 to processes, threads, jails and other resources.
49 These functions may manipulate sets of memory domains that contain many processes
50 or per-object anonymous masks that affect only a single object.
51 .Pp
52 The valid values for the
53 .Fa level
54 and
55 .Fa which
56 arguments are documented in
57 .Xr cpuset 2 .
58 These arguments specify which object and which set of the object we are
59 referring to.
60 Not all possible combinations are valid.
61 For example, only processes may belong to a numbered set accessed by a
62 .Fa level
63 argument of
64 .Dv CPU_LEVEL_CPUSET .
65 All resources, however, have a mask which may be manipulated with
66 .Dv CPU_LEVEL_WHICH .
67 .Pp
68 Masks of type
69 .Ft domainset_t
70 are composed using the
71 .Dv DOMAINSET
72 macros.
73 The kernel tolerates large sets as long as all domains specified
74 in the set exist.
75 Sets smaller than the kernel uses generate an error on calls to
76 .Fn cpuset_getdomain
77 even if the result set would fit within the user supplied set.
78 Calls to
79 .Fn cpuset_setdomain
80 tolerate small sets with no restrictions.
81 .Pp
82 The supplied mask should have a size of
83 .Fa setsize
84 bytes.
85 This size is usually provided by calling
86 .Li sizeof(mask)
87 which is ultimately determined by the value of
88 .Dv DOMAINSET_SETSIZE
89 as defined in
90 .In sys/domainset.h .
91 .Pp
92 .Fn cpuset_getdomain
93 retrieves the
94 mask and policy from the object specified by
95 .Fa level ,
96 .Fa which
97 and
98 .Fa id
99 and stores it in the space provided by
100 .Fa mask
101 and
102 .Fa policy .
103 .Pp
104 .Fn cpuset_setdomain
105 attempts to set the mask and policy for the object specified by
106 .Fa level ,
107 .Fa which
108 and
109 .Fa id
110 to the values in
111 .Fa mask
112 and
113 .Fa policy .
114 .Sh ALLOCATION POLICIES
115 Valid policy values are as follows:
116 .Bl -tag -width "foo"
117 .It Dv DOMAINSET_POLICY_ROUNDROBIN
118 Memory is allocated on a round-robin basis by cycling through each domain in
119 .Fa mask .
120 .It Dv DOMAINSET_POLICY_FIRSTTOUCH
121 Memory is allocated on the domain local to the CPU the requesting thread is
122 running on.
123 Failure to allocate from this domain will fallback to round-robin.
124 .It Dv DOMAINSET_POLICY_PREFER
125 Memory is allocated preferentially from the single domain specified in the mask.
126 If memory is unavailable the domains listed in the parent cpuset will be
127 visited in a round-robin order.
128 .El
129 .Sh RETURN VALUES
130 .Rv -std
131 .Sh ERRORS
132 The following error codes may be set in
133 .Va errno :
134 .Bl -tag -width Er
135 .\" When changing this list, consider updating share/man/man3/pthread_create.3,
136 .\" since that function can return any of these errors.
137 .It Bq Er EINVAL
138 The
139 .Fa level
140 or
141 .Fa which
142 argument was not a valid value.
143 .It Bq Er EINVAL
144 The
145 .Fa mask or
146 .Fa policy
147 argument specified when calling
148 .Fn cpuset_setdomain
149 was not a valid value.
150 .It Bq Er EDEADLK
151 The
152 .Fn cpuset_setdomain
153 call would leave a thread without a valid CPU to run on because the set
154 does not overlap with the thread's anonymous mask.
155 .It Bq Er EFAULT
156 The mask pointer passed was invalid.
157 .It Bq Er ESRCH
158 The object specified by the
159 .Fa id
160 and
161 .Fa which
162 arguments could not be found.
163 .It Bq Er ERANGE
164 The
165 .Fa domainsetsize
166 was either preposterously large or smaller than the kernel set size.
167 .It Bq Er EPERM
168 The calling process did not have the credentials required to complete the
169 operation.
170 .It Bq Er ECAPMODE
171 The calling process attempted to act on a process other than itself, while
172 in capability mode.
173 See
174 .Xr capsicum 4 .
175 .El
176 .Sh SEE ALSO
177 .Xr cpuset 1 ,
178 .Xr cpuset 2 ,
179 .Xr cpuset_getaffinity 2 ,
180 .Xr cpuset_getid 2 ,
181 .Xr cpuset_setaffinity 2 ,
182 .Xr cpuset_setid 2 ,
183 .Xr capsicum 4 ,
184 .Xr cpuset 9
185 .Sh HISTORY
186 The
187 .Nm
188 family of system calls first appeared in
189 .Fx 12.0 .
190 .Sh AUTHORS
191 .An Jeffrey Roberson Aq Mt jeff@FreeBSD.org