From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 3C727B50B for ; Sun, 15 Feb 2015 01:43:08 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 14 Feb 2015 16:43:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,578,1418112000"; d="scan'208";a="678096800" Received: from pgsmsx103.gar.corp.intel.com ([10.221.44.82]) by fmsmga002.fm.intel.com with ESMTP; 14 Feb 2015 16:43:04 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX103.gar.corp.intel.com (10.221.44.82) with Microsoft SMTP Server (TLS) id 14.3.195.1; Sun, 15 Feb 2015 08:43:03 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.62]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.46]) with mapi id 14.03.0195.001; Sun, 15 Feb 2015 08:43:02 +0800 From: "Liang, Cunming" To: Neil Horman Thread-Topic: [dpdk-dev] [PATCH v6 12/19] malloc: fix the issue of SOCKET_ID_ANY Thread-Index: AQHQRy3bkgrqC7N8BUG8tbfwqJ1xqpzuWICAgAKFUAA= Date: Sun, 15 Feb 2015 00:43:03 +0000 Message-ID: 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> In-Reply-To: <20150213175708.GB17402@neilslaptop.think-freely.org> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 00:43:08 -0000 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 >=20 > 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 > > --- > > 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 =3D rte_socket_id(); > > + > > + if (socket_id =3D=3D (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 no= de. 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 th= e 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-cor= es 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 m= ore comments for this. >=20 > Neil >=20 > > } > > > > void * > > -- > > 1.8.1.4 > > > >