1 .\" Copyright (c) 2015 Conrad Meyer <cem@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
14 .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
15 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
17 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 .\" POSSIBILITY OF SUCH DAMAGE.
33 .Nm CPUSET_T_INITIALIZER ,
54 .Nm CPU_SET_ATOMIC_ACQ ,
57 .Nm CPU_COPY_STORE_REL
58 .Nd cpuset manipulation macros
63 .Fn CPUSET_T_INITIALIZER "ARRAY_CONTENTS"
66 .Fn CPU_CLR "size_t cpu_idx" "cpuset_t *cpuset"
67 .Fn CPU_COPY "cpuset_t *from" "cpuset_t *to"
69 .Fn CPU_ISSET "size_t cpu_idx" "cpuset_t *cpuset"
70 .Fn CPU_SET "size_t cpu_idx" "cpuset_t *cpuset"
71 .Fn CPU_ZERO "cpuset_t *cpuset"
72 .Fn CPU_FILL "cpuset_t *cpuset"
73 .Fn CPU_SETOF "size_t cpu_idx" "cpuset_t *cpuset"
75 .Fn CPU_EMPTY "cpuset_t *cpuset"
77 .Fn CPU_ISFULLSET "cpuset_t *cpuset"
79 .Fn CPU_FFS "cpuset_t *cpuset"
81 .Fn CPU_COUNT "cpuset_t *cpuset"
84 .Fn CPU_SUBSET "cpuset_t *haystack" "cpuset_t *needle"
86 .Fn CPU_OVERLAP "cpuset_t *cpuset1" "cpuset_t *cpuset2"
88 .Fn CPU_CMP "cpuset_t *cpuset1" "cpuset_t *cpuset2"
89 .Fn CPU_OR "cpuset_t *dst" "cpuset_t *src"
90 .Fn CPU_AND "cpuset_t *dst" "cpuset_t *src"
91 .Fn CPU_ANDNOT "cpuset_t *dst" "cpuset_t *src"
93 .Fn CPU_CLR_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset"
94 .Fn CPU_SET_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset"
95 .Fn CPU_SET_ATOMIC_ACQ "size_t cpu_idx" "cpuset_t *cpuset"
97 .Fn CPU_AND_ATOMIC "cpuset_t *dst" "cpuset_t *src"
98 .Fn CPU_OR_ATOMIC "cpuset_t *dst" "cpuset_t *src"
99 .Fn CPU_COPY_STORE_REL "cpuset_t *from" "cpuset_t *to"
103 family of macros provide a flexible and efficient CPU set implementation,
107 Each CPU is represented by a single bit.
108 The maximum number of CPUs representable by
112 Individual CPUs in cpusets are referenced with indices zero through
116 .Fn CPUSET_T_INITIALIZER
117 macro allows one to initialize a
119 with a compile time literal value.
123 macro defines a compile time literal, usable by
124 .Fn CPUSET_T_INITIALIZER ,
125 representing a full cpuset (all CPUs present).
127 .Fn CPUSET_T_INITIALIZER
131 .Sx CPUSET_T_INITIALIZER EXAMPLE
138 from the cpuset pointed to by
142 macro is identical, but the bit representing the CPU is cleared with atomic
143 machine instructions.
147 macro copies the contents of the cpuset
151 .Fn CPU_COPY_STORE_REL
152 is similar, but copies component machine words from
156 with atomic store with release semantics.
159 is composed of multiple machine words,
160 .Fn CPU_COPY_STORE_REL
161 performs multiple individually atomic operations.)
167 to the cpuset pointed to by
169 if it is not already present.
172 macro is identical, but the bit representing the CPU is set with atomic
173 machine instructions.
175 .Fn CPU_SET_ATOMIC_ACQ
176 macro sets the bit representing the CPU with atomic acquire semantics.
180 macro removes all CPUs from
185 macro adds all CPUs to
190 macro removes all CPUs in
192 before adding only CPU
209 is full (the set of all CPUs).
213 macro returns the 1-index of the first (lowest) CPU in
220 to use the non-zero result of
224 index parameter to any other
226 macro, you must subtract one from the result.
230 macro returns the total number of CPUs in
250 have any common CPUs.
255 is not the empty set.)
268 macro adds CPUs present in
274 equivalent of the scalar:
279 is similar, but sets the bits representing CPUs in the component machine words
282 with atomic machine instructions.
285 is composed of multiple machine words,
287 performs multiple individually atomic operations.)
291 macro removes CPUs absent from
297 equivalent of the scalar:
302 is similar, with the same atomic semantics as
307 macro removes CPUs in
313 equivalent of the scalar:
317 .Sh CPUSET_T_INITIALIZER EXAMPLE
321 /* Initialize myset to filled (all CPUs) */
322 myset = CPUSET_T_INITIALIZER(CPUSET_FSET);
324 /* Initialize myset to only the lowest CPU */
325 myset = CPUSET_T_INITIALIZER(0x1);
335 released in January 2009, and in
337 released in November 2009.
339 This manual page first appeared in
345 macros were written by
346 .An Jeff Roberson Aq Mt jeff@FreeBSD.org .
347 This manual page was written by
348 .An Conrad Meyer Aq Mt cem@FreeBSD.org .
350 Unlike every other reference to individual set members, which are zero-indexed,
352 returns a one-indexed result (or zero if the cpuset is empty).