OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / man7 / cpuset.7
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
20 .\" License along with this manual; if not, write to the Free
21 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 .\" MA 02111, USA.
23 .\"
24 .\"*******************************************************************
25 .\"
26 .\" This file was generated with po4a. Translate the source file.
27 .\"
28 .\"*******************************************************************
29 .TH CPUSET 7 2008\-11\-12 Linux "Linux Programmer's Manual"
30 .SH 名前
31 cpuset \- confine processes to processor and memory node subsets
32 .SH 説明
33 The cpuset file system is a pseudo\-file\-system interface to the kernel
34 cpuset mechanism, which is used to control the processor placement and
35 memory placement of processes.  It is commonly mounted at \fI/dev/cpuset\fP.
36 .PP
37 On systems with kernels compiled with built in support for cpusets, all
38 processes are attached to a cpuset, and cpusets are always present.  If a
39 system supports cpusets, then it will have the entry \fBnodev cpuset\fP in the
40 file \fI/proc/filesystems\fP.  By mounting the cpuset file system (see the
41 \fBEXAMPLE\fP section below), the administrator can configure the cpusets on a
42 system to control the processor and memory placement of processes on that
43 system.  By default, if the cpuset configuration on a system is not modified
44 or if the cpuset file system is not even mounted, then the cpuset mechanism,
45 though present, has no affect on the system's behavior.
46 .PP
47 A cpuset defines a list of CPUs and memory nodes.
48 .PP
49 The CPUs of a system include all the logical processing units on which a
50 process can execute, including, if present, multiple processor cores within
51 a package and Hyper\-Threads within a processor core.  Memory nodes include
52 all distinct banks of main memory; small and SMP systems typically have just
53 one memory node that contains all the system's main memory, while NUMA
54 (non\-uniform memory access) systems have multiple memory nodes.
55 .PP
56 Cpusets are represented as directories in a hierarchical pseudo\-file system,
57 where the top directory in the hierarchy (\fI/dev/cpuset\fP)  represents the
58 entire system (all online CPUs and memory nodes)  and any cpuset that is the
59 child (descendant) of another parent cpuset contains a subset of that
60 parent's CPUs and memory nodes.  The directories and files representing
61 cpusets have normal file\-system permissions.
62 .PP
63 Every process in the system belongs to exactly one cpuset.  A process is
64 confined to only run on the CPUs in the cpuset it belongs to, and to
65 allocate memory only on the memory nodes in that cpuset.  When a process
66 \fBfork\fP(2)s, the child process is placed in the same cpuset as its parent.
67 With sufficient privilege, a process may be moved from one cpuset to another
68 and the allowed CPUs and memory nodes of an existing cpuset may be changed.
69 .PP
70 When the system begins booting, a single cpuset is defined that includes all
71 CPUs and memory nodes on the system, and all processes are in that cpuset.
72 During the boot process, or later during normal system operation, other
73 cpusets may be created, as subdirectories of this top cpuset, under the
74 control of the system administrator, and processes may be placed in these
75 other cpusets.
76 .PP
77 Cpusets are integrated with the \fBsched_setaffinity\fP(2)  scheduling affinity
78 mechanism and the \fBmbind\fP(2)  and \fBset_mempolicy\fP(2)  memory\-placement
79 mechanisms in the kernel.  Neither of these mechanisms let a process make
80 use of a CPU or memory node that is not allowed by that process's cpuset.
81 If changes to a process's cpuset placement conflict with these other
82 mechanisms, then cpuset placement is enforced even if it means overriding
83 these other mechanisms.  The kernel accomplishes this overriding by silently
84 restricting the CPUs and memory nodes requested by these other mechanisms to
85 those allowed by the invoking process's cpuset.  This can result in these
86 other calls returning an error, if for example, such a call ends up
87 requesting an empty set of CPUs or memory nodes, after that request is
88 restricted to the invoking process's cpuset.
89 .PP
90 Typically, a cpuset is used to manage the CPU and memory\-node confinement
91 for a set of cooperating processes such as a batch scheduler job, and these
92 other mechanisms are used to manage the placement of individual processes or
93 memory regions within that set or job.
94 .SH FILES
95 Each directory below \fI/dev/cpuset\fP represents a cpuset and contains a fixed
96 set of pseudo\-files describing the state of that cpuset.
97 .PP
98 New cpusets are created using the \fBmkdir\fP(2)  system call or the
99 \fBmkdir\fP(1)  command.  The properties of a cpuset, such as its flags,
100 allowed CPUs and memory nodes, and attached processes, are queried and
101 modified by reading or writing to the appropriate file in that cpuset's
102 directory, as listed below.
103 .PP
104 The pseudo\-files in each cpuset directory are automatically created when the
105 cpuset is created, as a result of the \fBmkdir\fP(2)  invocation.  It is not
106 possible to directly add or remove these pseudo\-files.
107 .PP
108 A cpuset directory that contains no child cpuset directories, and has no
109 attached processes, can be removed using \fBrmdir\fP(2)  or \fBrmdir\fP(1).  It is
110 not necessary, or possible, to remove the pseudo\-files inside the directory
111 before removing it.
112 .PP
113 The pseudo\-files in each cpuset directory are small text files that may be
114 read and written using traditional shell utilities such as \fBcat\fP(1), and
115 \fBecho\fP(1), or from a program by using file I/O library functions or system
116 calls, such as \fBopen\fP(2), \fBread\fP(2), \fBwrite\fP(2), and \fBclose\fP(2).
117 .PP
118 .\" ====================== tasks ======================
119 The pseudo\-files in a cpuset directory represent internal kernel state and
120 do not have any persistent image on disk.  Each of these per\-cpuset files is
121 listed and described below.
122 .TP 
123 \fItasks\fP
124 List of the process IDs (PIDs) of the processes in that cpuset.  The list is
125 formatted as a series of ASCII decimal numbers, each followed by a newline.
126 A process may be added to a cpuset (automatically removing it from the
127 cpuset that previously contained it) by writing its PID to that cpuset's
128 \fItasks\fP file (with or without a trailing newline.)
129
130 .\" =================== notify_on_release ===================
131 \fBWarning:\fP only one PID may be written to the \fItasks\fP file at a time.  If
132 a string is written that contains more than one PID, only the first one will
133 be used.
134 .TP 
135 \fInotify_on_release\fP
136 .\" ====================== cpus ======================
137 Flag (0 or 1).  If set (1), that cpuset will receive special handling after
138 it is released, that is, after all processes cease using it (i.e., terminate
139 or are moved to a different cpuset)  and all child cpuset directories have
140 been removed.  See the \fBNotify On Release\fP section, below.
141 .TP 
142 \fIcpus\fP
143 List of the physical numbers of the CPUs on which processes in that cpuset
144 are allowed to execute.  See \fBList Format\fP below for a description of the
145 format of \fIcpus\fP.
146
147 .\" ==================== cpu_exclusive ====================
148 The CPUs allowed to a cpuset may be changed by writing a new list to its
149 \fIcpus\fP file.
150 .TP 
151 \fIcpu_exclusive\fP
152 Flag (0 or 1).  If set (1), the cpuset has exclusive use of its CPUs (no
153 sibling or cousin cpuset may overlap CPUs).  By default this is off (0).
154 Newly created cpusets also initially default this to off (0).
155
156 .\" ====================== mems ======================
157 Two cpusets are \fIsibling\fP cpusets if they share the same parent cpuset in
158 the \fI/dev/cpuset\fP hierarchy.  Two cpusets are \fIcousin\fP cpusets if neither
159 is the ancestor of the other.  Regardless of the \fIcpu_exclusive\fP setting,
160 if one cpuset is the ancestor of another, and if both of these cpusets have
161 nonempty \fIcpus\fP, then their \fIcpus\fP must overlap, because the \fIcpus\fP of
162 any cpuset are always a subset of the \fIcpus\fP of its parent cpuset.
163 .TP 
164 \fImems\fP
165 .\" ==================== mem_exclusive ====================
166 List of memory nodes on which processes in this cpuset are allowed to
167 allocate memory.  See \fBList Format\fP below for a description of the format
168 of \fImems\fP.
169 .TP 
170 \fImem_exclusive\fP
171 Flag (0 or 1).  If set (1), the cpuset has exclusive use of its memory nodes
172 (no sibling or cousin may overlap).  Also if set (1), the cpuset is a
173 \fBHardwall\fP cpuset (see below.)  By default this is off (0).  Newly created
174 cpusets also initially default this to off (0).
175
176 .\" ==================== mem_hardwall ====================
177 Regardless of the \fImem_exclusive\fP setting, if one cpuset is the ancestor of
178 another, then their memory nodes must overlap, because the memory nodes of
179 any cpuset are always a subset of the memory nodes of that cpuset's parent
180 cpuset.
181 .TP 
182 \fImem_hardwall\fP (since Linux 2.6.26)
183 .\" ==================== memory_migrate ====================
184 Flag (0 or 1).  If set (1), the cpuset is a \fBHardwall\fP cpuset (see below.)
185 Unlike \fBmem_exclusive\fP, there is no constraint on whether cpusets marked
186 \fBmem_hardwall\fP may have overlapping memory nodes with sibling or cousin
187 cpusets.  By default this is off (0).  Newly created cpusets also initially
188 default this to off (0).
189 .TP 
190 \fImemory_migrate\fP (since Linux 2.6.16)
191 .\" ==================== memory_pressure ====================
192 Flag (0 or 1).  If set (1), then memory migration is enabled.  By default
193 this is off (0).  See the \fBMemory Migration\fP section, below.
194 .TP 
195 \fImemory_pressure\fP (since Linux 2.6.16)
196 .\" ================= memory_pressure_enabled =================
197 A measure of how much memory pressure the processes in this cpuset are
198 causing.  See the \fBMemory Pressure\fP section, below.  Unless
199 \fImemory_pressure_enabled\fP is enabled, always has value zero (0).  This file
200 is read\-only.  See the \fBWARNINGS\fP section, below.
201 .TP 
202 \fImemory_pressure_enabled\fP (since Linux 2.6.16)
203 .\" ================== memory_spread_page ==================
204 Flag (0 or 1).  This file is only present in the root cpuset, normally
205 \fI/dev/cpuset\fP.  If set (1), the \fImemory_pressure\fP calculations are enabled
206 for all cpusets in the system.  By default this is off (0).  See the
207 \fBMemory Pressure\fP section, below.
208 .TP 
209 \fImemory_spread_page\fP (since Linux 2.6.17)
210 .\" ================== memory_spread_slab ==================
211 Flag (0 or 1).  If set (1), pages in the kernel page cache (file\-system
212 buffers) are uniformly spread across the cpuset.  By default this is off (0)
213 in the top cpuset, and inherited from the parent cpuset in newly created
214 cpusets.  See the \fBMemory Spread\fP section, below.
215 .TP 
216 \fImemory_spread_slab\fP (since Linux 2.6.17)
217 .\" ================== sched_load_balance ==================
218 Flag (0 or 1).  If set (1), the kernel slab caches for file I/O (directory
219 and inode structures) are uniformly spread across the cpuset.  By default
220 this is off (0) in the top cpuset, and inherited from the parent cpuset in
221 newly created cpusets.  See the \fBMemory Spread\fP section, below.
222 .TP 
223 \fIsched_load_balance\fP (since Linux 2.6.24)
224 .\" ================== sched_relax_domain_level ==================
225 Flag (0 or 1).  If set (1, the default) the kernel will automatically load
226 balance processes in that cpuset over the allowed CPUs in that cpuset.  If
227 cleared (0) the kernel will avoid load balancing processes in this cpuset,
228 \fIunless\fP some other cpuset with overlapping CPUs has its
229 \fIsched_load_balance\fP flag set.  See \fBScheduler Load Balancing\fP, below, for
230 further details.
231 .TP 
232 \fIsched_relax_domain_level\fP (since Linux 2.6.26)
233 .\" ================== proc cpuset ==================
234 Integer, between \-1 and a small positive value.  The
235 \fIsched_relax_domain_level\fP controls the width of the range of CPUs over
236 which the kernel scheduler performs immediate rebalancing of runnable tasks
237 across CPUs.  If \fIsched_load_balance\fP is disabled, then the setting of
238 \fIsched_relax_domain_level\fP does not matter, as no such load balancing is
239 done.  If \fIsched_load_balance\fP is enabled, then the higher the value of the
240 \fIsched_relax_domain_level\fP, the wider the range of CPUs over which
241 immediate load balancing is attempted.  See \fBScheduler Relax Domain Level\fP,
242 below, for further details.
243 .PP
244 .\" ================== proc status ==================
245 In addition to the above pseudo\-files in each directory below
246 \fI/dev/cpuset\fP, each process has a pseudo\-file,
247 \fI/proc/<pid>/cpuset\fP, that displays the path of the process's
248 cpuset directory relative to the root of the cpuset file system.
249 .PP
250 Also the \fI/proc/<pid>/status\fP file for each process has four added
251 lines, displaying the process's \fICpus_allowed\fP (on which CPUs it may be
252 scheduled) and \fIMems_allowed\fP (on which memory nodes it may obtain memory),
253 in the two formats \fBMask Format\fP and \fBList Format\fP (see below)  as shown
254 in the following example:
255 .PP
256 .RS
257 .nf
258 Cpus_allowed:   ffffffff,ffffffff,ffffffff,ffffffff
259 Cpus_allowed_list:     0\-127
260 Mems_allowed:   ffffffff,ffffffff
261 Mems_allowed_list:     0\-63
262 .fi
263 .RE
264 .PP
265 .\" ================== EXTENDED CAPABILITIES ==================
266 The "allowed" fields were added in Linux 2.6.24; the "allowed_list" fields
267 were added in Linux 2.6.26.
268 .SH "EXTENDED CAPABILITIES"
269 .\" ================== Exclusive Cpusets ==================
270 In addition to controlling which \fIcpus\fP and \fImems\fP a process is allowed to
271 use, cpusets provide the following extended capabilities.
272 .SS "Exclusive Cpusets"
273 If a cpuset is marked \fIcpu_exclusive\fP or \fImem_exclusive\fP, no other cpuset,
274 other than a direct ancestor or descendant, may share any of the same CPUs
275 or memory nodes.
276 .PP
277 .\" ================== Hardwall ==================
278 A cpuset that is \fImem_exclusive\fP restricts kernel allocations for buffer
279 cache pages and other internal kernel data pages commonly shared by the
280 kernel across multiple users.  All cpusets, whether \fImem_exclusive\fP or not,
281 restrict allocations of memory for user space.  This enables configuring a
282 system so that several independent jobs can share common kernel data, while
283 isolating each job's user allocation in its own cpuset.  To do this,
284 construct a large \fImem_exclusive\fP cpuset to hold all the jobs, and
285 construct child, non\-\fImem_exclusive\fP cpusets for each individual job.  Only
286 a small amount of kernel memory, such as requests from interrupt handlers,
287 is allowed to be placed on memory nodes outside even a \fImem_exclusive\fP
288 cpuset.
289 .SS Hardwall
290 A cpuset that has \fImem_exclusive\fP or \fImem_hardwall\fP set is a \fIhardwall\fP
291 cpuset.  A \fIhardwall\fP cpuset restricts kernel allocations for page, buffer,
292 and other data commonly shared by the kernel across multiple users.  All
293 cpusets, whether \fIhardwall\fP or not, restrict allocations of memory for user
294 space.
295 .PP
296 This enables configuring a system so that several independent jobs can share
297 common kernel data, such as file system pages, while isolating each job's
298 user allocation in its own cpuset.  To do this, construct a large
299 \fIhardwall\fP cpuset to hold all the jobs, and construct child cpusets for
300 each individual job which are not \fIhardwall\fP cpusets.
301 .PP
302 .\" ================== Notify On Release ==================
303 Only a small amount of kernel memory, such as requests from interrupt
304 handlers, is allowed to be taken outside even a \fIhardwall\fP cpuset.
305 .SS "Notify On Release"
306 If the \fInotify_on_release\fP flag is enabled (1) in a cpuset, then whenever
307 the last process in the cpuset leaves (exits or attaches to some other
308 cpuset)  and the last child cpuset of that cpuset is removed, the kernel
309 will run the command \fI/sbin/cpuset_release_agent\fP, supplying the pathname
310 (relative to the mount point of the cpuset file system) of the abandoned
311 cpuset.  This enables automatic removal of abandoned cpusets.
312 .PP
313 The default value of \fInotify_on_release\fP in the root cpuset at system boot
314 is disabled (0).  The default value of other cpusets at creation is the
315 current value of their parent's \fInotify_on_release\fP setting.
316 .PP
317 The command \fI/sbin/cpuset_release_agent\fP is invoked, with the name
318 (\fI/dev/cpuset\fP relative path)  of the to\-be\-released cpuset in \fIargv[1]\fP.
319 .PP
320 The usual contents of the command \fI/sbin/cpuset_release_agent\fP is simply
321 the shell script:
322 .in +4n
323 .nf
324
325 #!/bin/sh
326 rmdir /dev/cpuset/$1
327 .fi
328 .in
329 .PP
330 .\" ================== Memory Pressure ==================
331 As with other flag values below, this flag can be changed by writing an
332 ASCII number 0 or 1 (with optional trailing newline)  into the file, to
333 clear or set the flag, respectively.
334 .SS "Memory Pressure"
335 The \fImemory_pressure\fP of a cpuset provides a simple per\-cpuset running
336 average of the rate that the processes in a cpuset are attempting to free up
337 in\-use memory on the nodes of the cpuset to satisfy additional memory
338 requests.
339 .PP
340 This enables batch managers that are monitoring jobs running in dedicated
341 cpusets to efficiently detect what level of memory pressure that job is
342 causing.
343 .PP
344 This is useful both on tightly managed systems running a wide mix of
345 submitted jobs, which may choose to terminate or reprioritize jobs that are
346 trying to use more memory than allowed on the nodes assigned them, and with
347 tightly coupled, long\-running, massively parallel scientific computing jobs
348 that will dramatically fail to meet required performance goals if they start
349 to use more memory than allowed to them.
350 .PP
351 This mechanism provides a very economical way for the batch manager to
352 monitor a cpuset for signs of memory pressure.  It's up to the batch manager
353 or other user code to decide what action to take if it detects signs of
354 memory pressure.
355 .PP
356 Unless memory pressure calculation is enabled by setting the pseudo\-file
357 \fI/dev/cpuset/memory_pressure_enabled\fP, it is not computed for any cpuset,
358 and reads from any \fImemory_pressure\fP always return zero, as represented by
359 the ASCII string "0\en".  See the \fBWARNINGS\fP section, below.
360 .PP
361 A per\-cpuset, running average is employed for the following reasons:
362 .IP * 3
363 Because this meter is per\-cpuset rather than per\-process or per virtual
364 memory region, the system load imposed by a batch scheduler monitoring this
365 metric is sharply reduced on large systems, because a scan of the tasklist
366 can be avoided on each set of queries.
367 .IP *
368 Because this meter is a running average rather than an accumulating counter,
369 a batch scheduler can detect memory pressure with a single read, instead of
370 having to read and accumulate results for a period of time.
371 .IP *
372 Because this meter is per\-cpuset rather than per\-process, the batch
373 scheduler can obtain the key information\(emmemory pressure in a
374 cpuset\(emwith a single read, rather than having to query and accumulate
375 results over all the (dynamically changing)  set of processes in the cpuset.
376 .PP
377 The \fImemory_pressure\fP of a cpuset is calculated using a per\-cpuset simple
378 digital filter that is kept within the kernel.  For each cpuset, this filter
379 tracks the recent rate at which processes attached to that cpuset enter the
380 kernel direct reclaim code.
381 .PP
382 The kernel direct reclaim code is entered whenever a process has to satisfy
383 a memory page request by first finding some other page to repurpose, due to
384 lack of any readily available already free pages.  Dirty file system pages
385 are repurposed by first writing them to disk.  Unmodified file system buffer
386 pages are repurposed by simply dropping them, though if that page is needed
387 again, it will have to be reread from disk.
388 .PP
389 .\" ================== Memory Spread ==================
390 The \fImemory_pressure\fP file provides an integer number representing the
391 recent (half\-life of 10 seconds) rate of entries to the direct reclaim code
392 caused by any process in the cpuset, in units of reclaims attempted per
393 second, times 1000.
394 .SS "Memory Spread"
395 There are two Boolean flag files per cpuset that control where the kernel
396 allocates pages for the file\-system buffers and related in\-kernel data
397 structures.  They are called \fImemory_spread_page\fP and
398 \fImemory_spread_slab\fP.
399 .PP
400 If the per\-cpuset Boolean flag file \fImemory_spread_page\fP is set, then the
401 kernel will spread the file\-system buffers (page cache) evenly over all the
402 nodes that the faulting process is allowed to use, instead of preferring to
403 put those pages on the node where the process is running.
404 .PP
405 If the per\-cpuset Boolean flag file \fImemory_spread_slab\fP is set, then the
406 kernel will spread some file\-system\-related slab caches, such as those for
407 inodes and directory entries, evenly over all the nodes that the faulting
408 process is allowed to use, instead of preferring to put those pages on the
409 node where the process is running.
410 .PP
411 The setting of these flags does not affect the data segment (see \fBbrk\fP(2))
412 or stack segment pages of a process.
413 .PP
414 By default, both kinds of memory spreading are off and the kernel prefers to
415 allocate memory pages on the node local to where the requesting process is
416 running.  If that node is not allowed by the process's NUMA memory policy or
417 cpuset configuration or if there are insufficient free memory pages on that
418 node, then the kernel looks for the nearest node that is allowed and has
419 sufficient free memory.
420 .PP
421 When new cpusets are created, they inherit the memory spread settings of
422 their parent.
423 .PP
424 Setting memory spreading causes allocations for the affected page or slab
425 caches to ignore the process's NUMA memory policy and be spread instead.
426 However, the effect of these changes in memory placement caused by
427 cpuset\-specified memory spreading is hidden from the \fBmbind\fP(2)  or
428 \fBset_mempolicy\fP(2)  calls.  These two NUMA memory policy calls always
429 appear to behave as if no cpuset\-specified memory spreading is in effect,
430 even if it is.  If cpuset memory spreading is subsequently turned off, the
431 NUMA memory policy most recently specified by these calls is automatically
432 reapplied.
433 .PP
434 Both \fImemory_spread_page\fP and \fImemory_spread_slab\fP are Boolean flag
435 files.  By default they contain "0", meaning that the feature is off for
436 that cpuset.  If a "1" is written to that file, that turns the named feature
437 on.
438 .PP
439 Cpuset\-specified memory spreading behaves similarly to what is known (in
440 other contexts) as round\-robin or interleave memory placement.
441 .PP
442 Cpuset\-specified memory spreading can provide substantial performance
443 improvements for jobs that:
444 .IP a) 3
445 need to place thread\-local data on memory nodes close to the CPUs which are
446 running the threads that most frequently access that data; but also
447 .IP b)
448 need to access large file\-system data sets that must to be spread across the
449 several nodes in the job's cpuset in order to fit.
450 .PP
451 .\" ================== Memory Migration ==================
452 Without this policy, the memory allocation across the nodes in the job's
453 cpuset can become very uneven, especially for jobs that might have just a
454 single thread initializing or reading in the data set.
455 .SS "Memory Migration"
456 Normally, under the default setting (disabled) of \fImemory_migrate\fP, once a
457 page is allocated (given a physical page of main memory) then that page
458 stays on whatever node it was allocated, so long as it remains allocated,
459 even if the cpuset's memory\-placement policy \fImems\fP subsequently changes.
460 .PP
461 When memory migration is enabled in a cpuset, if the \fImems\fP setting of the
462 cpuset is changed, then any memory page in use by any process in the cpuset
463 that is on a memory node that is no longer allowed will be migrated to a
464 memory node that is allowed.
465 .PP
466 Furthermore, if a process is moved into a cpuset with \fImemory_migrate\fP
467 enabled, any memory pages it uses that were on memory nodes allowed in its
468 previous cpuset, but which are not allowed in its new cpuset, will be
469 migrated to a memory node allowed in the new cpuset.
470 .PP
471 .\" ================== Scheduler Load Balancing ==================
472 The relative placement of a migrated page within the cpuset is preserved
473 during these migration operations if possible.  For example, if the page was
474 on the second valid node of the prior cpuset, then the page will be placed
475 on the second valid node of the new cpuset, if possible.
476 .SS "Scheduler Load Balancing"
477 The kernel scheduler automatically load balances processes.  If one CPU is
478 underutilized, the kernel will look for processes on other more overloaded
479 CPUs and move those processes to the underutilized CPU, within the
480 constraints of such placement mechanisms as cpusets and
481 \fBsched_setaffinity\fP(2).
482 .PP
483 The algorithmic cost of load balancing and its impact on key shared kernel
484 data structures such as the process list increases more than linearly with
485 the number of CPUs being balanced.  For example, it costs more to load
486 balance across one large set of CPUs than it does to balance across two
487 smaller sets of CPUs, each of half the size of the larger set.  (The precise
488 relationship between the number of CPUs being balanced and the cost of load
489 balancing depends on implementation details of the kernel process scheduler,
490 which is subject to change over time, as improved kernel scheduler
491 algorithms are implemented.)
492 .PP
493 The per\-cpuset flag \fIsched_load_balance\fP provides a mechanism to suppress
494 this automatic scheduler load balancing in cases where it is not needed and
495 suppressing it would have worthwhile performance benefits.
496 .PP
497 By default, load balancing is done across all CPUs, except those marked
498 isolated using the kernel boot time "isolcpus=" argument.  (See \fBScheduler
499 Relax Domain Level\fP, below, to change this default.)
500 .PP
501 This default load balancing across all CPUs is not well suited to the
502 following two situations:
503 .IP * 3
504 On large systems, load balancing across many CPUs is expensive.  If the
505 system is managed using cpusets to place independent jobs on separate sets
506 of CPUs, full load balancing is unnecessary.
507 .IP *
508 Systems supporting real\-time on some CPUs need to minimize system overhead
509 on those CPUs, including avoiding process load balancing if that is not
510 needed.
511 .PP
512 When the per\-cpuset flag \fIsched_load_balance\fP is enabled (the default
513 setting), it requests load balancing across all the CPUs in that cpuset's
514 allowed CPUs, ensuring that load balancing can move a process (not otherwise
515 pinned, as by \fBsched_setaffinity\fP(2))  from any CPU in that cpuset to any
516 other.
517 .PP
518 When the per\-cpuset flag \fIsched_load_balance\fP is disabled, then the
519 scheduler will avoid load balancing across the CPUs in that cpuset,
520 \fIexcept\fP in so far as is necessary because some overlapping cpuset has
521 \fIsched_load_balance\fP enabled.
522 .PP
523 So, for example, if the top cpuset has the flag \fIsched_load_balance\fP
524 enabled, then the scheduler will load balance across all CPUs, and the
525 setting of the \fIsched_load_balance\fP flag in other cpusets has no effect, as
526 we're already fully load balancing.
527 .PP
528 Therefore in the above two situations, the flag \fIsched_load_balance\fP should
529 be disabled in the top cpuset, and only some of the smaller, child cpusets
530 would have this flag enabled.
531 .PP
532 When doing this, you don't usually want to leave any unpinned processes in
533 the top cpuset that might use nontrivial amounts of CPU, as such processes
534 may be artificially constrained to some subset of CPUs, depending on the
535 particulars of this flag setting in descendant cpusets.  Even if such a
536 process could use spare CPU cycles in some other CPUs, the kernel scheduler
537 might not consider the possibility of load balancing that process to the
538 underused CPU.
539 .PP
540 .\" ================== Scheduler Relax Domain Level ==================
541 Of course, processes pinned to a particular CPU can be left in a cpuset that
542 disables \fIsched_load_balance\fP as those processes aren't going anywhere else
543 anyway.
544 .SS "Scheduler Relax Domain Level"
545 The kernel scheduler performs immediate load balancing whenever a CPU
546 becomes free or another task becomes runnable.  This load balancing works to
547 ensure that as many CPUs as possible are usefully employed running tasks.
548 The kernel also performs periodic load balancing off the software clock
549 described in \fItime\fP(7).  The setting of \fIsched_relax_domain_level\fP only
550 applies to immediate load balancing.  Regardless of the
551 \fIsched_relax_domain_level\fP setting, periodic load balancing is attempted
552 over all CPUs (unless disabled by turning off \fIsched_load_balance\fP.)  In
553 any case, of course, tasks will only be scheduled to run on CPUs allowed by
554 their cpuset, as modified by \fBsched_setaffinity\fP(2)  system calls.
555 .PP
556 On small systems, such as those with just a few CPUs, immediate load
557 balancing is useful to improve system interactivity and to minimize wasteful
558 idle CPU cycles.  But on large systems, attempting immediate load balancing
559 across a large number of CPUs can be more costly than it is worth, depending
560 on the particular performance characteristics of the job mix and the
561 hardware.
562 .PP
563 The exact meaning of the small integer values of \fIsched_relax_domain_level\fP
564 will depend on internal implementation details of the kernel scheduler code
565 and on the non\-uniform architecture of the hardware.  Both of these will
566 evolve over time and vary by system architecture and kernel version.
567 .PP
568 As of this writing, when this capability was introduced in Linux 2.6.26, on
569 certain popular architectures, the positive values of
570 \fIsched_relax_domain_level\fP have the following meanings.
571 .sp
572 .PD 0
573 .IP \fB(1)\fP 4
574 Perform immediate load balancing across Hyper\-Thread siblings on the same
575 core.
576 .IP \fB(2)\fP
577 Perform immediate load balancing across other cores in the same package.
578 .IP \fB(3)\fP
579 Perform immediate load balancing across other CPUs on the same node or
580 blade.
581 .IP \fB(4)\fP
582 Perform immediate load balancing across over several (implementation detail)
583 nodes [On NUMA systems].
584 .IP \fB(5)\fP
585 Perform immediate load balancing across over all CPUs in system [On NUMA
586 systems].
587 .PD
588 .PP
589 The \fIsched_relax_domain_level\fP value of zero (0) always means don't perform
590 immediate load balancing, hence that load balancing is only done
591 periodically, not immediately when a CPU becomes available or another task
592 becomes runnable.
593 .PP
594 The \fIsched_relax_domain_level\fP value of minus one (\-1)  always means use
595 the system default value.  The system default value can vary by architecture
596 and kernel version.  This system default value can be changed by kernel
597 boot\-time "relax_domain_level=" argument.
598 .PP
599 In the case of multiple overlapping cpusets which have conflicting
600 \fIsched_relax_domain_level\fP values, then the highest such value applies to
601 all CPUs in any of the overlapping cpusets.  In such cases, the value
602 \fBminus one (\-1)\fP is the lowest value, overridden by any other value, and
603 the value \fBzero (0)\fP is the next lowest value.
604 .SH FORMATS
605 .\" ================== Mask Format ==================
606 The following formats are used to represent sets of CPUs and memory nodes.
607 .SS "Mask Format"
608 The \fBMask Format\fP is used to represent CPU and memory\-node bitmasks in the
609 \fI/proc/<pid>/status\fP file.
610 .PP
611 This format displays each 32\-bit word in hexadecimal (using ASCII characters
612 "0" \- "9" and "a" \- "f"); words are filled with leading zeros, if required.
613 For masks longer than one word, a comma separator is used between words.
614 Words are displayed in big\-endian order, which has the most significant bit
615 first.  The hex digits within a word are also in big\-endian order.
616 .PP
617 The number of 32\-bit words displayed is the minimum number needed to display
618 all bits of the bitmask, based on the size of the bitmask.
619 .PP
620 Examples of the \fBMask Format\fP:
621 .PP
622 .RS
623 .nf
624 00000001                        # just bit 0 set
625 40000000,00000000,00000000      # just bit 94 set
626 00000001,00000000,00000000      # just bit 64 set
627 000000ff,00000000               # bits 32\-39 set
628 00000000,000E3862               # 1,5,6,11\-13,17\-19 set
629 .fi
630 .RE
631 .PP
632 A mask with bits 0, 1, 2, 4, 8, 16, 32, and 64 set displays as:
633 .PP
634 .RS
635 .nf
636 00000001,00000001,00010117
637 .fi
638 .RE
639 .PP
640 .\" ================== List Format ==================
641 The first "1" is for bit 64, the second for bit 32, the third for bit 16,
642 the fourth for bit 8, the fifth for bit 4, and the "7" is for bits 2, 1, and
643 0.
644 .SS "List Format"
645 The \fBList Format\fP for \fIcpus\fP and \fImems\fP is a comma\-separated list of CPU
646 or memory\-node numbers and ranges of numbers, in ASCII decimal.
647 .PP
648 Examples of the \fBList Format\fP:
649 .PP
650 .RS
651 .nf
652 0\-4,9           # bits 0, 1, 2, 3, 4, and 9 set
653 0\-2,7,12\-14     # bits 0, 1, 2, 7, 12, 13, and 14 set
654 .fi
655 .RE
656 .\" ================== RULES ==================
657 .SH RULES
658 The following rules apply to each cpuset:
659 .IP * 3
660 Its CPUs and memory nodes must be a (possibly equal)  subset of its
661 parent's.
662 .IP *
663 It can only be marked \fIcpu_exclusive\fP if its parent is.
664 .IP *
665 It can only be marked \fImem_exclusive\fP if its parent is.
666 .IP *
667 If it is \fIcpu_exclusive\fP, its CPUs may not overlap any sibling.
668 .IP *
669 .\" ================== PERMISSIONS ==================
670 If it is \fImemory_exclusive\fP, its memory nodes may not overlap any sibling.
671 .SH PERMISSIONS
672 The permissions of a cpuset are determined by the permissions of the
673 directories and pseudo\-files in the cpuset file system, normally mounted at
674 \fI/dev/cpuset\fP.
675 .PP
676 For instance, a process can put itself in some other cpuset (than its
677 current one) if it can write the \fItasks\fP file for that cpuset.  This
678 requires execute permission on the encompassing directories and write
679 permission on the \fItasks\fP file.
680 .PP
681 An additional constraint is applied to requests to place some other process
682 in a cpuset.  One process may not attach another to a cpuset unless it would
683 have permission to send that process a signal (see \fBkill\fP(2)).
684 .PP
685 A process may create a child cpuset if it can access and write the parent
686 cpuset directory.  It can modify the CPUs or memory nodes in a cpuset if it
687 can access that cpuset's directory (execute permissions on the each of the
688 parent directories) and write the corresponding \fIcpus\fP or \fImems\fP file.
689 .PP
690 There is one minor difference between the manner in which these permissions
691 are evaluated and the manner in which normal file\-system operation
692 permissions are evaluated.  The kernel interprets relative pathnames
693 starting at a process's current working directory.  Even if one is operating
694 on a cpuset file, relative pathnames are interpreted relative to the
695 process's current working directory, not relative to the process's current
696 cpuset.  The only ways that cpuset paths relative to a process's current
697 cpuset can be used are if either the process's current working directory is
698 its cpuset (it first did a \fBcd\fP or \fBchdir\fP(2)  to its cpuset directory
699 beneath \fI/dev/cpuset\fP, which is a bit unusual)  or if some user code
700 converts the relative cpuset path to a full file\-system path.
701 .PP
702 .\" ================== WARNINGS ==================
703 In theory, this means that user code should specify cpusets using absolute
704 pathnames, which requires knowing the mount point of the cpuset file system
705 (usually, but not necessarily, \fI/dev/cpuset\fP).  In practice, all user level
706 code that this author is aware of simply assumes that if the cpuset file
707 system is mounted, then it is mounted at \fI/dev/cpuset\fP.  Furthermore, it is
708 common practice for carefully written user code to verify the presence of
709 the pseudo\-file \fI/dev/cpuset/tasks\fP in order to verify that the cpuset
710 pseudo\-file system is currently mounted.
711 .SH WARNINGS
712 .SS "Enabling memory_pressure"
713 By default, the per\-cpuset file \fImemory_pressure\fP always contains zero
714 (0).  Unless this feature is enabled by writing "1" to the pseudo\-file
715 \fI/dev/cpuset/memory_pressure_enabled\fP, the kernel does not compute
716 per\-cpuset \fImemory_pressure\fP.
717 .SS "Using the echo command"
718 .\" Gack!  csh(1)'s echo does this
719 When using the \fBecho\fP command at the shell prompt to change the values of
720 cpuset files, beware that the built\-in \fBecho\fP command in some shells does
721 not display an error message if the \fBwrite\fP(2)  system call fails.  For
722 example, if the command:
723 .in +4n
724 .nf
725
726 echo 19 > mems
727
728 .fi
729 .in
730 failed because memory node 19 was not allowed (perhaps the current system
731 does not have a memory node 19), then the \fBecho\fP command might not display
732 any error.  It is better to use the \fB/bin/echo\fP external command to change
733 cpuset file settings, as this command will display \fBwrite\fP(2)  errors, as
734 in the example:
735 .in +4n
736 .nf
737
738 /bin/echo 19 > mems
739 /bin/echo: write error: Invalid argument
740 .fi
741 .in
742 .\" ================== EXCEPTIONS ==================
743 .SH EXCEPTIONS
744 .SS "Memory placement"
745 Not all allocations of system memory are constrained by cpusets, for the
746 following reasons.
747 .PP
748 If hot\-plug functionality is used to remove all the CPUs that are currently
749 assigned to a cpuset, then the kernel will automatically update the
750 \fIcpus_allowed\fP of all processes attached to CPUs in that cpuset to allow
751 all CPUs.  When memory hot\-plug functionality for removing memory nodes is
752 available, a similar exception is expected to apply there as well.  In
753 general, the kernel prefers to violate cpuset placement, rather than
754 starving a process that has had all its allowed CPUs or memory nodes taken
755 offline.  User code should reconfigure cpusets to only refer to online CPUs
756 and memory nodes when using hot\-plug to add or remove such resources.
757 .PP
758 A few kernel\-critical, internal memory\-allocation requests, marked
759 GFP_ATOMIC, must be satisfied immediately.  The kernel may drop some request
760 or malfunction if one of these allocations fail.  If such a request cannot
761 be satisfied within the current process's cpuset, then we relax the cpuset,
762 and look for memory anywhere we can find it.  It's better to violate the
763 cpuset than stress the kernel.
764 .PP
765 Allocations of memory requested by kernel drivers while processing an
766 interrupt lack any relevant process context, and are not confined by
767 cpusets.
768 .SS "Renaming cpusets"
769 .\" ================== ERRORS ==================
770 You can use the \fBrename\fP(2)  system call to rename cpusets.  Only simple
771 renaming is supported; that is, changing the name of a cpuset directory is
772 permitted, but moving a directory into a different directory is not
773 permitted.
774 .SH エラー
775 The Linux kernel implementation of cpusets sets \fIerrno\fP to specify the
776 reason for a failed system call affecting cpusets.
777 .PP
778 The possible \fIerrno\fP settings and their meaning when set on a failed cpuset
779 call are as listed below.
780 .TP 
781 \fBE2BIG\fP
782 Attempted a \fBwrite\fP(2)  on a special cpuset file with a length larger than
783 some kernel\-determined upper limit on the length of such writes.
784 .TP 
785 \fBEACCES\fP
786 Attempted to \fBwrite\fP(2)  the process ID (PID) of a process to a cpuset
787 \fItasks\fP file when one lacks permission to move that process.
788 .TP 
789 \fBEACCES\fP
790 Attempted to add, using \fBwrite\fP(2), a CPU or memory node to a cpuset, when
791 that CPU or memory node was not already in its parent.
792 .TP 
793 \fBEACCES\fP
794 Attempted to set, using \fBwrite\fP(2), \fIcpu_exclusive\fP or \fImem_exclusive\fP on
795 a cpuset whose parent lacks the same setting.
796 .TP 
797 \fBEACCES\fP
798 Attempted to \fBwrite\fP(2)  a \fImemory_pressure\fP file.
799 .TP 
800 \fBEACCES\fP
801 Attempted to create a file in a cpuset directory.
802 .TP 
803 \fBEBUSY\fP
804 Attempted to remove, using \fBrmdir\fP(2), a cpuset with attached processes.
805 .TP 
806 \fBEBUSY\fP
807 Attempted to remove, using \fBrmdir\fP(2), a cpuset with child cpusets.
808 .TP 
809 \fBEBUSY\fP
810 Attempted to remove a CPU or memory node from a cpuset that is also in a
811 child of that cpuset.
812 .TP 
813 \fBEEXIST\fP
814 Attempted to create, using \fBmkdir\fP(2), a cpuset that already exists.
815 .TP 
816 \fBEEXIST\fP
817 Attempted to \fBrename\fP(2)  a cpuset to a name that already exists.
818 .TP 
819 \fBEFAULT\fP
820 Attempted to \fBread\fP(2)  or \fBwrite\fP(2)  a cpuset file using a buffer that
821 is outside the writing processes accessible address space.
822 .TP 
823 \fBEINVAL\fP
824 Attempted to change a cpuset, using \fBwrite\fP(2), in a way that would violate
825 a \fIcpu_exclusive\fP or \fImem_exclusive\fP attribute of that cpuset or any of
826 its siblings.
827 .TP 
828 \fBEINVAL\fP
829 Attempted to \fBwrite\fP(2)  an empty \fIcpus\fP or \fImems\fP list to a cpuset which
830 has attached processes or child cpusets.
831 .TP 
832 \fBEINVAL\fP
833 Attempted to \fBwrite\fP(2)  a \fIcpus\fP or \fImems\fP list which included a range
834 with the second number smaller than the first number.
835 .TP 
836 \fBEINVAL\fP
837 Attempted to \fBwrite\fP(2)  a \fIcpus\fP or \fImems\fP list which included an
838 invalid character in the string.
839 .TP 
840 \fBEINVAL\fP
841 Attempted to \fBwrite\fP(2)  a list to a \fIcpus\fP file that did not include any
842 online CPUs.
843 .TP 
844 \fBEINVAL\fP
845 Attempted to \fBwrite\fP(2)  a list to a \fImems\fP file that did not include any
846 online memory nodes.
847 .TP 
848 \fBEINVAL\fP
849 Attempted to \fBwrite\fP(2)  a list to a \fImems\fP file that included a node that
850 held no memory.
851 .TP 
852 \fBEIO\fP
853 Attempted to \fBwrite\fP(2)  a string to a cpuset \fItasks\fP file that does not
854 begin with an ASCII decimal integer.
855 .TP 
856 \fBEIO\fP
857 Attempted to \fBrename\fP(2)  a cpuset into a different directory.
858 .TP 
859 \fBENAMETOOLONG\fP
860 Attempted to \fBread\fP(2)  a \fI/proc/<pid>/cpuset\fP file for a cpuset
861 path that is longer than the kernel page size.
862 .TP 
863 \fBENAMETOOLONG\fP
864 Attempted to create, using \fBmkdir\fP(2), a cpuset whose base directory name
865 is longer than 255 characters.
866 .TP 
867 \fBENAMETOOLONG\fP
868 Attempted to create, using \fBmkdir\fP(2), a cpuset whose full pathname,
869 including the mount point (typically "/dev/cpuset/") prefix, is longer than
870 4095 characters.
871 .TP 
872 \fBENODEV\fP
873 The cpuset was removed by another process at the same time as a \fBwrite\fP(2)
874 was attempted on one of the pseudo\-files in the cpuset directory.
875 .TP 
876 \fBENOENT\fP
877 Attempted to create, using \fBmkdir\fP(2), a cpuset in a parent cpuset that
878 doesn't exist.
879 .TP 
880 \fBENOENT\fP
881 Attempted to \fBaccess\fP(2)  or \fBopen\fP(2)  a nonexistent file in a cpuset
882 directory.
883 .TP 
884 \fBENOMEM\fP
885 Insufficient memory is available within the kernel; can occur on a variety
886 of system calls affecting cpusets, but only if the system is extremely short
887 of memory.
888 .TP 
889 \fBENOSPC\fP
890 Attempted to \fBwrite\fP(2)  the process ID (PID)  of a process to a cpuset
891 \fItasks\fP file when the cpuset had an empty \fIcpus\fP or empty \fImems\fP setting.
892 .TP 
893 \fBENOSPC\fP
894 Attempted to \fBwrite\fP(2)  an empty \fIcpus\fP or \fImems\fP setting to a cpuset
895 that has tasks attached.
896 .TP 
897 \fBENOTDIR\fP
898 Attempted to \fBrename\fP(2)  a nonexistent cpuset.
899 .TP 
900 \fBEPERM\fP
901 Attempted to remove a file from a cpuset directory.
902 .TP 
903 \fBERANGE\fP
904 Specified a \fIcpus\fP or \fImems\fP list to the kernel which included a number
905 too large for the kernel to set in its bitmasks.
906 .TP 
907 \fBESRCH\fP
908 .\" ================== VERSIONS ==================
909 Attempted to \fBwrite\fP(2)  the process ID (PID) of a nonexistent process to a
910 cpuset \fItasks\fP file.
911 .SH バージョン
912 .\" ================== NOTES ==================
913 Cpusets appeared in version 2.6.12 of the Linux kernel.
914 .SH 注意
915 .\" ================== BUGS ==================
916 Despite its name, the \fIpid\fP parameter is actually a thread ID, and each
917 thread in a threaded group can be attached to a different cpuset.  The value
918 returned from a call to \fBgettid\fP(2)  can be passed in the argument \fIpid\fP.
919 .SH バグ
920 .\" ================== EXAMPLE ==================
921 \fImemory_pressure\fP cpuset files can be opened for writing, creation, or
922 truncation, but then the \fBwrite\fP(2)  fails with \fIerrno\fP set to \fBEACCES\fP,
923 and the creation and truncation options on \fBopen\fP(2)  have no effect.
924 .SH EXAMPLE
925 The following examples demonstrate querying and setting cpuset options using
926 shell commands.
927 .SS "Creating and attaching to a cpuset."
928 To create a new cpuset and attach the current command shell to it, the steps
929 are:
930 .sp
931 .PD 0
932 .IP 1) 4
933 mkdir /dev/cpuset (if not already done)
934 .IP 2)
935 mount \-t cpuset none /dev/cpuset (if not already done)
936 .IP 3)
937 Create the new cpuset using \fBmkdir\fP(1).
938 .IP 4)
939 Assign CPUs and memory nodes to the new cpuset.
940 .IP 5)
941 Attach the shell to the new cpuset.
942 .PD
943 .PP
944 For example, the following sequence of commands will set up a cpuset named
945 "Charlie", containing just CPUs 2 and 3, and memory node 1, and then attach
946 the current shell to that cpuset.
947 .in +4n
948 .nf
949
950 $\fB mkdir /dev/cpuset\fP
951 $\fB mount \-t cpuset cpuset /dev/cpuset\fP
952 $\fB cd /dev/cpuset\fP
953 $\fB mkdir Charlie\fP
954 $\fB cd Charlie\fP
955 $\fB /bin/echo 2\-3 > cpus\fP
956 $\fB /bin/echo 1 > mems\fP
957 $\fB /bin/echo $$ > tasks\fP
958 # The current shell is now running in cpuset Charlie
959 # The next line should display '/Charlie'
960 $\fB cat /proc/self/cpuset\fP
961 .fi
962 .in
963 .SS "Migrating a job to different memory nodes."
964 To migrate a job (the set of processes attached to a cpuset)  to different
965 CPUs and memory nodes in the system, including moving the memory pages
966 currently allocated to that job, perform the following steps.
967 .sp
968 .PD 0
969 .IP 1) 4
970 Let's say we want to move the job in cpuset \fIalpha\fP (CPUs 4\-7 and memory
971 nodes 2\-3) to a new cpuset \fIbeta\fP (CPUs 16\-19 and memory nodes 8\-9).
972 .IP 2)
973 First create the new cpuset \fIbeta\fP.
974 .IP 3)
975 Then allow CPUs 16\-19 and memory nodes 8\-9 in \fIbeta\fP.
976 .IP 4)
977 Then enable \fImemory_migration\fP in \fIbeta\fP.
978 .IP 5)
979 Then move each process from \fIalpha\fP to \fIbeta\fP.
980 .PD
981 .PP
982 The following sequence of commands accomplishes this.
983 .in +4n
984 .nf
985
986 $\fB cd /dev/cpuset\fP
987 $\fB mkdir beta\fP
988 $\fB cd beta\fP
989 $\fB /bin/echo 16\-19 > cpus\fP
990 $\fB /bin/echo 8\-9 > mems\fP
991 $\fB /bin/echo 1 > memory_migrate\fP
992 $\fB while read i; do /bin/echo $i; done < ../alpha/tasks > tasks\fP
993 .fi
994 .in
995 .PP
996 The above should move any processes in \fIalpha\fP to \fIbeta\fP, and any memory
997 held by these processes on memory nodes 2\-3 to memory nodes 8\-9,
998 respectively.
999 .PP
1000 Notice that the last step of the above sequence did not do:
1001 .in +4n
1002 .nf
1003
1004 $\fB cp ../alpha/tasks tasks\fP
1005 .fi
1006 .in
1007 .PP
1008 The \fIwhile\fP loop, rather than the seemingly easier use of the \fBcp\fP(1)
1009 command, was necessary because only one process PID at a time may be written
1010 to the \fItasks\fP file.
1011 .PP
1012 The same effect (writing one PID at a time) as the \fIwhile\fP loop can be
1013 accomplished more efficiently, in fewer keystrokes and in syntax that works
1014 on any shell, but alas more obscurely, by using the \fB\-u\fP (unbuffered)
1015 option of \fBsed\fP(1):
1016 .in +4n
1017
1018 .nf
1019 $\fB sed \-un p < ../alpha/tasks > tasks\fP
1020 .fi
1021 .in
1022 .\" ================== SEE ALSO ==================
1023 .SH 関連項目
1024 \fBtaskset\fP(1), \fBget_mempolicy\fP(2), \fBgetcpu\fP(2), \fBmbind\fP(2),
1025 \fBsched_getaffinity\fP(2), \fBsched_setaffinity\fP(2), \fBsched_setscheduler\fP(2),
1026 \fBset_mempolicy\fP(2), \fBCPU_SET\fP(3), \fBproc\fP(5), \fBnuma\fP(7),
1027 \fBmigratepages\fP(8), \fBnumactl\fP(8)
1028 .PP
1029 The kernel source file \fIDocumentation/cpusets.txt\fP.