Commit 4e7b8a6c authored by David Rientjes's avatar David Rientjes Committed by Linus Torvalds
Browse files

nodemask: make NODEMASK_ALLOC more general

This is a series of patches to provide control over the location of the
allocation and freeing of persistent huge pages on a NUMA platform.
Please consider for merging into mmotm.

This series uses two mechanisms to constrain the nodes from which
persistent huge pages are allocated: 1) the task NUMA mempolicy of the
task modifying a new sysctl "nr_hugepages_mempolicy", based on a
suggestion by Mel Gorman; and 2) a subset of the hugepages hstate sysfs
attributes have been added [in V4] to each node system device under:


The per node attibutes allow direct assignment of a huge page count on a
specific node, regardless of the task's mempolicy or cpuset constraints.

This patch:

NODEMASK_ALLOC(x, m) assumes x is a type of struct, which is unnecessary.
It's perfectly reasonable to use this macro to allocate a nodemask_t,
which is anonymous, either dynamically or on the stack depending on
Signed-off-by: default avatarDavid Rientjes <>
Signed-off-by: default avatarLee Schermerhorn <>
Acked-by: default avatarKAMEZAWA Hiroyuki <>
Cc: Mel Gorman <>
Cc: Randy Dunlap <>
Cc: Nishanth Aravamudan <>
Cc: Andi Kleen <>
Cc: David Rientjes <>
Cc: Adam Litke <>
Cc: Andy Whitcroft <>
Cc: Eric Whitney <>
Cc: Christoph Lameter <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 6d9c285a
......@@ -481,14 +481,14 @@ static inline int num_node_state(enum node_states state)
* For nodemask scrach area.(See CPUMASK_ALLOC() in cpumask.h)
* NODEMASK_ALLOC(x, m) allocates an object of type 'x' with the name 'm'.
#if NODES_SHIFT > 8 /* nodemask_t > 64 bytes */
#define NODEMASK_ALLOC(x, m) struct x *m = kmalloc(sizeof(*m), GFP_KERNEL)
#define NODEMASK_FREE(m) kfree(m)
#define NODEMASK_ALLOC(x, m) x *m = kmalloc(sizeof(*m), GFP_KERNEL)
#define NODEMASK_FREE(m) kfree(m)
#define NODEMASK_ALLOC(x, m) struct x _m, *m = &_m
#define NODEMASK_FREE(m)
#define NODEMASK_ALLOC(x, m) x _m, *m = &_m
#define NODEMASK_FREE(m) do {} while (0)
/* A example struture for using NODEMASK_ALLOC, used in mempolicy. */
......@@ -497,8 +497,9 @@ struct nodemask_scratch {
nodemask_t mask2;
#define NODEMASK_SCRATCH(x) NODEMASK_ALLOC(nodemask_scratch, x)
NODEMASK_ALLOC(struct nodemask_scratch, x)
#endif /* __LINUX_NODEMASK_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment