aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/nodemask.h21
-rw-r--r--mm/hugetlb.c5
2 files changed, 15 insertions, 11 deletions
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index cbd521a03127..454997cccbd8 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -485,15 +485,17 @@ static inline int num_node_state(enum node_states state)
485#define for_each_online_node(node) for_each_node_state(node, N_ONLINE) 485#define for_each_online_node(node) for_each_node_state(node, N_ONLINE)
486 486
487/* 487/*
488 * For nodemask scrach area.(See CPUMASK_ALLOC() in cpumask.h) 488 * For nodemask scrach area.
489 * NODEMASK_ALLOC(x, m) allocates an object of type 'x' with the name 'm'. 489 * NODEMASK_ALLOC(type, name) allocates an object with a specified type and
490 * name.
490 */ 491 */
491#if NODES_SHIFT > 8 /* nodemask_t > 64 bytes */ 492#if NODES_SHIFT > 8 /* nodemask_t > 256 bytes */
492#define NODEMASK_ALLOC(x, m) x *m = kmalloc(sizeof(*m), GFP_KERNEL) 493#define NODEMASK_ALLOC(type, name, gfp_flags) \
493#define NODEMASK_FREE(m) kfree(m) 494 type *name = kmalloc(sizeof(*name), gfp_flags)
495#define NODEMASK_FREE(m) kfree(m)
494#else 496#else
495#define NODEMASK_ALLOC(x, m) x _m, *m = &_m 497#define NODEMASK_ALLOC(type, name, gfp_flags) type _name, *name = &_name
496#define NODEMASK_FREE(m) do {} while (0) 498#define NODEMASK_FREE(m) do {} while (0)
497#endif 499#endif
498 500
499/* A example struture for using NODEMASK_ALLOC, used in mempolicy. */ 501/* A example struture for using NODEMASK_ALLOC, used in mempolicy. */
@@ -502,8 +504,9 @@ struct nodemask_scratch {
502 nodemask_t mask2; 504 nodemask_t mask2;
503}; 505};
504 506
505#define NODEMASK_SCRATCH(x) \ 507#define NODEMASK_SCRATCH(x) \
506 NODEMASK_ALLOC(struct nodemask_scratch, x) 508 NODEMASK_ALLOC(struct nodemask_scratch, x, \
509 GFP_KERNEL | __GFP_NORETRY)
507#define NODEMASK_SCRATCH_FREE(x) NODEMASK_FREE(x) 510#define NODEMASK_SCRATCH_FREE(x) NODEMASK_FREE(x)
508 511
509 512
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b4a263512cb7..450493d25572 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1361,7 +1361,7 @@ static ssize_t nr_hugepages_store_common(bool obey_mempolicy,
1361 int nid; 1361 int nid;
1362 unsigned long count; 1362 unsigned long count;
1363 struct hstate *h; 1363 struct hstate *h;
1364 NODEMASK_ALLOC(nodemask_t, nodes_allowed); 1364 NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY);
1365 1365
1366 err = strict_strtoul(buf, 10, &count); 1366 err = strict_strtoul(buf, 10, &count);
1367 if (err) 1367 if (err)
@@ -1857,7 +1857,8 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
1857 proc_doulongvec_minmax(table, write, buffer, length, ppos); 1857 proc_doulongvec_minmax(table, write, buffer, length, ppos);
1858 1858
1859 if (write) { 1859 if (write) {
1860 NODEMASK_ALLOC(nodemask_t, nodes_allowed); 1860 NODEMASK_ALLOC(nodemask_t, nodes_allowed,
1861 GFP_KERNEL | __GFP_NORETRY);
1861 if (!(obey_mempolicy && 1862 if (!(obey_mempolicy &&
1862 init_nodemask_of_mempolicy(nodes_allowed))) { 1863 init_nodemask_of_mempolicy(nodes_allowed))) {
1863 NODEMASK_FREE(nodes_allowed); 1864 NODEMASK_FREE(nodes_allowed);