* [Patch v3] net/netvsc: add device argument to configure if NUMA information on the device should be used
@ 2025-08-25 21:50 longli
0 siblings, 0 replies; only message in thread
From: longli @ 2025-08-25 21:50 UTC (permalink / raw)
To: Stephen Hemminger, Wei Hu; +Cc: dev, Long Li
From: Long Li <longli@microsoft.com>
In most cases, netvsc is used with a VF device. The application generally
runs with better performance when all the device memory is allocated on
VF's NUMA node, as the VF device carries most of the data packets.
But sometimes netvsc may run on a different NUMA node than that of the VF.
This patches adds a device argument "numa_aware" to allow the application
to configure if netvsc should be NUMA aware. The default behavior for
netvsc is that it is not NUMA aware. Setting "numa_aware=1" tells netvsc
to be NUMA aware.
Signed-off-by: Long Li <longli@microsoft.com>
---
Change log
v2: move the code for parsing device arguments to vmbus
v3: change default to be not NUMA aware. Use VMBUS code to parse "numa_aware" only
doc/guides/nics/netvsc.rst | 9 ++++
drivers/bus/vmbus/bus_vmbus_driver.h | 2 +
drivers/bus/vmbus/linux/vmbus_bus.c | 66 +++++++++++++++++++++++-----
drivers/net/netvsc/hn_ethdev.c | 1 +
4 files changed, 67 insertions(+), 11 deletions(-)
diff --git a/doc/guides/nics/netvsc.rst b/doc/guides/nics/netvsc.rst
index 2c0ea6ac9e..cdeefbe1e1 100644
--- a/doc/guides/nics/netvsc.rst
+++ b/doc/guides/nics/netvsc.rst
@@ -141,3 +141,12 @@ The user can specify below argument in devargs.
A non-zero value tells netvsc to attach external buffers to mbuf on
receiving packets, thus avoid copying memory. Use of external buffers
requires the application is able to read data from external mbuf.
+
+#. ``numa_aware``:
+ The numa_aware is used to configure if netvsc driver should be NUMA aware.
+ The default value is 0 (meaning the netvsc driver is not NUMA aware). When
+ used with a VF device, the VF device's NUMA node may not be the same as
+ netvsc's NUMA node. The application generally runs with better performance
+ if all the device queues are allocated on VF's NUMA node, as the VF carries
+ most of the data packets. Setting this value to 1 makes netvsc driver NUMA
+ aware.
diff --git a/drivers/bus/vmbus/bus_vmbus_driver.h b/drivers/bus/vmbus/bus_vmbus_driver.h
index bc394208de..9b8ebe7891 100644
--- a/drivers/bus/vmbus/bus_vmbus_driver.h
+++ b/drivers/bus/vmbus/bus_vmbus_driver.h
@@ -17,6 +17,8 @@ extern "C" {
struct vmbus_channel;
struct vmbus_mon_page;
+#define NETVSC_ARG_NUMA_AWARE "numa_aware"
+
/** Maximum number of VMBUS resources. */
enum hv_uio_map {
HV_TXRX_RING_MAP = 0,
diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c b/drivers/bus/vmbus/linux/vmbus_bus.c
index ed18d4da96..a1ff8f65bc 100644
--- a/drivers/bus/vmbus/linux/vmbus_bus.c
+++ b/drivers/bus/vmbus/linux/vmbus_bus.c
@@ -18,6 +18,7 @@
#include <rte_memory.h>
#include <rte_malloc.h>
#include <rte_bus_vmbus.h>
+#include <rte_kvargs.h>
#include <eal_export.h>
#include "eal_filesystem.h"
@@ -231,6 +232,48 @@ rte_vmbus_unmap_device(struct rte_vmbus_device *dev)
vmbus_uio_unmap_resource(dev);
}
+/* Check in dev args if NUMA should be used by checking for "numa_aware" in the
+ * device arguments.
+ * By default returning false, meaning this vmbus device is not NUMA aware.
+ */
+static bool vmbus_use_numa(struct rte_vmbus_device *dev)
+{
+ struct rte_devargs *devargs = dev->device.devargs;
+ struct rte_kvargs *kvlist;
+ const struct rte_kvargs_pair *pair;
+ unsigned long v;
+ unsigned int i;
+ char *endp = NULL;
+ bool ret = false;
+
+ if (!devargs)
+ return ret;
+
+ VMBUS_LOG(DEBUG, "device args %s %s", devargs->name, devargs->args);
+
+ kvlist = rte_kvargs_parse(devargs->args, NULL);
+ if (!kvlist) {
+ VMBUS_LOG(ERR, "invalid parameters");
+ return ret;
+ }
+
+ for (i = 0; i < kvlist->count; i++) {
+ pair = &kvlist->pairs[i];
+ if (!strcmp(pair->key, NETVSC_ARG_NUMA_AWARE)) {
+ v = strtoul(pair->value, &endp, 0);
+ if (*pair->value == '\0' || *endp != '\0') {
+ VMBUS_LOG(ERR, "invalid parameter %s=%s",
+ pair->key, pair->value);
+ }
+ ret = v ? true : false;
+ }
+ }
+
+ rte_kvargs_free(kvlist);
+
+ return ret;
+}
+
/* Scan one vmbus sysfs entry, and fill the devices list from it. */
static int
vmbus_scan_one(const char *name)
@@ -287,19 +330,20 @@ vmbus_scan_one(const char *name)
goto error;
dev->monitor_id = tmp;
- /* get numa node (if present) */
- snprintf(filename, sizeof(filename), "%s/numa_node",
- dirname);
+ dev->device.devargs = vmbus_devargs_lookup(dev);
- if (access(filename, R_OK) == 0) {
- if (eal_parse_sysfs_value(filename, &tmp) < 0)
- goto error;
- dev->device.numa_node = tmp;
- } else {
- dev->device.numa_node = SOCKET_ID_ANY;
- }
+ dev->device.numa_node = SOCKET_ID_ANY;
+ if (vmbus_use_numa(dev)) {
+ /* get numa node (if present) */
+ snprintf(filename, sizeof(filename), "%s/numa_node",
+ dirname);
- dev->device.devargs = vmbus_devargs_lookup(dev);
+ if (access(filename, R_OK) == 0) {
+ if (eal_parse_sysfs_value(filename, &tmp) < 0)
+ goto error;
+ dev->device.numa_node = tmp;
+ }
+ }
/* Allocate interrupt handle instance */
dev->intr_handle =
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 0a7ed155d3..cc4099bec4 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -204,6 +204,7 @@ static int hn_parse_args(const struct rte_eth_dev *dev)
NETVSC_ARG_RXBREAK,
NETVSC_ARG_TXBREAK,
NETVSC_ARG_RX_EXTMBUF_ENABLE,
+ NETVSC_ARG_NUMA_AWARE,
NULL
};
struct rte_kvargs *kvlist;
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-25 21:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-25 21:50 [Patch v3] net/netvsc: add device argument to configure if NUMA information on the device should be used longli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).