Message ID | 1422842559-13617-11-git-send-email-cunming.liang@intel.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D1DA037C5; Mon, 2 Feb 2015 03:03:19 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id B6BB537C4 for <dev@dpdk.org>; Mon, 2 Feb 2015 03:03:17 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 01 Feb 2015 18:03:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,503,1418112000"; d="scan'208";a="679459165" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2015 18:03:16 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t1223DpU014422; Mon, 2 Feb 2015 10:03:13 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t12239qe013742; Mon, 2 Feb 2015 10:03:11 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t12239A2013738; Mon, 2 Feb 2015 10:03:09 +0800 From: Cunming Liang <cunming.liang@intel.com> To: dev@dpdk.org Date: Mon, 2 Feb 2015 10:02:32 +0800 Message-Id: <1422842559-13617-11-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1422842559-13617-1-git-send-email-cunming.liang@intel.com> References: <1422491072-5114-1-git-send-email-cunming.liang@intel.com> <1422842559-13617-1-git-send-email-cunming.liang@intel.com> Subject: [dpdk-dev] [PATCH v4 10/17] 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> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Cunming Liang
Feb. 2, 2015, 2:02 a.m. UTC
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(-)
Comments
Hi, On 02/02/2015 03:02 AM, 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; > } > > void * > The documentation off rte_malloc_socket() says: @param socket NUMA socket to allocate memory on. If SOCKET_ID_ANY is used, this function will behave the same as rte_malloc(). void * rte_malloc_socket(const char *type, size_t size, unsigned align, int socket); Your patch changes the behavior of rte_malloc() without explaining why, and the documentation becomes wrong. Can you explain why you need this change? Regards, Olivier
> -----Original Message----- > From: Olivier MATZ [mailto:olivier.matz@6wind.com] > Sent: Monday, February 09, 2015 4:01 AM > To: Liang, Cunming; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v4 10/17] malloc: fix the issue of SOCKET_ID_ANY > > Hi, > > On 02/02/2015 03:02 AM, 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; > > } > > > > void * > > > > The documentation off rte_malloc_socket() says: > > @param socket > NUMA socket to allocate memory on. If SOCKET_ID_ANY is used, this > function will behave the same as rte_malloc(). > > void * > rte_malloc_socket(const char *type, size_t size, unsigned align, int > socket); > > > Your patch changes the behavior of rte_malloc() without explaining > why, and the documentation becomes wrong. > > Can you explain why you need this change? [LCM] I don't think I change the declaration of rte_malloc_socket(). If socket_arg=SOCKET_ID_ANY, the socket value expect to the return value of malloc_get_numa_socket(). The malloc_get_numa_socket() supposed to return the correct TLS _socket_id. It works fine for normal cases. But as we change the default value of TLS _socket_id to SOCKET_ID_ANY. And one lcore can run on multiple cpu, if all cpus in the cpuset are not belongs to one NUMA node, the _socket_id would be SOCKET_ID_ANY. When user call rte_malloc_socket(SOCKET_ID_ANY), it does provide the same behavior as rte_malloc(). They both will get socket_id from malloc_get_numa_socket(). The addition part is the exception path process. > > Regards, > Olivier
Hi, On 02/09/2015 03:08 PM, Liang, Cunming wrote: > > >> -----Original Message----- >> From: Olivier MATZ [mailto:olivier.matz@6wind.com] >> Sent: Monday, February 09, 2015 4:01 AM >> To: Liang, Cunming; dev@dpdk.org >> Subject: Re: [dpdk-dev] [PATCH v4 10/17] malloc: fix the issue of SOCKET_ID_ANY >> >> Hi, >> >> On 02/02/2015 03:02 AM, 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; >>> } >>> >>> void * >>> >> >> The documentation off rte_malloc_socket() says: >> >> @param socket >> NUMA socket to allocate memory on. If SOCKET_ID_ANY is used, this >> function will behave the same as rte_malloc(). >> >> void * >> rte_malloc_socket(const char *type, size_t size, unsigned align, int >> socket); >> >> >> Your patch changes the behavior of rte_malloc() without explaining >> why, and the documentation becomes wrong. >> >> Can you explain why you need this change? > [LCM] I don't think I change the declaration of rte_malloc_socket(). > If socket_arg=SOCKET_ID_ANY, the socket value expect to the return value of malloc_get_numa_socket(). > The malloc_get_numa_socket() supposed to return the correct TLS _socket_id. > It works fine for normal cases. But as we change the default value of TLS _socket_id to SOCKET_ID_ANY. > And one lcore can run on multiple cpu, if all cpus in the cpuset are not belongs to one NUMA node, the _socket_id would be SOCKET_ID_ANY. > When user call rte_malloc_socket(SOCKET_ID_ANY), it does provide the same behavior as rte_malloc(). > They both will get socket_id from malloc_get_numa_socket(). The addition part is the exception path process. Sorry, I checked again, you are right.
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; } void *