]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/cpuset.7
standards.7: Add some more standards
[thirdparty/man-pages.git] / man7 / cpuset.7
CommitLineData
0de5014f
MK
1.\" Copyright (c) 2008 Silicon Graphics, Inc.
2.\"
3.\" Author: Paul Jackson (http://oss.sgi.com/projects/cpusets)
4.\"
ef06249a 5.\" %%%LICENSE_START(GPLv2_MISC)
0de5014f
MK
6.\" This is free documentation; you can redistribute it and/or
7.\" modify it under the terms of the GNU General Public License
8.\" version 2 as published by the Free Software Foundation.
9.\"
10.\" The GNU General Public License's references to "object code"
11.\" and "executables" are to be interpreted as the output of any
12.\" document formatting or typesetting system, including
13.\" intermediate and printed output.
14.\"
15.\" This manual is distributed in the hope that it will be useful,
16.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18.\" GNU General Public License for more details.
19.\"
20.\" You should have received a copy of the GNU General Public
c715f741
MK
21.\" License along with this manual; if not, see
22.\" <http://www.gnu.org/licenses/>.
8ff7380d 23.\" %%%LICENSE_END
0de5014f 24.\"
4b8c67d9 25.TH CPUSET 7 2017-09-15 "Linux" "Linux Programmer's Manual"
0de5014f
MK
26.SH NAME
27cpuset \- confine processes to processor and memory node subsets
28.SH DESCRIPTION
9ee4a2b6 29The cpuset filesystem is a pseudo-filesystem interface
0de5014f
MK
30to the kernel cpuset mechanism,
31which is used to control the processor placement
32and memory placement of processes.
33It is commonly mounted at
34.IR /dev/cpuset .
35.PP
36On systems with kernels compiled with built in support for cpusets,
37all processes are attached to a cpuset, and cpusets are always present.
38If a system supports cpusets, then it will have the entry
39.B nodev cpuset
40in the file
41.IR /proc/filesystems .
9ee4a2b6 42By mounting the cpuset filesystem (see the
0de5014f
MK
43.B EXAMPLE
44section below),
45the administrator can configure the cpusets on a system
46to control the processor and memory placement of processes
47on that system.
48By default, if the cpuset configuration
28955f15
SP
49on a system is not modified or if the cpuset filesystem
50is not even mounted, then the cpuset mechanism,
41185b12 51though present, has no effect on the system's behavior.
0de5014f
MK
52.PP
53A cpuset defines a list of CPUs and memory nodes.
54.PP
55The CPUs of a system include all the logical processing
56units on which a process can execute, including, if present,
57multiple processor cores within a package and Hyper-Threads
58within a processor core.
59Memory nodes include all distinct
60banks of main memory; small and SMP systems typically have
61just one memory node that contains all the system's main memory,
62while NUMA (non-uniform memory access) systems have multiple memory nodes.
63.PP
64Cpusets are represented as directories in a hierarchical
9ee4a2b6 65pseudo-filesystem, where the top directory in the hierarchy
0de5014f
MK
66.RI ( /dev/cpuset )
67represents the entire system (all online CPUs and memory nodes)
68and any cpuset that is the child (descendant) of
69another parent cpuset contains a subset of that parent's
70CPUs and memory nodes.
71The directories and files representing cpusets have normal
9ee4a2b6 72filesystem permissions.
0de5014f
MK
73.PP
74Every process in the system belongs to exactly one cpuset.
33a0ccb2 75A process is confined to run only on the CPUs in
0de5014f
MK
76the cpuset it belongs to, and to allocate memory only
77on the memory nodes in that cpuset.
78When a process
79.BR fork (2)s,
80the child process is placed in the same cpuset as its parent.
81With sufficient privilege, a process may be moved from one
82cpuset to another and the allowed CPUs and memory nodes
83of an existing cpuset may be changed.
84.PP
85When the system begins booting, a single cpuset is
86defined that includes all CPUs and memory nodes on the
87system, and all processes are in that cpuset.
88During the boot process, or later during normal system operation,
89other cpusets may be created, as subdirectories of this top cpuset,
90under the control of the system administrator,
91and processes may be placed in these other cpusets.
92.PP
93Cpusets are integrated with the
94.BR sched_setaffinity (2)
95scheduling affinity mechanism and the
96.BR mbind (2)
97and
98.BR set_mempolicy (2)
99memory-placement mechanisms in the kernel.
100Neither of these mechanisms let a process make use
101of a CPU or memory node that is not allowed by that process's cpuset.
102If changes to a process's cpuset placement conflict with these
103other mechanisms, then cpuset placement is enforced
104even if it means overriding these other mechanisms.
105The kernel accomplishes this overriding by silently
106restricting the CPUs and memory nodes requested by
107these other mechanisms to those allowed by the
108invoking process's cpuset.
109This can result in these
110other calls returning an error, if for example, such
111a call ends up requesting an empty set of CPUs or
112memory nodes, after that request is restricted to
113the invoking process's cpuset.
114.PP
115Typically, a cpuset is used to manage
116the CPU and memory-node confinement for a set of
117cooperating processes such as a batch scheduler job, and these
118other mechanisms are used to manage the placement of
119individual processes or memory regions within that set or job.
120.SH FILES
121Each directory below
122.I /dev/cpuset
123represents a cpuset and contains a fixed set of pseudo-files
124describing the state of that cpuset.
125.PP
126New cpusets are created using the
127.BR mkdir (2)
128system call or the
129.BR mkdir (1)
130command.
131The properties of a cpuset, such as its flags, allowed
132CPUs and memory nodes, and attached processes, are queried and modified
133by reading or writing to the appropriate file in that cpuset's directory,
134as listed below.
135.PP
136The pseudo-files in each cpuset directory are automatically created when
137the cpuset is created, as a result of the
138.BR mkdir (2)
139invocation.
140It is not possible to directly add or remove these pseudo-files.
141.PP
142A cpuset directory that contains no child cpuset directories,
143and has no attached processes, can be removed using
144.BR rmdir (2)
145or
146.BR rmdir (1).
147It is not necessary, or possible,
148to remove the pseudo-files inside the directory before removing it.
149.PP
150The pseudo-files in each cpuset directory are
151small text files that may be read and
152written using traditional shell utilities such as
153.BR cat (1),
154and
155.BR echo (1),
156or from a program by using file I/O library functions or system calls,
157such as
158.BR open (2),
159.BR read (2),
160.BR write (2),
161and
162.BR close (2).
163.PP
164The pseudo-files in a cpuset directory represent internal kernel
165state and do not have any persistent image on disk.
166Each of these per-cpuset files is listed and described below.
167.\" ====================== tasks ======================
168.TP
169.I tasks
170List of the process IDs (PIDs) of the processes in that cpuset.
171The list is formatted as a series of ASCII
172decimal numbers, each followed by a newline.
173A process may be added to a cpuset (automatically removing
174it from the cpuset that previously contained it) by writing its
175PID to that cpuset's
176.I tasks
de396db5 177file (with or without a trailing newline).
a721e8b2 178.IP
0de5014f
MK
179.B Warning:
180only one PID may be written to the
181.I tasks
182file at a time.
183If a string is written that contains more
184than one PID, only the first one will be used.
185.\" =================== notify_on_release ===================
186.TP
187.I notify_on_release
188Flag (0 or 1).
189If set (1), that cpuset will receive special handling
190after it is released, that is, after all processes cease using
191it (i.e., terminate or are moved to a different cpuset)
192and all child cpuset directories have been removed.
193See the \fBNotify On Release\fR section, below.
194.\" ====================== cpus ======================
195.TP
0a61a4f4 196.I cpuset.cpus
0de5014f
MK
197List of the physical numbers of the CPUs on which processes
198in that cpuset are allowed to execute.
199See \fBList Format\fR below for a description of the
200format of
201.IR cpus .
a721e8b2 202.IP
0de5014f
MK
203The CPUs allowed to a cpuset may be changed by
204writing a new list to its
205.I cpus
206file.
207.\" ==================== cpu_exclusive ====================
208.TP
0a61a4f4 209.I cpuset.cpu_exclusive
0de5014f
MK
210Flag (0 or 1).
211If set (1), the cpuset has exclusive use of
212its CPUs (no sibling or cousin cpuset may overlap CPUs).
238a751e 213By default, this is off (0).
0de5014f 214Newly created cpusets also initially default this to off (0).
a721e8b2 215.IP
0de5014f
MK
216Two cpusets are
217.I sibling
218cpusets if they share the same parent cpuset in the
219.I /dev/cpuset
220hierarchy.
221Two cpusets are
222.I cousin
223cpusets if neither is the ancestor of the other.
224Regardless of the
225.I cpu_exclusive
226setting, if one cpuset is the ancestor of another,
aa796481 227and if both of these cpusets have nonempty
0de5014f
MK
228.IR cpus ,
229then their
230.I cpus
231must overlap, because the
232.I cpus
233of any cpuset are always a subset of the
234.I cpus
235of its parent cpuset.
236.\" ====================== mems ======================
237.TP
0a61a4f4 238.I cpuset.mems
0de5014f
MK
239List of memory nodes on which processes in this cpuset are
240allowed to allocate memory.
241See \fBList Format\fR below for a description of the
242format of
243.IR mems .
244.\" ==================== mem_exclusive ====================
245.TP
0a61a4f4 246.I cpuset.mem_exclusive
0de5014f
MK
247Flag (0 or 1).
248If set (1), the cpuset has exclusive use of
249its memory nodes (no sibling or cousin may overlap).
76eac093 250Also if set (1), the cpuset is a \fBHardwall\fR cpuset (see below).
238a751e 251By default, this is off (0).
0de5014f 252Newly created cpusets also initially default this to off (0).
a721e8b2 253.IP
0de5014f
MK
254Regardless of the
255.I mem_exclusive
256setting, if one cpuset is the ancestor of another,
257then their memory nodes must overlap, because the memory