From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <nhorman@tuxdriver.com>
Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58])
 by dpdk.org (Postfix) with ESMTP id 00244B571
 for <dev@dpdk.org>; Sun, 15 Feb 2015 15:09:36 +0100 (CET)
Received: from [67.210.173.2] (helo=localhost)
 by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63)
 (envelope-from <nhorman@tuxdriver.com>)
 id 1YMzt4-0001SK-84; Sun, 15 Feb 2015 09:09:35 -0500
Date: Sun, 15 Feb 2015 09:09:18 -0500
From: Neil Horman <nhorman@tuxdriver.com>
To: "Liang, Cunming" <cunming.liang@intel.com>
Message-ID: <20150215140917.GA6302@neilslaptop.think-freely.org>
References: <1423728996-3004-1-git-send-email-cunming.liang@intel.com>
 <1423791501-1555-1-git-send-email-cunming.liang@intel.com>
 <1423791501-1555-13-git-send-email-cunming.liang@intel.com>
 <20150213175708.GB17402@neilslaptop.think-freely.org>
 <D0158A423229094DA7ABF71CF2FA0DA3118DA492@shsmsx102.ccr.corp.intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <D0158A423229094DA7ABF71CF2FA0DA3118DA492@shsmsx102.ccr.corp.intel.com>
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Spam-Score: -2.9 (--)
X-Spam-Status: No
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v6 12/19] malloc: fix the issue of
 SOCKET_ID_ANY
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Sun, 15 Feb 2015 14:09:37 -0000

On Sun, Feb 15, 2015 at 12:43:03AM +0000, Liang, Cunming wrote:
> Hi,
> 
> > -----Original Message-----
> > From: Neil Horman [mailto:nhorman@tuxdriver.com]
> > Sent: Saturday, February 14, 2015 1:57 AM
> > To: Liang, Cunming
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v6 12/19] malloc: fix the issue of SOCKET_ID_ANY
> > 
> > On Fri, Feb 13, 2015 at 09:38:14AM +0800, Cunming Liang wrote:
> > > Add check for rte_socket_id(), avoid get unexpected return like (-1).
> > >
> > > Signed-off-by: Cunming Liang <cunming.liang@intel.com>
> > > ---
> > >  lib/librte_malloc/malloc_heap.h | 7 ++++++-
> > >  1 file changed, 6 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/lib/librte_malloc/malloc_heap.h b/lib/librte_malloc/malloc_heap.h
> > > index b4aec45..a47136d 100644
> > > --- a/lib/librte_malloc/malloc_heap.h
> > > +++ b/lib/librte_malloc/malloc_heap.h
> > > @@ -44,7 +44,12 @@ extern "C" {
> > >  static inline unsigned
> > >  malloc_get_numa_socket(void)
> > >  {
> > > -	return rte_socket_id();
> > > +	unsigned socket_id = rte_socket_id();
> > > +
> > > +	if (socket_id == (unsigned)SOCKET_ID_ANY)
> > > +		return 0;
> > > +
> > > +	return socket_id;
> > Why is -1 unexpected?  Isn't it reasonable to assume that some memory is
> > equidistant from all cpu numa nodes?
> [LCM] One piece of memory will be whole allocated from one specific NUMA node. But won't be like some part from one and the other part from another.
> If no specific NUMA node assigned(SOCKET_ID_ANY/-1), it firstly asks for the current NUMA node where current core belongs to.
> 'malloc_get_numa_socket()' is called on that time. When the time 1:1 thread/core mapping is assumed and the default value is 0, it always will return a none (-1) value.
> Now rte_socket_id() may return -1 in the case the pthread runs on multi-cores which are not belongs to one NUMA node, or in the case _socket_id is not yet assigned and the default value is (-1). So if current _socket_id is -1, then just pick up the first node as the candidate. Probably I shall add more comments for this.
> > 
Ok, but doesn't that provide an abnormal bias for node 0?  I was thinking it
might be better to be honest with the application so that it can choose a node
according to its own policy.

Neil

> > Neil
> > 
> > >  }
> > >
> > >  void *
> > > --
> > > 1.8.1.4
> > >
> > >
>