1 .\" Copyright (c) 2008 Christian Brueffer
2 .\" Copyright (c) 2008 Jeffrey Roberson
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .Nd manage CPU affinity sets
42 .Fn cpuset "cpusetid_t *setid"
44 .Fn cpuset_setid "cpuwhich_t which" "id_t id" "cpusetid_t setid"
46 .Fn cpuset_getid "cpulevel_t level" "cpuwhich_t which" "id_t id" "cpusetid_t *setid"
50 family of system calls allow applications to control sets of processors and
51 memory domains and assign processes and threads to these sets.
52 Processor sets contain lists of CPUs and domains that members may run on
53 and exist only as long as some process is a member of the set.
54 All processes in the system have an assigned set.
55 The default set for all processes in the system is the set numbered 1.
56 Threads belong to the same set as the process which contains them,
57 however, they may further restrict their set with the anonymous
58 per-thread mask to bind to a specific CPU or subset of CPUs and memory domains.
60 Sets are referenced by a number of type
62 Each thread has a root set, an assigned set, and an anonymous mask.
63 Only the root and assigned sets are numbered.
64 The root set is the set of all CPUs and memory domains available in the system
65 or in the system partition the thread is running in.
66 The assigned set is a subset of the root set and is administratively
67 assignable on a per-process basis.
68 Many processes and threads may be members of a numbered set.
70 The anonymous set is a further thread-specific refinement on the assigned
72 It is intended that administrators will manipulate numbered sets using
74 while application developers will manipulate anonymous sets using
75 .Xr cpuset_setaffinity 2 and
76 .Xr cpuset_setdomain 2 .
78 To select the correct set a value of type
81 The following values for
84 .Bl -column CPU_LEVEL_CPUSET -offset indent
85 .It Dv CPU_LEVEL_ROOT Ta "Root set"
86 .It Dv CPU_LEVEL_CPUSET Ta "Assigned set"
87 .It Dv CPU_LEVEL_WHICH Ta "Set specified by which argument"
92 argument determines how the value of
94 is interpreted and is of type
98 argument may have the following values:
99 .Bl -column CPU_WHICH_INTRHANDLER -offset indent
100 .It Dv CPU_WHICH_TID Ta "id is lwpid_t (thread id)"
101 .It Dv CPU_WHICH_PID Ta "id is pid_t (process id)"
102 .It Dv CPU_WHICH_JAIL Ta "id is jid (jail id)"
103 .It Dv CPU_WHICH_CPUSET Ta "id is a cpusetid_t (cpuset id)"
104 .It Dv CPU_WHICH_IRQ Ta "id is an irq number"
105 .It Dv CPU_WHICH_INTRHANDLER Ta "id is an irq number for an interrupt handler"
106 .It Dv CPU_WHICH_ITHREAD Ta "id is an irq number for an ithread"
107 .It Dv CPU_WHICH_DOMAIN Ta "id is a NUMA domain"
112 of '-1' may be used with a
119 to mean the current thread, process, or current thread's
121 All cpuset syscalls allow this usage.
131 refers to the anonymous mask of the object.
132 This mask does not have an id and may only be manipulated with
133 .Xr cpuset_setaffinity 2 .
136 creates a new set containing the same CPUs as the root set of the current
137 process and stores its id in the space provided by
139 On successful completion the calling process joins the set and is the
141 Children inherit this set after a call to
145 attempts to set the id of the object specified by the
150 is the only acceptable value for which as
151 threads do not have an id distinct from their process and the API does
152 not permit changing the id of an existing set.
153 Upon successful completion all of the threads in the target process will
154 be running on CPUs permitted by the set.
157 retrieves a set id from the object indicated by
159 and stores it in the space pointed to by
161 The retrieved id may be that of either the root or assigned set
162 depending on the value of
169 to get the set id from
170 the process or thread specified by the
175 with a process or thread is unsupported since
176 this references the unnumbered anonymous mask.
178 The actual contents of the sets may be retrieved or manipulated using
179 .Xr cpuset_getaffinity 2 ,
180 .Xr cpuset_setaffinity 2 ,
181 .Xr cpuset_getdomain 2 , and
182 .Xr cpuset_setdomain 2 .
183 See those manual pages for more detail.
187 The following error codes may be set in
195 argument was not a valid value.
199 call would leave a thread without a valid CPU to run on because the set
200 does not overlap with the thread's anonymous mask.
202 The setid pointer passed to
208 The object specified by the
212 arguments could not be found.
214 The calling process did not have the credentials required to complete the
223 .Xr cpuset_getaffinity 2 ,
224 .Xr cpuset_getdomain 2 ,
225 .Xr cpuset_setaffinity 2 ,
226 .Xr cpuset_setdomain 2 ,
227 .Xr pthread_affinity_np 3 ,
228 .Xr pthread_attr_affinity_np 3 ,
233 family of system calls first appeared in
236 .An Jeffrey Roberson Aq Mt jeff@FreeBSD.org