|
|
b91920 |
From 8093f82b3e52efe012e46c429b7af4e82492f71c Mon Sep 17 00:00:00 2001
|
|
|
b91920 |
From: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
b91920 |
Date: Tue, 27 Nov 2018 11:54:27 +0100
|
|
|
b91920 |
Subject: [PATCH] net/virtio: allocate vrings on device NUMA node
|
|
|
b91920 |
|
|
|
b91920 |
[ upstream commit 4a5140ab17d29e77eefa47b5cb514238e8e0c132 ]
|
|
|
b91920 |
|
|
|
b91920 |
When a guest is spanned on multiple NUMA nodes and
|
|
|
b91920 |
multiple Virtio devices are spanned onto these nodes,
|
|
|
b91920 |
we expect that their ring memory is allocated in the
|
|
|
b91920 |
right memory node.
|
|
|
b91920 |
|
|
|
b91920 |
Otherwise, vCPUs from node A may be polling Virtio rings
|
|
|
b91920 |
allocated on node B, which would increase QPI bandwidth
|
|
|
b91920 |
and impact performance.
|
|
|
b91920 |
|
|
|
b91920 |
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
b91920 |
Reviewed-by: David Marchand <david.marchand@redhat.com>
|
|
|
b91920 |
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
b91920 |
---
|
|
|
b91920 |
drivers/net/virtio/virtio_ethdev.c | 12 +++++++-----
|
|
|
b91920 |
1 file changed, 7 insertions(+), 5 deletions(-)
|
|
|
b91920 |
|
|
|
b91920 |
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
|
|
|
b91920 |
index 2ba66d291..cb2b2e0bf 100644
|
|
|
b91920 |
--- a/drivers/net/virtio/virtio_ethdev.c
|
|
|
b91920 |
+++ b/drivers/net/virtio/virtio_ethdev.c
|
|
|
b91920 |
@@ -335,8 +335,10 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)
|
|
|
b91920 |
void *sw_ring = NULL;
|
|
|
b91920 |
int queue_type = virtio_get_queue_type(hw, vtpci_queue_idx);
|
|
|
b91920 |
int ret;
|
|
|
b91920 |
+ int numa_node = dev->device->numa_node;
|
|
|
b91920 |
|
|
|
b91920 |
- PMD_INIT_LOG(DEBUG, "setting up queue: %u", vtpci_queue_idx);
|
|
|
b91920 |
+ PMD_INIT_LOG(INFO, "setting up queue: %u on NUMA node %d",
|
|
|
b91920 |
+ vtpci_queue_idx, numa_node);
|
|
|
b91920 |
|
|
|
b91920 |
/*
|
|
|
b91920 |
* Read the virtqueue size from the Queue Size field
|
|
|
b91920 |
@@ -372,7 +374,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)
|
|
|
b91920 |
}
|
|
|
b91920 |
|
|
|
b91920 |
vq = rte_zmalloc_socket(vq_name, size, RTE_CACHE_LINE_SIZE,
|
|
|
b91920 |
- SOCKET_ID_ANY);
|
|
|
b91920 |
+ numa_node);
|
|
|
b91920 |
if (vq == NULL) {
|
|
|
b91920 |
PMD_INIT_LOG(ERR, "can not allocate vq");
|
|
|
b91920 |
return -ENOMEM;
|
|
|
b91920 |
@@ -392,7 +394,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)
|
|
|
b91920 |
size, vq->vq_ring_size);
|
|
|
b91920 |
|
|
|
b91920 |
mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size,
|
|
|
b91920 |
- SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,
|
|
|
b91920 |
+ numa_node, RTE_MEMZONE_IOVA_CONTIG,
|
|
|
b91920 |
VIRTIO_PCI_VRING_ALIGN);
|
|
|
b91920 |
if (mz == NULL) {
|
|
|
b91920 |
if (rte_errno == EEXIST)
|
|
|
b91920 |
@@ -418,7 +420,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)
|
|
|
b91920 |
snprintf(vq_hdr_name, sizeof(vq_hdr_name), "port%d_vq%d_hdr",
|
|
|
b91920 |
dev->data->port_id, vtpci_queue_idx);
|
|
|
b91920 |
hdr_mz = rte_memzone_reserve_aligned(vq_hdr_name, sz_hdr_mz,
|
|
|
b91920 |
- SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,
|
|
|
b91920 |
+ numa_node, RTE_MEMZONE_IOVA_CONTIG,
|
|
|
b91920 |
RTE_CACHE_LINE_SIZE);
|
|
|
b91920 |
if (hdr_mz == NULL) {
|
|
|
b91920 |
if (rte_errno == EEXIST)
|
|
|
b91920 |
@@ -435,7 +437,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)
|
|
|
b91920 |
sizeof(vq->sw_ring[0]);
|
|
|
b91920 |
|
|
|
b91920 |
sw_ring = rte_zmalloc_socket("sw_ring", sz_sw,
|
|
|
b91920 |
- RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
|
|
|
b91920 |
+ RTE_CACHE_LINE_SIZE, numa_node);
|
|
|
b91920 |
if (!sw_ring) {
|
|
|
b91920 |
PMD_INIT_LOG(ERR, "can not allocate RX soft ring");
|
|
|
b91920 |
ret = -ENOMEM;
|
|
|
b91920 |
--
|
|
|
b91920 |
2.20.1
|
|
|
b91920 |
|