From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 1CC1A532C for ; Mon, 13 Jun 2016 12:03:59 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 13 Jun 2016 03:03:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,466,1459839600"; d="scan'208";a="974461154" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by orsmga001.jf.intel.com with ESMTP; 13 Jun 2016 03:03:57 -0700 Date: Mon, 13 Jun 2016 18:05:55 +0800 From: Yuanhan Liu To: Rich Lane Cc: dev@dpdk.org, "huawei.xie" , Thomas Monjalon , Panu Matilainen , Traynor Kevin , Tetsuya Mukawa Message-ID: <20160613100555.GR10038@yliu-dev.sh.intel.com> References: <1463117111-27050-1-git-send-email-yuanhan.liu@linux.intel.com> <1465271530-27878-1-git-send-email-yuanhan.liu@linux.intel.com> <1465271530-27878-9-git-send-email-yuanhan.liu@linux.intel.com> <20160609044500.GK10038@yliu-dev.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20160609044500.GK10038@yliu-dev.sh.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v3 08/20] vhost: introduce new API to export numa node 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: Mon, 13 Jun 2016 10:04:00 -0000 On Thu, Jun 09, 2016 at 12:45:00PM +0800, Yuanhan Liu wrote: > On Wed, Jun 08, 2016 at 02:51:33PM -0700, Rich Lane wrote: > > On Mon, Jun 6, 2016 at 8:51 PM, Yuanhan Liu > > wrote: > > > > @@ -248,14 +248,9 @@ new_device(struct virtio_net *dev) > >         internal = eth_dev->data->dev_private; > > > >  #ifdef RTE_LIBRTE_VHOST_NUMA > > -       ret  = get_mempolicy(&newnode, NULL, 0, dev, > > -                       MPOL_F_NODE | MPOL_F_ADDR); > > -       if (ret < 0) { > > -               RTE_LOG(ERR, PMD, "Unknown numa node\n"); > > -               return -1; > > -       } > > - > > -       eth_dev->data->numa_node = newnode; > > +       newnode = rte_vhost_get_numa_node(dev->vid); > > +       if (newnode > 0) > > > > > > Should be "newnode >= 0".  > > Nice catch! Thanks. Here is the update patch that includes the fix of two issues reported by Rich and Panu. And if there is no objection, I'd like to apply this series plus some other series on virtio/vhost from mine in one or two days: it's close to the RC1 deadline now. --yliu --- >>From f378af61f6ba7dcfcd20ab180fba166619ea3d88 Mon Sep 17 00:00:00 2001 From: Yuanhan Liu Date: Wed, 11 May 2016 06:12:57 +0800 Subject: [PATCH] vhost: introduce new API to export numa node Introduce a new API rte_vhost_get_numa_node() to get the numa node from which the virtio_net struct is allocated. Signed-off-by: Yuanhan Liu Tested-by: Rich Lane Acked-by: Rich Lane --- v4: - fix build error in shared configuration reported by Panu - fix numa node check reported by Rich --- drivers/net/vhost/rte_eth_vhost.c | 13 ++++--------- lib/librte_vhost/rte_vhost_version.map | 7 +++++++ lib/librte_vhost/rte_virtio_net.h | 12 ++++++++++++ lib/librte_vhost/virtio-net.c | 26 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 63538c1..a00351b 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -230,7 +230,7 @@ new_device(struct virtio_net *dev) struct vhost_queue *vq; unsigned i; #ifdef RTE_LIBRTE_VHOST_NUMA - int newnode, ret; + int newnode; #endif if (dev == NULL) { @@ -248,14 +248,9 @@ new_device(struct virtio_net *dev) internal = eth_dev->data->dev_private; #ifdef RTE_LIBRTE_VHOST_NUMA - ret = get_mempolicy(&newnode, NULL, 0, dev, - MPOL_F_NODE | MPOL_F_ADDR); - if (ret < 0) { - RTE_LOG(ERR, PMD, "Unknown numa node\n"); - return -1; - } - - eth_dev->data->numa_node = newnode; + newnode = rte_vhost_get_numa_node(dev->vid); + if (newnode >= 0) + eth_dev->data->numa_node = newnode; #endif for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map index 3d8709e..a323fa0 100644 --- a/lib/librte_vhost/rte_vhost_version.map +++ b/lib/librte_vhost/rte_vhost_version.map @@ -20,3 +20,10 @@ DPDK_2.1 { rte_vhost_driver_unregister; } DPDK_2.0; + +DPDK_16.07 { + global: + + rte_vhost_get_numa_node; + +} DPDK_2.1; diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h index bc64e89..b8e9b02 100644 --- a/lib/librte_vhost/rte_virtio_net.h +++ b/lib/librte_vhost/rte_virtio_net.h @@ -245,6 +245,18 @@ int rte_vhost_driver_callback_register(struct virtio_net_device_ops const * cons int rte_vhost_driver_session_start(void); /** + * Get the numa node from which the virtio net device's memory + * is allocated. + * + * @param vid + * virtio-net device ID + * + * @return + * The numa node, -1 on failure + */ +int rte_vhost_get_numa_node(int vid); + +/** * This function adds buffers to the virtio devices RX virtqueue. Buffers can * be received from the physical port or from another virtual device. A packet * count is returned to indicate the number of packets that were succesfully diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index c6d3829..25b6515 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -730,6 +730,32 @@ vhost_set_backend(int vid, struct vhost_vring_file *file) return 0; } +int +rte_vhost_get_numa_node(int vid) +{ +#ifdef RTE_LIBRTE_VHOST_NUMA + struct virtio_net *dev = get_device(vid); + int numa_node; + int ret; + + if (dev == NULL) + return -1; + + ret = get_mempolicy(&numa_node, NULL, 0, dev, + MPOL_F_NODE | MPOL_F_ADDR); + if (ret < 0) { + RTE_LOG(ERR, VHOST_CONFIG, + "(%d) failed to query numa node: %d\n", vid, ret); + return -1; + } + + return numa_node; +#else + RTE_SET_USED(vid); + return -1; +#endif +} + int rte_vhost_enable_guest_notification(struct virtio_net *dev, uint16_t queue_id, int enable) { -- 1.9.3