Skip to content

Commit a38a59f

Browse files
Ben Widawskytorvalds
authored andcommitted
mm/mempolicy: advertise new MPOL_PREFERRED_MANY
Adds a new mode to the existing mempolicy modes, MPOL_PREFERRED_MANY. MPOL_PREFERRED_MANY will be adequately documented in the internal admin-guide with this patch. Eventually, the man pages for mbind(2), get_mempolicy(2), set_mempolicy(2) and numactl(8) will also have text about this mode. Those shall contain the canonical reference. NUMA systems continue to become more prevalent. New technologies like PMEM make finer grain control over memory access patterns increasingly desirable. MPOL_PREFERRED_MANY allows userspace to specify a set of nodes that will be tried first when performing allocations. If those allocations fail, all remaining nodes will be tried. It's a straight forward API which solves many of the presumptive needs of system administrators wanting to optimize workloads on such machines. The mode will work either per VMA, or per thread. [Michal Hocko: refine kernel doc for MPOL_PREFERRED_MANY] Link: https://lore.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ben Widawsky <[email protected]> Signed-off-by: Feng Tang <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Dan Williams <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Rientjes <[email protected]> Cc: Huang Ying <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent cfcaa66 commit a38a59f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Documentation/admin-guide/mm/numa_memory_policy.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ MPOL_INTERLEAVED
245245
address range or file. During system boot up, the temporary
246246
interleaved system default policy works in this mode.
247247

248+
MPOL_PREFERRED_MANY
249+
This mode specifices that the allocation should be preferrably
250+
satisfied from the nodemask specified in the policy. If there is
251+
a memory pressure on all nodes in the nodemask, the allocation
252+
can fall back to all existing numa nodes. This is effectively
253+
MPOL_PREFERRED allowed for a mask rather than a single node.
254+
248255
NUMA memory policy supports the following optional mode flags:
249256

250257
MPOL_F_STATIC_NODES
@@ -253,10 +260,10 @@ MPOL_F_STATIC_NODES
253260
nodes changes after the memory policy has been defined.
254261

255262
Without this flag, any time a mempolicy is rebound because of a
256-
change in the set of allowed nodes, the node (Preferred) or
257-
nodemask (Bind, Interleave) is remapped to the new set of
258-
allowed nodes. This may result in nodes being used that were
259-
previously undesired.
263+
change in the set of allowed nodes, the preferred nodemask (Preferred
264+
Many), preferred node (Preferred) or nodemask (Bind, Interleave) is
265+
remapped to the new set of allowed nodes. This may result in nodes
266+
being used that were previously undesired.
260267

261268
With this flag, if the user-specified nodes overlap with the
262269
nodes allowed by the task's cpuset, then the memory policy is

mm/mempolicy.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,12 +1463,7 @@ static inline int sanitize_mpol_flags(int *mode, unsigned short *flags)
14631463
*flags = *mode & MPOL_MODE_FLAGS;
14641464
*mode &= ~MPOL_MODE_FLAGS;
14651465

1466-
/*
1467-
* The check should be 'mode >= MPOL_MAX', but as 'prefer_many'
1468-
* is not fully implemented, don't permit it to be used for now,
1469-
* and the logic will be restored in following patch
1470-
*/
1471-
if ((unsigned int)(*mode) >= MPOL_PREFERRED_MANY)
1466+
if ((unsigned int)(*mode) >= MPOL_MAX)
14721467
return -EINVAL;
14731468
if ((*flags & MPOL_F_STATIC_NODES) && (*flags & MPOL_F_RELATIVE_NODES))
14741469
return -EINVAL;

0 commit comments

Comments
 (0)