On Wed, 26 Aug 2009, Lee Schermerhorn wrote: > Against: 2.6.31-rc6-mmotm-090820-1918 > > Introduce nodemask macro to allocate a nodemask and > initialize it to contain a single node, using existing > nodemask_of_node() macro. Coded as a macro to avoid header > dependency hell. > > This will be used to construct the huge pages "nodes_allowed" > nodemask for a single node when a persistent huge page > pool page count is modified via a per node sysfs attribute. > > Signed-off-by: Lee Schermerhorn <lee.schermerhorn@xxxxxx> > > include/linux/nodemask.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > Index: linux-2.6.31-rc6-mmotm-090820-1918/include/linux/nodemask.h > =================================================================== > --- linux-2.6.31-rc6-mmotm-090820-1918.orig/include/linux/nodemask.h 2009-08-24 10:16:56.000000000 -0400 > +++ linux-2.6.31-rc6-mmotm-090820-1918/include/linux/nodemask.h 2009-08-26 12:38:31.000000000 -0400 > @@ -257,6 +257,16 @@ static inline int __next_node(int n, con > m; \ > }) > > +#define alloc_nodemask_of_node(node) \ > +({ \ > + typeof(_unused_nodemask_arg_) *nmp; \ > + nmp = kmalloc(sizeof(*nmp), GFP_KERNEL); \ > + if (nmp) \ > + *nmp = nodemask_of_node(node); \ > + nmp; \ > +}) > + > + > #define first_unset_node(mask) __first_unset_node(&(mask)) > static inline int __first_unset_node(const nodemask_t *maskp) > { I think it would probably be better to use the generic NODEMASK_ALLOC() interface by requiring it to pass the entire type (including "struct") as part of the first parameter. Then it automatically takes care of dynamically allocating large nodemasks vs. allocating them on the stack. Would it work by redefining NODEMASK_ALLOC() in the NODES_SHIFT > 8 case to be this: #define NODEMASK_ALLOC(x, m) x *m = kmalloc(sizeof(*m), GFP_KERNEL); and converting NODEMASK_SCRATCH(x) to NODEMASK_ALLOC(struct nodemask_scratch, x), and then doing this in your code: NODEMASK_ALLOC(nodemask_t, nodes_allowed); if (nodes_allowed) *nodes_allowed = nodemask_of_node(node); The NODEMASK_{ALLOC,SCRATCH}() interface is in its infancy so it can probably be made more general to handle cases like this. -- To unsubscribe from this list: send the line "unsubscribe linux-numa" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html