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

Re: [Xen-devel] [PATCH v2 3/3] mm: MEMF_node should handle changes in nodeid_t size



>>> On 24.02.15 at 20:11, <boris.ostrovsky@xxxxxxxxxx> wrote:
> Instead of using a hardcoded constant to extract nodeID from
> memflags use a macro whose value is based on nodeid_t size.
> 
> Also provide a macro for extracting nodeID from memflags so that
> users don't need to remember to decrement the value.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
> ---
>  xen/common/page_alloc.c |    2 +-
>  xen/include/xen/mm.h    |    6 +++++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
> index 124fa88..367b5bd 100644
> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -581,7 +581,7 @@ static struct page_info *alloc_heap_pages(
>      struct domain *d)
>  {
>      unsigned int first_node, i, j, zone = 0, nodemask_retry = 0;
> -    nodeid_t node = (nodeid_t)((memflags >> _MEMF_node) - 1);
> +    nodeid_t node = MEMF2NODE(memflags);
>      unsigned long request = 1UL << order;
>      struct page_info *pg;
>      nodemask_t nodemask = (d != NULL ) ? d->node_affinity : node_online_map;
> diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
> index 74a65a6..c86c487 100644
> --- a/xen/include/xen/mm.h
> +++ b/xen/include/xen/mm.h
> @@ -110,6 +110,8 @@ struct npfec {
>  };
>  
>  /* memflags: */
> +#define MEMF_node_mask    ((1U << sizeof(nodeid_t)) - 1)

DYM 8 * sizeof()? Also please put this side by side with _MEMF_node.

> @@ -121,10 +123,12 @@ struct npfec {
>  #define _MEMF_exact_node  4
>  #define  MEMF_exact_node  (1U<<_MEMF_exact_node)
>  #define _MEMF_node        8
> -#define  MEMF_node(n)     ((((n)+1)&0xff)<<_MEMF_node)
> +#define  MEMF_node(n)     ((((n)+1) & MEMF_node_mask) << _MEMF_node)
>  #define _MEMF_bits        24
>  #define  MEMF_bits(n)     ((n)<<_MEMF_bits)

At the very least you'll want to put a BUILD_BUG_ON() somewhere
to make sure MEMF_node() doesn't spill into MEMF_bits().

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.