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