From: "Jan Beulich" Subject: Re: [PATCH] x86/numa: Adjust datatypes for node and pxm Date: Mon, 23 Feb 2015 09:57:53 +0000 Message-ID: <54EB07B10200007800062614@mail.emea.novell.com> References: <1424542459-2615-1-git-send-email-boris.ostrovsky@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1424542459-2615-1-git-send-email-boris.ostrovsky@oracle.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Boris Ostrovsky Cc: kevin.tian@intel.com, keir@xen.org, ian.campbell@citrix.com, Andrew.Cooper3@citrix.com, dario.faggioli@citrix.com, tim@xen.org, xen-devel@lists.xen.org, stefano.stabellini@citrix.com, yang.z.zhang@intel.com List-Id: xen-devel@lists.xenproject.org >>> On 21.02.15 at 19:14, wrote: > Use u8-sized node IDs and unsigned PXMs consistently throughout > code (and introduce nodeid_t type). > > Signed-off-by: Boris Ostrovsky I think the description should call out areas not covered, like the node encoding in the top bits of MEMF_*. > --- a/xen/arch/x86/srat.c > +++ b/xen/arch/x86/srat.c > @@ -21,44 +21,55 @@ > #include > #include > > +#define MAX_PXM 255 Perhaps better (MAX_NUMNODES - 1) than a literal number? Or even do away with it altogether, use MAX_NUMNODES - 1 in the array definition and ARRAY_SIZE() elsewhere? > -__devinit int setup_node(int pxm) > +__devinit nodeid_t setup_node(unsigned pxm) > { > - unsigned node = pxm2node[pxm]; > - if (node == 0xff) { > + nodeid_t node; > + > + /* NUMA_NO_NODE is 255 */ > + BUILD_BUG_ON(MAX_NUMNODES > 254); BUILD_BUG_ON(MAX_NUMNODES >= NUMA_NO_NODE); (yielding the comment redundant) > --- 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; > - unsigned int node = (uint8_t)((memflags >> _MEMF_node) - 1); > + nodeid_t node = (nodeid_t)((memflags >> _MEMF_node) - 1); No-one will notice this needing adjustment if nodeid_t ever gets widened. We'll need a _MEMF_node_width or _MEMF_node_mask to do proper masking here (the latter would allow the use of MASK_EXTR()), avoiding the need for a cast altogether. Jan