Lines Matching refs:policy

8 In the Linux kernel, "memory policy" determines from which node the kernel will
11 The current memory policy support was added to Linux 2.6 around May 2004. This
12 document attempts to describe the concepts and APIs of the 2.6 memory policy
30 The Linux kernel supports _scopes_ of memory policy, described here from
34 this policy is "hard coded" into the kernel. It is the policy
36 one of the more specific policy scopes discussed below. When
37 the system is "up and running", the system default policy will
39 up, the system default policy will be set to interleave
45 this is an optional, per-task policy. When defined for a
46 specific task, this policy controls all page allocations made
48 specific scope. If a task does not define a task policy, then
50 task policy "fall back" to the System Default Policy.
52 The task policy applies to the entire address space of a task. Thus,
55 to establish the task policy for a child task exec()'d from an
56 executable image that has no awareness of memory policy. See the
59 that a task may use to set/change its task/process policy.
62 [Linux kernel task] that installs the policy and any threads
64 at the time a new task policy is installed retain their current
65 policy.
67 A task policy applies only to pages allocated after the policy is
69 changes its task policy remain where they were allocated based on
70 the policy at the time they were allocated.
76 virtual address space. A task may define a specific policy for a range
80 policy.
82 A VMA policy will govern the allocation of pages that back
84 address space that don't have an explicit VMA policy will fall
85 back to the task policy, which may itself fall back to the
90 * VMA policy applies ONLY to anonymous pages. These include
93 mmap()ed with the MAP_ANONYMOUS flag. If a VMA policy is
96 MAP_PRIVATE flag, the VMA policy will only be applied when
102 the policy is installed; and they are inherited across
109 * A task may install a new VMA policy on a sub-range of a
112 its own policy.
114 * By default, VMA policy applies only to pages allocated after
115 the policy is installed. Any pages already faulted into the
117 policy at the time they were allocated. However, since
120 installed policy.
131 the object share the policy, and all pages allocated for the
132 shared object, by any task, will obey the shared policy.
135 mmap(MAP_ANONYMOUS|MAP_SHARED), support shared policy. When shared
136 policy support was added to Linux, the associated data structures were
139 shmem segments were never "hooked up" to the shared policy support.
141 for shared policy has not been completed.
145 with MAP_SHARED ignore any VMA policy installed on the virtual
149 task policy, if any, else System Default Policy.
151 The shared policy infrastructure supports different policies on subset
153 the task that installs the policy for each range of distinct policy.
157 a shared memory region, when one task has installed shared policy on
163 A NUMA memory policy consists of a "mode", optional mode flags, and
165 policy, the optional mode flags determine the behavior of the mode,
167 policy behavior.
173 NUMA memory policy supports the following 4 behavioral modes:
176 This mode is only used in the memory policy APIs. Internally,
177 MPOL_DEFAULT is converted to the NULL memory policy in all
178 policy scopes. Any existing non-default policy will simply be
180 MPOL_DEFAULT means "fall back to the next most specific policy
183 For example, a NULL or default task policy will fall back to the
184 system default policy. A NULL or default vma policy will fall
185 back to the task policy.
187 When specified in one of the memory policy APIs, the Default mode
190 It is an error for the set of nodes specified for this policy to
195 nodes specified by the policy. Memory will be allocated from
201 from the single node specified in the policy. If that
206 Internally, the Preferred policy uses a single node--the
209 and the policy is interpreted as local allocation. "Local"
210 allocation policy can be viewed as a Preferred policy that
216 mode. If an empty nodemask is passed, the policy cannot use
222 page granularity, across the nodes specified in the policy.
228 policy using the page offset of the faulting address into the
230 nodes specified by the policy. It then attempts to allocate a
232 specified by a Preferred policy or had been selected by a
237 the set of nodes specified by the policy using a node counter
241 specified by the policy based on the order in which they are
244 interleaved system default policy works in this mode.
248 satisfied from the nodemask specified in the policy. If there is
253 NUMA memory policy supports the following optional mode flags:
258 nodes changes after the memory policy has been defined.
267 nodes allowed by the task's cpuset, then the memory policy is
269 overlap, the Default policy is used.
272 mems 1-3 that sets an Interleave policy over the same set. If
303 nodemask, the policy will be effected over the first (and in the
315 mems 2-5 that sets an Interleave policy over the same set with
326 policy is intended to manage. Let the kernel then remap to the
344 When a new memory policy is allocated, its reference count is initialized
346 new policy. When a pointer to a memory policy structure is stored in another
348 on completion of the policy installation.
350 During run-time "usage" of the policy, we attempt to minimize atomic operations
354 1) querying of the policy, either by the task itself [using the get_mempolicy()
358 2) examination of the policy to determine the policy mode and associated node
362 BIND policy nodemask is used, by reference, to filter ineligible nodes.
367 1) we never need to get/free the system default policy as this is never
370 2) for querying the policy, we do not need to take an extra reference on the
371 target task's task policy nor vma policies because we always acquire the
375 of a task or thread freeing a policy while another task or thread is
378 3) Page allocation usage of task or vma policy occurs in the fault path where
380 policy requires that the mmap_lock be held for write, the policy can't be
384 shared memory policy while another task, with a distinct mmap_lock, is
385 querying or allocating a page based on the policy. To resolve this
386 potential race, the shared policy infrastructure adds an extra reference
387 to the shared policy during lookup while holding a spin lock on the shared
388 policy management structure. This requires that we drop this extra
389 reference when we're finished "using" the policy. We must drop the
400 falling back to task or system default policy for shared memory regions,
409 Linux supports 4 system calls for controlling memory policy. These APIS
425 Set's the calling task's "task/process memory policy" to mode
441 Queries the "task/process memory policy" of the calling task, or the
442 policy or location of a specified virtual address, depending on the
454 mbind() installs the policy specified by (mode, nmask, maxnodes) as a
455 VMA policy for the range of the calling task's address space specified
467 sys_set_mempolicy_home_node set the home node for a VMA policy present in the
471 the default allocation policy to allocate memory close to the local node for an
478 Although not strictly part of the Linux implementation of memory policy,
481 + set the task policy for a specified program via set_mempolicy(2), fork(2) and
484 + set the shared policy for a shared memory segment via mbind(2)
487 containing the memory policy system call wrappers. Some distributions
499 specified for the policy contains nodes that are not allowed by the cpuset and
501 specified for the policy and the set of nodes with memory is used. If the
502 result is the empty set, the policy is considered invalid and cannot be
503 installed. If MPOL_F_RELATIVE_NODES is used, the policy's nodes are mapped
509 any of the tasks install shared policy on the region, only nodes whose
511 this information requires "stepping outside" the memory policy APIs to use the
514 memory sets are disjoint, "local" allocation is the only valid policy.