]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/cpuset_getdomain.2
Merge ^/vendor/llvm-project/release-10.x up to its last change (upstream
[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 Mar 19, 2018
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" "domainet_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.  Failure to allocate from this domain will fallback to round-robin.
123 .It Dv DOMAINSET_POLICY_PREFER
124 Memory is allocated preferentially from the single domain specified in the mask.
125 If memory is unavailable the domains listed in the parent cpuset will be
126 visited in a round-robin order.
127 .El
128 .Sh RETURN VALUES
129 .Rv -std
130 .Sh ERRORS
131 The following error codes may be set in
132 .Va errno :
133 .Bl -tag -width Er
134 .\" When changing this list, consider updating share/man/man3/pthread_create.3,
135 .\" since that function can return any of these errors.
136 .It Bq Er EINVAL
137 The
138 .Fa level
139 or
140 .Fa which
141 argument was not a valid value.
142 .It Bq Er EINVAL
143 The
144 .Fa mask or
145 .Fa policy
146 argument specified when calling
147 .Fn cpuset_setdomain
148 was not a valid value.
149 .It Bq Er EDEADLK
150 The
151 .Fn cpuset_setdomain
152 call would leave a thread without a valid CPU to run on because the set
153 does not overlap with the thread's anonymous mask.
154 .It Bq Er EFAULT
155 The mask pointer passed was invalid.
156 .It Bq Er ESRCH
157 The object specified by the
158 .Fa id
159 and
160 .Fa which
161 arguments could not be found.
162 .It Bq Er ERANGE
163 The
164 .Fa domainsetsize
165 was either preposterously large or smaller than the kernel set size.
166 .It Bq Er EPERM
167 The calling process did not have the credentials required to complete the
168 operation.
169 .It Bq Er ECAPMODE
170 The calling process attempted to act on a process other than itself, while 
171 in capability mode.
172 See
173 .Xr capsicum 4 .
174 .El
175 .Sh SEE ALSO
176 .Xr capsicum 4 ,
177 .Xr cpuset 1 ,
178 .Xr cpuset 2 ,
179 .Xr cpuset_getid 2 ,
180 .Xr cpuset_setid 2 ,
181 .Xr cpuset_getaffinity 2 ,
182 .Xr cpuset_setaffinity 2 ,
183 .Xr cpuset 9
184 .Sh HISTORY
185 The
186 .Nm
187 family of system calls first appeared in
188 .Fx 12.0 .
189 .Sh AUTHORS
190 .An Jeffrey Roberson Aq Mt jeff@FreeBSD.org