Re: [patch] nodemask: make NODEMASK_ALLOC more general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Rientjes wrote:
> 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
> NODES_SHIFT.
>
> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
Seems reasonable (my macro was not good)
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>

BTW...CPUMASK_ALLOC gone away ?
by  #ifdef CONFIG_CPUMASK_OFFSTACK
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=4b805b17382c11a8b1c9bb8053ce9d1dcde0701a

Hm, comment should be updated, at least.

Thanks,
-Kame

> ---
>  include/linux/nodemask.h |   15 ++++++++-------
>  1 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
> --- a/include/linux/nodemask.h
> +++ b/include/linux/nodemask.h
> @@ -486,14 +486,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)
>  #else
> -#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)
>  #endif
>
>  /* A example struture for using NODEMASK_ALLOC, used in mempolicy. */
> @@ -502,8 +502,9 @@ struct nodemask_scratch {
>  	nodemask_t	mask2;
>  };
>
> -#define NODEMASK_SCRATCH(x) NODEMASK_ALLOC(nodemask_scratch, x)
> -#define NODEMASK_SCRATCH_FREE(x)  NODEMASK_FREE(x)
> +#define NODEMASK_SCRATCH(x)	\
> +		NODEMASK_ALLOC(struct nodemask_scratch, x)
> +#define NODEMASK_SCRATCH_FREE(x)	NODEMASK_FREE(x)
>
>
>  #endif /* __LINUX_NODEMASK_H */
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>
>


--
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

[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux