|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v3 07/10] xen/nodemask: Drop nodes_{setall, clear}() and improve the initialisers
On 29.07.2019 14:12, Andrew Cooper wrote:
> There is no need to use runtime variable-length clearing when MAX_NUMNODES is
> known to the compiler. Drop these functions and use the initialisers instead.
The only slight concern I have with this is that it further locks
down the maximum remaining to be a compile time constant. But this
is not an objection, just a remark.
> @@ -67,7 +65,34 @@ typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); }
> nodemask_t;
>
> #define nodemask_bits(src) ((src)->bits)
>
> -extern nodemask_t _unused_nodemask_arg_;
> +#define NODEMASK_LAST_WORD BITMAP_LAST_WORD_MASK(MAX_NUMNODES)
> +
> +#define NODEMASK_NONE \
> +((nodemask_t) {{ \
> + [0 ... BITS_TO_LONGS(MAX_NUMNODES) - 1] = 0 \
> +}})
> +
> +#if MAX_NUMNODES <= BITS_PER_LONG
> +
> +#define NODEMASK_ALL ((nodemask_t) {{ NODEMASK_LAST_WORD }})
> +#define NODEMASK_OF(node) ((nodemask_t) {{ 1UL << (node) }})
> +
> +#else /* MAX_NUMNODES > BITS_PER_LONG */
> +
> +#define NODEMASK_ALL \
> +((nodemask_t) {{ \
> + [0 ... BITS_TO_LONGS(MAX_NUMNODES) - 2] = ~0UL, \
> + [BITS_TO_LONGS(MAX_NUMNODES) - 1] = NODEMASK_LAST_WORD \
> +}})
> +
> +#define NODEMASK_OF(node) \
> +({ \
> + nodemask_t m = NODES_NONE; \
> + m.bits[(node) / BITS_PER_LONG] = 1UL << ((node) % BITS_PER_LONG); \
I think you will want to avoid the double evaluation of "node"
here. With this taken care of
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |