]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/sys/cpuset_getaffinity.2
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libc / sys / cpuset_getaffinity.2
1 .\" Copyright (c) 2008 Christian Brueffer
2 .\" Copyright (c) 2008 Jeffrey Roberson
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
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.
13 .\"
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
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd September 10, 2010
29 .Dt CPUSET 2
30 .Os
31 .Sh NAME
32 .Nm cpuset_getaffinity ,
33 .Nm cpuset_setaffinity
34 .Nd manage CPU affinity
35 .Sh LIBRARY
36 .Lb libc
37 .Sh SYNOPSIS
38 .In sys/param.h
39 .In sys/cpuset.h
40 .Ft int
41 .Fn cpuset_getaffinity "cpulevel_t level" "cpuwhich_t which" "id_t id" "size_t setsize" "cpuset_t *mask"
42 .Ft int
43 .Fn cpuset_setaffinity "cpulevel_t level" "cpuwhich_t which" "id_t id" "size_t setsize" "const cpuset_t *mask"
44 .Sh DESCRIPTION
45 .Fn cpuset_getaffinity
46 and
47 .Fn cpuset_setaffinity
48 allow the manipulation of sets of CPUs available to processes, threads,
49 interrupts, jails and other resources.
50 These functions may manipulate sets of CPUs that contain many processes
51 or per-object anonymous masks that effect only a single object.
52 .Pp
53 The valid values for the
54 .Fa level
55 and
56 .Fa which
57 arguments are documented in
58 .Xr cpuset 2 .
59 These arguments specify which object and which set of the object we are
60 referring to.
61 Not all possible combinations are valid.
62 For example, only processes may belong to a numbered set accessed by a
63 .Fa level
64 argument of
65 .Dv CPU_LEVEL_CPUSET .
66 All resources, however, have a mask which may be manipulated with
67 .Dv CPU_LEVEL_WHICH .
68 .Pp
69 Masks of type
70 .Ft cpuset_t
71 are composed using the
72 .Xr CPU_SET 2
73 macros.
74 The kernel tolerates large sets as long as all CPUs specified
75 in the set exist.
76 Sets smaller than the kernel uses generate an error on calls to
77 .Fn cpuset_getaffinity
78 even if the result set would fit within the user supplied set.
79 Calls to
80 .Fn cpuset_setaffinity
81 tolerate small sets with no restrictions.
82 .Pp
83 The supplied mask should have a size of
84 .Fa setsize
85 bytes.
86 This size is usually provided by calling
87 .Li sizeof(mask)
88 which is ultimately determined by the value of
89 .Dv CPU_SETSIZE
90 as defined in
91 .In sys/cpuset.h .
92 .Pp
93 .Fn cpuset_getaffinity
94 retrieves the
95 mask from the object specified by
96 .Fa level ,
97 .Fa which
98 and
99 .Fa id
100 and stores it in the space provided by
101 .Fa mask .
102 .Pp
103 .Fn cpuset_setaffinity
104 attempts to set the mask for the object specified by
105 .Fa level ,
106 .Fa which
107 and
108 .Fa id
109 to the value in
110 .Fa mask .
111 .Pp
112 .Sh RETURN VALUES
113 .Rv -std
114 .Sh ERRORS
115 The following error codes may be set in
116 .Va errno :
117 .Bl -tag -width Er
118 .It Bq Er EINVAL
119 The
120 .Fa level
121 or
122 .Fa which
123 argument was not a valid value.
124 .It Bq Er EINVAL
125 The
126 .Fa mask
127 argument specified when calling
128 .Fn cpuset_setaffinity
129 was not a valid value.
130 .It Bq Er EDEADLK
131 The
132 .Fn cpuset_setaffinity
133 call would leave a thread without a valid CPU to run on because the set
134 does not overlap with the thread's anonymous mask.
135 .It Bq Er EFAULT
136 The mask pointer passed was invalid.
137 .It Bq Er ESRCH
138 The object specified by the
139 .Fa id
140 and
141 .Fa which
142 arguments could not be found.
143 .It Bq Er ERANGE
144 The
145 .Fa cpusetsize
146 was either preposterously large or smaller than the kernel set size.
147 .It Bq Er EPERM
148 The calling process did not have the credentials required to complete the
149 operation.
150 .El
151 .Sh SEE ALSO
152 .Xr cpuset 1 ,
153 .Xr cpuset 2 ,
154 .Xr cpuset_getid 2 ,
155 .Xr cpuset_setid 2 ,
156 .Xr CPU_SET 3 ,
157 .Xr pthread_affinity_np 3 ,
158 .Xr pthread_attr_affinity_np 3
159 .Sh HISTORY
160 The
161 .Nm
162 family of system calls first appeared in
163 .Fx 7.1 .
164 .Sh AUTHOR
165 .An Jeffrey Roberson Aq jeff@FreeBSD.org