Lines Matching +full:in +full:- +full:memory
11 - Portions Copyright (c) 2004-2006 Silicon Graphics, Inc.
12 - Modified by Paul Jackson <pj@sgi.com>
13 - Modified by Christoph Lameter <cl@linux.com>
14 - Modified by Paul Menage <menage@google.com>
15 - Modified by Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
25 1.6 What is memory spread ?
41 ----------------------
43 Cpusets provide a mechanism for assigning a set of CPUs and Memory
44 Nodes to a set of tasks. In this document "Memory Node" refers to
45 an on-line node that contains memory.
47 Cpusets constrain the CPU and Memory placement of tasks to only
49 hierarchy visible in a virtual file system. These are the essential
53 Cpusets use the generic cgroup subsystem described in
54 Documentation/admin-guide/cgroup-v1/cgroups.rst.
57 include CPUs in its CPU affinity mask, and using the mbind(2) and
58 set_mempolicy(2) system calls to include Memory Nodes in its memory
60 CPUs or Memory Nodes not in that cpuset. The scheduler will not
61 schedule a task on a CPU that is not allowed in its cpus_allowed
63 node that is not allowed in the requesting task's mems_allowed vector.
65 User level code may create and destroy cpusets by name in the cgroup
67 cpusets and which CPUs and Memory Nodes are assigned to each cpuset,
73 ----------------------------
76 complex memory cache hierarchies and multiple Memory Nodes having
77 non-uniform access times (NUMA) presents additional challenges for
78 the efficient scheduling and memory placement of processes.
82 the available CPU and Memory resources amongst the requesting tasks.
85 memory placement to reduce memory access times and contention,
101 when the memory locations are changed.
105 leverages existing CPU and Memory Placement facilities in the Linux
107 memory allocator code.
111 ---------------------------------
114 Memory Nodes are used by a process or set of processes.
117 CPUs a task may be scheduled (sched_setaffinity) and on which Memory
118 Nodes it may obtain memory (mbind, set_mempolicy).
122 - Cpusets are sets of allowed CPUs and Memory Nodes, known to the
124 - Each task in the system is attached to a cpuset, via a pointer
125 in the task structure to a reference counted cgroup structure.
126 - Calls to sched_setaffinity are filtered to just those CPUs
127 allowed in that task's cpuset.
128 - Calls to mbind and set_mempolicy are filtered to just
129 those Memory Nodes allowed in that task's cpuset.
130 - The root cpuset contains all the systems CPUs and Memory
132 - For any cpuset, one can define child cpusets containing a subset
133 of the parents CPU and Memory Node resources.
134 - The hierarchy of cpusets can be mounted at /dev/cpuset, for
136 - A cpuset may be marked exclusive, which ensures that no other
138 any overlapping CPUs or Memory Nodes.
139 - You can list all the tasks (by pid) attached to any cpuset.
142 into the rest of the kernel, none in performance critical paths:
144 - in init/main.c, to initialize the root cpuset at system boot.
145 - in fork and exit, to attach and detach a task from its cpuset.
146 - in sched_setaffinity, to mask the requested CPUs by what's
147 allowed in that task's cpuset.
148 - in sched.c migrate_live_tasks(), to keep migrating tasks within
150 - in the mbind and set_mempolicy system calls, to mask the requested
151 Memory Nodes by what's allowed in that task's cpuset.
152 - in page_alloc.c, to restrict memory to allowed nodes.
153 - in vmscan.c, to restrict page recovery to the current cpuset.
155 You should mount the "cgroup" filesystem type in order to enable
157 new system calls are added for cpusets - all support for querying and
162 and mems_allowed (on which Memory Nodes it may obtain memory),
163 in the two formats seen in the following example::
166 Cpus_allowed_list: 0-127
168 Mems_allowed_list: 0-63
170 Each cpuset is represented by a directory in the cgroup file system
174 - cpuset.cpus: list of CPUs in that cpuset
175 - cpuset.mems: list of Memory Nodes in that cpuset
176 - cpuset.memory_migrate flag: if set, move pages to cpusets nodes
177 - cpuset.cpu_exclusive flag: is cpu placement exclusive?
178 - cpuset.mem_exclusive flag: is memory placement exclusive?
179 - cpuset.mem_hardwall flag: is memory allocation hardwalled
180 - cpuset.memory_pressure: measure of how much paging pressure in cpuset
181 - cpuset.memory_spread_page flag: if set, spread page cache evenly on allowed nodes
182 - cpuset.memory_spread_slab flag: if set, spread slab cache evenly on allowed nodes
183 - cpuset.sched_load_balance flag: if set, load balance within CPUs on that cpuset
184 - cpuset.sched_relax_domain_level: the searching range when migrating tasks
186 In addition, only the root cpuset has the following file:
188 - cpuset.memory_pressure_enabled flag: compute memory_pressure?
192 CPUs and Memory Nodes, and attached tasks, are modified by writing
193 to the appropriate file in that cpusets directory, as listed above.
196 a large system into nested, dynamically changeable, "soft-partitions".
201 to using the CPUs and Memory Nodes of a particular cpuset. A task
202 may be re-attached to any other cpuset, if allowed by the permissions
205 Such management of a system "in the large" integrates smoothly with
206 the detailed placement done on individual tasks and memory regions
211 - Its CPUs and Memory Nodes must be a subset of its parents.
212 - It can't be marked exclusive unless its parent is.
213 - If its cpu or memory is exclusive, they may not overlap any sibling.
222 The cpus and mems files in the root (top_cpuset) cpuset are
223 read-only. The cpus file automatically tracks the value of
225 automatically tracks the value of node_states[N_MEMORY]--i.e.,
226 nodes with memory--using the cpuset_track_online_nodes() hook.
229 normally read-only copies of cpuset.cpus and cpuset.mems files
232 similar to the corresponding files in cpuset v2. In other words, hotplug
235 the actual cpus and memory nodes that are currently used by this cpuset.
236 See Documentation/admin-guide/cgroup-v2.rst for more information about
241 --------------------------------
245 Memory Nodes.
250 whether hardwalled or not, restrict allocations of memory for user
253 isolating each job's user allocation in its own cpuset. To do this,
255 construct child, non-mem_exclusive cpusets for each individual job.
256 Only a small amount of typical kernel memory, such as requests from
262 -----------------------------
263 The memory_pressure of a cpuset provides a simple per-cpuset metric
264 of the rate that the tasks in a cpuset are attempting to free up in
265 use memory on the nodes of the cpuset to satisfy additional memory
268 This enables batch managers monitoring jobs running in dedicated
269 cpusets to efficiently detect what level of memory pressure that job
273 submitted jobs, which may choose to terminate or re-prioritize jobs that
274 are trying to use more memory than allowed on the nodes assigned to them,
277 goals if they start to use more memory than allowed to them.
280 to monitor a cpuset for signs of memory pressure. It's up to the
286 /dev/cpuset/memory_pressure_enabled, the hook in the rebalance
291 Why a per-cpuset, running average:
293 Because this meter is per-cpuset, rather than per-task or mm,
299 counter, a batch scheduler can detect memory pressure with a
303 Because this meter is per-cpuset rather than per-task or mm,
304 the batch scheduler can obtain the key information, memory
305 pressure in a cpuset, with a single read, rather than having to
307 set of tasks in the cpuset.
309 A per-cpuset simple digital filter (requires a spinlock and 3 words
310 of data per-cpuset) is kept, and updated by any task attached to that
313 A per-cpuset file provides an integer number representing the recent
314 (half-life of 10 seconds) rate of direct page reclaims caused by
315 the tasks in the cpuset, in units of reclaims attempted per second,
319 1.6 What is memory spread ?
320 ---------------------------
322 kernel allocates pages for the file system buffers and related in
326 If the per-cpuset boolean flag file 'cpuset.memory_spread_page' is set, then
331 If the per-cpuset boolean flag file 'cpuset.memory_spread_slab' is set,
340 By default, both kinds of memory spreading are off, and memory
343 configuration, so long as sufficient free memory pages are available.
345 When new cpusets are created, they inherit the memory spread settings
348 Setting memory spreading causes allocations for the affected page
351 mempolicies will not notice any change in these calls as a result of
352 their containing task's memory spread settings. If memory spreading
354 applies to memory page allocations.
363 Setting the flag 'cpuset.memory_spread_page' turns on a per-process flag
364 PFA_SPREAD_PAGE for each task that is in that cpuset or subsequently
375 value of a per-task rotor cpuset_mem_spread_rotor to select the next
376 node in the current task's mems_allowed to prefer for the allocation.
378 This memory placement policy is also known (in other contexts) as
379 round-robin or interleave.
384 the several nodes in the jobs cpuset in order to fit. Without this
385 policy, especially for jobs that might have one thread reading in the
386 data set, the memory allocation across the nodes in the jobs cpuset
390 --------------------------------
403 Each sched domain covers some subset of the CPUs in the system;
404 no two sched domains overlap; some CPUs might not be in any sched
408 than one big one, but doing so means that overloads in one of the
413 the isolated CPUs will not participate in load balancing, and will not
426 When the per-cpuset flag "cpuset.sched_load_balance" is enabled (the default
427 setting), it requests that all the CPUs in that cpusets allowed 'cpuset.cpus'
428 be contained in a single sched domain, ensuring that load balancing
430 from any CPU in that cpuset to any other.
432 When the per-cpuset flag "cpuset.sched_load_balance" is disabled, then the
433 scheduler will avoid load balancing across the CPUs in that cpuset,
434 --except-- in so far as is necessary because some overlapping cpuset
439 CPUs, and the setting of the "cpuset.sched_load_balance" flag in any other
442 Therefore in the above two situations, the top cpuset flag
446 When doing this, you don't usually want to leave any unpinned tasks in
447 the top cpuset that might use non-trivial amounts of CPU, as such tasks
449 the particulars of this flag setting in descendant cpusets. Even if
450 such a task could use spare CPU cycles in some other CPUs, the kernel
454 Of course, tasks pinned to a particular CPU can be left in a cpuset
460 overlap and each CPU is in at most one sched domain.
470 This mismatch is why there is not a simple one-to-one relation
481 paragraphs above. In the general case, as in the top cpuset case,
482 don't leave tasks that might use non-trivial amounts of CPU in
487 CPUs in "cpuset.isolcpus" were excluded from load balancing by the
489 of the value of "cpuset.sched_load_balance" in any cpuset.
492 ------------------------------------------------
494 The per-cpuset flag 'cpuset.sched_load_balance' defaults to enabled (contrary
496 ensure that it can load balance across all the CPUs in that cpuset
497 (makes sure that all the CPUs in the cpus_allowed of that cpuset are
498 in the same sched domain.)
501 then they will be (must be) both in the same sched domain.
514 CPUs in the system. This partition is a set of subsets (represented
522 - the 'cpuset.sched_load_balance' flag of a cpuset with non-empty CPUs changes,
523 - or CPUs come or go from a cpuset with this flag enabled,
524 - or 'cpuset.sched_relax_domain_level' value of a cpuset with non-empty CPUs
526 - or a cpuset with non-empty CPUs and with this flag enabled is removed,
527 - or a cpu is offlined/onlined.
530 setup - one sched domain for each element (struct cpumask) in the
541 --------------------------------------
543 In sched domain, the scheduler migrates tasks in 2 ways; periodic load
552 And if a CPU run out of tasks in its runqueue, the CPU try to pull
557 idle CPUs, the scheduler might not search all CPUs in the domain
558 every time. In fact, in some architectures, the searching ranges on
559 events are limited in the same socket or node where the CPU locates,
566 on the next tick. For some applications in special situation, waiting
571 indicates size of searching range in levels ideally as follows,
572 otherwise initial value -1 that indicates the cpuset has no request.
575 -1 no request. use system default or follow request of others.
577 1 search siblings (hyperthreads in a core).
578 2 search cores in a package.
579 3 search cpus in a node [= system wide on non-NUMA system]
580 4 search nodes in a chunk of node [on NUMA system]
587 This file is per-cpuset and affect the sched domain where the cpuset
594 requests 0 and others are -1 then 0 is used.
602 - The migration costs between each cpu can be assumed considerably
605 - The searching cost doesn't have impact(for you) or you can make
607 - The latency is required even it sacrifices cache hit rate etc.
612 --------------------------
614 In order to minimize the impact of cpusets on critical kernel
616 does not support one task updating the memory placement of another
618 or Memory Node placement, or of changing to which cpuset a task
621 If a cpuset has its Memory Nodes modified, then for each task attached
623 a page of memory for that task, the kernel will notice the change
624 in the task's cpuset, and update its per-task memory placement to
625 remain within the new cpusets memory placement. If the task was using
628 of MPOL_BIND nodes are still allowed in the new cpuset. If the task
630 in the new cpuset, then the task will be essentially treated as if it
634 memory placement, as above, the next time that the kernel attempts
635 to allocate a page of memory for that task.
637 If a cpuset has its 'cpuset.cpus' modified, then each task in that cpuset
642 the task will be allowed to run on any CPU allowed in its new cpuset,
645 In summary, the memory placement of a task whose cpuset is changed is
650 of main memory) then that page stays on whatever node it
652 cpusets memory placement policy 'cpuset.mems' subsequently changes.
655 allocated to it on nodes in its previous cpuset are migrated
662 'cpuset.mems' file is modified, pages allocated to tasks in that
663 cpuset, that were on nodes in the previous setting of 'cpuset.mems',
664 will be moved to nodes in the new setting of 'mems.'
665 Pages that were not in the task's prior cpuset, or in the cpuset's
670 then all the tasks in that cpuset will be moved to the nearest ancestor
671 with non-empty cpus. But the moving of some (or all) tasks might fail if
673 on task attaching. In this failing case, those tasks will stay
674 in the original cpuset, and the kernel will automatically update
675 their cpus_allowed to allow all online CPUs. When memory hotplug
676 functionality for removing Memory Nodes is available, a similar exception
677 is expected to apply there as well. In general, the kernel prefers to
679 its allowed CPUs or Memory Nodes taken offline.
683 The kernel may drop some request, in rare cases even panic, if a
686 memory anywhere we can find it. It's better to violate the cpuset
692 2) mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset
693 3) Create the new cpuset by doing mkdir's and write's (or echo's) in
701 named "Charlie", containing just CPUs 2 and 3, and Memory Node 1,
702 and then start a subshell 'sh' in that cpuset::
704 mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset
708 /bin/echo 2-3 > cpuset.cpus
712 # The subshell 'sh' is now running in cpuset Charlie
718 - via the cpuset file system directly, using the various cd, mkdir, echo,
720 - via the C library libcpuset.
721 - via the C library libcgroup.
723 - via the python application cset.
735 ---------------
741 # mount -t cgroup -o cpuset cpuset /sys/fs/cgroup/cpuset
744 tree of the cpusets in the system. For instance, /sys/fs/cgroup/cpuset
756 In this directory you can find several files::
769 the CPUs and Memory Nodes it can use, the processes that are using
779 # /bin/echo 0-7 > cpuset.cpus
783 # /bin/echo 0-7 > cpuset.mems
789 You can also create cpusets inside your cpuset by using mkdir in this
798 This will fail if the cpuset is in use (has cpusets inside, or has
806 mount -t cpuset X /sys/fs/cgroup/cpuset
810 mount -t cgroup -ocpuset,noprefix X /sys/fs/cgroup/cpuset
814 ------------------------
816 This is the syntax to use when writing in the cpus or mems files
817 in cpuset directories::
819 # /bin/echo 1-4 > cpuset.cpus -> set cpus list to cpus 1,2,3,4
820 # /bin/echo 1,2,3,4 > cpuset.cpus -> set cpus list to cpus 1,2,3,4
825 # /bin/echo 1-4,6 > cpuset.cpus -> set cpus list to cpus 1,2,3,4,6
832 # /bin/echo "" > cpuset.cpus -> clear cpus list
835 -----------------
839 # /bin/echo 1 > cpuset.cpu_exclusive -> set flag 'cpuset.cpu_exclusive'
840 # /bin/echo 0 > cpuset.cpu_exclusive -> unset flag 'cpuset.cpu_exclusive'
843 -----------------------
866 errors. If you use it in the cpuset file system, you won't be