[dpdk-dev,1/2] bond: avoid allocating mempool on socket LCORE_ID_ANY

Message ID 1493242208-19526-1-git-send-email-jblunck@infradead.org (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jan Blunck April 26, 2017, 9:30 p.m. UTC
  If the numa node is unknown, use the value from rte_socket_id() to avoid
an allocation failure.

Signed-off-by: Eric Kinzie <ekinzie@brocade.com>
CC: Eric Kinzie <ehkinzie@gmail.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Doherty, Declan June 28, 2017, 9:47 a.m. UTC | #1
On 26/04/17 22:30, Jan Blunck wrote:
> If the numa node is unknown, use the value from rte_socket_id() to avoid
> an allocation failure.
> 
> Signed-off-by: Eric Kinzie <ekinzie@brocade.com>
> CC: Eric Kinzie <ehkinzie@gmail.com>
> ---
>   drivers/net/bonding/rte_eth_bond_8023ad.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index 7b863d6..b8df536 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -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

> +		socket_id = 0;

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

>   
>   	element_size = sizeof(struct slow_protocol_frame) +
>   				RTE_PKTMBUF_HEADROOM;
>
  
Jan Blunck June 28, 2017, noon UTC | #2
On Wed, Jun 28, 2017 at 11:47 AM, Declan Doherty
<declan.doherty@intel.com> wrote:
> On 26/04/17 22:30, Jan Blunck wrote:
>>
>> If the numa node is unknown, use the value from rte_socket_id() to avoid
>> an allocation failure.
>>
>> Signed-off-by: Eric Kinzie <ekinzie@brocade.com>
>> CC: Eric Kinzie <ehkinzie@gmail.com>
>> ---
>>   drivers/net/bonding/rte_eth_bond_8023ad.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c
>> b/drivers/net/bonding/rte_eth_bond_8023ad.c
>> index 7b863d6..b8df536 100644
>> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
>> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
>> @@ -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.

>> +               socket_id = 0;
>
>
> Should this not be socket_id = rte_socket_id(); as we don't know we are
> running on
>
>
>>         element_size = sizeof(struct slow_protocol_frame) +
>>                                 RTE_PKTMBUF_HEADROOM;
>>
>
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 7b863d6..b8df536 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -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;