Skip to contentSkip to conversation

bond: avoid allocating mempool on socket LCORE_ID_ANY

PATCH In review Jan Blunck 3 participants 8 messages Apr 26, 2017 – Jul 3, 2017

Subsystems (2)
lore
Share & tools
lore

Jan Blunck

author
#0 lore raw

PATCH 1/2 bond: avoid allocating mempool on socket LCORE_ID_ANY

If the numa node is unknown, use the value from rte_socket_id() to avoid an allocation failure.

---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/bonding/rte_eth_bond_8023ad.c +2 -0
index 7b863d6..b8df536 100644
@@ -887,6 +887,8 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id)
 	RTE_ASSERT(port->rx_ring == NULL);
 	RTE_ASSERT(port->tx_ring == NULL);
 	socket_id = rte_eth_devices[slave_id].data->numa_node;
+	if (socket_id == (uint8_t)LCORE_ID_ANY)
+		socket_id = 0;
 
 	element_size = sizeof(struct slow_protocol_frame) +
 				RTE_PKTMBUF_HEADROOM;
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 bond: use rte_eth_dev_socket_id()

The bonded device does not have to be a PCI device. Use the rte_ethdev functions instead.

---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -1
index b8df536..f84553c 100644
@@ -886,7 +886,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id)
 
 	RTE_ASSERT(port->rx_ring == NULL);
 	RTE_ASSERT(port->tx_ring == NULL);
-	socket_id = rte_eth_devices[slave_id].data->numa_node;
+	socket_id = rte_eth_dev_socket_id(slave_id);
 	if (socket_id == (uint8_t)LCORE_ID_ANY)
 		socket_id = 0;
 
Signature · 1 line
2.7.4
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] bond: use rte_eth_dev_socket_id()

Quoted 16 lines · Jan Blunck

The bonded device does not have to be a PCI device. Use the rte_ethdev functions instead.

---
  drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_8023ad.c +0 -0
index b8df536..f84553c 100644

drivers/net/bonding/rte_eth_bond_8023ad.c bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id) · line 892

Quoted 8 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -1
@@ -886,7 +886,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id)
 
  	RTE_ASSERT(port->rx_ring == NULL);
  	RTE_ASSERT(port->tx_ring == NULL);
-	socket_id = rte_eth_devices[slave_id].data->numa_node;
+	socket_id = rte_eth_dev_socket_id(slave_id);
  	if (socket_id == (uint8_t)LCORE_ID_ANY)
  		socket_id = 0;
 
#3 lore raw
In reply to Jan Blunck
Quoted 14 lines · Jan Blunck

If the numa node is unknown, use the value from rte_socket_id() to avoid an allocation failure.

---
  drivers/net/bonding/rte_eth_bond_8023ad.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/net/bonding/rte_eth_bond_8023ad.c +0 -0
index 7b863d6..b8df536 100644

drivers/net/bonding/rte_eth_bond_8023ad.c bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id) · line 890

Quoted 4 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -0
@@ -887,6 +887,8 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id)
  	RTE_ASSERT(port->rx_ring == NULL);
  	RTE_ASSERT(port->tx_ring == NULL);
  	socket_id = rte_eth_devices[slave_id].data->numa_node;
+	if (socket_id == (uint8_t)LCORE_ID_ANY)

socket_id is an integer so we shouldn't be casting LCORE_ID_ANY to an uint8_t as this condition would never match as LCORE_ID_ANY wouldn't be UINT32_MAX after casting

drivers/net/bonding/rte_eth_bond_8023ad.c bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id) · line 891

Quoted 1 line
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -0
+		socket_id = 0;

Should this not be socket_id = rte_socket_id(); as we don't know we are running on

Quoted 4 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +0 -0
  	element_size = sizeof(struct slow_protocol_frame) +
  				RTE_PKTMBUF_HEADROOM;
 
author
#4 lore raw
Quoted 11 lines · Declan Doherty
Quoted 10 lines · Jan Blunck

If the numa node is unknown, use the value from rte_socket_id() to avoid an allocation failure.

---
  drivers/net/bonding/rte_eth_bond_8023ad.c | 2 ++
  1 file changed, 2 insertions(+)
Quoted 17 lines

drivers/net/bonding/rte_eth_bond_8023ad.c bond_mode_8023ad_activate_slave(struct rte_eth_dev · line 891

Quoted 11 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -0
index 7b863d6..b8df536 100644
@@ -887,6 +887,8 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev
 *bond_dev, uint8_t slave_id)
        RTE_ASSERT(port->rx_ring == NULL);
        RTE_ASSERT(port->tx_ring == NULL);
        socket_id = rte_eth_devices[slave_id].data->numa_node;
+       if (socket_id == (uint8_t)LCORE_ID_ANY)

socket_id is an integer so we shouldn't be casting LCORE_ID_ANY to an uint8_t as this condition would never match as LCORE_ID_ANY wouldn't be UINT32_MAX after casting

Ouch ... let me fix this.

Quoted 11 lines

drivers/net/bonding/rte_eth_bond_8023ad.c bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id) · line 891

Quoted 1 line
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -0
+               socket_id = 0;

Should this not be socket_id = rte_socket_id(); as we don't know we are running on

Quoted 3 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +0 -0
        element_size = sizeof(struct slow_protocol_frame) +
                                RTE_PKTMBUF_HEADROOM;
#5 lore raw

PATCH v2 1/2 bond: avoid allocating mempool on socket LCORE_ID_ANY

From: Jan Blunck <[email protected]>

If the numa node is unknown, use the value from rte_socket_id() to avoid an allocation failure.

---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/bonding/rte_eth_bond_8023ad.c +3 -0
index 57b9b32..7826296 100644
@@ -886,7 +886,10 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id)
 
 	RTE_ASSERT(port->rx_ring == NULL);
 	RTE_ASSERT(port->tx_ring == NULL);
+
 	socket_id = rte_eth_devices[slave_id].data->numa_node;
+	if (socket_id == (int)LCORE_ID_ANY)
+		socket_id = rte_socket_id();
 
 	element_size = sizeof(struct slow_protocol_frame) +
 				RTE_PKTMBUF_HEADROOM;
Signature · 1 line
2.9.4
#6 lore raw

PATCH v2 2/2 bond: use rte_eth_dev_socket_id()

From: Jan Blunck <[email protected]>

The bonded device does not have to be a PCI device. Use the rte_ethdev functions instead.

---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -1
index 7826296..65dc75b 100644
@@ -887,7 +887,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id)
 	RTE_ASSERT(port->rx_ring == NULL);
 	RTE_ASSERT(port->tx_ring == NULL);
 
-	socket_id = rte_eth_devices[slave_id].data->numa_node;
+	socket_id = rte_eth_dev_socket_id(slave_id);
 	if (socket_id == (int)LCORE_ID_ANY)
 		socket_id = rte_socket_id();
 
Signature · 1 line
2.9.4