[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 3/3] mm: MEMF_node should handle changes in nodeid_t size
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) + #define _MEMF_no_refcount 0 #define MEMF_no_refcount (1U<<_MEMF_no_refcount) #define _MEMF_populate_on_demand 1 @@ -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) +#define MEMF2NODE(memflags) (MASK_EXTR(memflags, MEMF_node_mask) - 1) + #ifdef CONFIG_PAGEALLOC_MAX_ORDER #define MAX_ORDER CONFIG_PAGEALLOC_MAX_ORDER #else -- 1.7.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |