[dpdk-dev] [PATCH v6 7/7] vhost: convert inflight data to DPDK allocation API

Maxime Coquelin maxime.coquelin at redhat.com
Tue Jun 29 16:36:34 CEST 2021


Hi Chenbo,

On 6/25/21 9:26 AM, Xia, Chenbo wrote:
> Hi Maxime,
> 
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin at redhat.com>
>> Sent: Friday, June 18, 2021 10:04 PM
>> To: dev at dpdk.org; david.marchand at redhat.com; Xia, Chenbo <chenbo.xia at intel.com>
>> Cc: Maxime Coquelin <maxime.coquelin at redhat.com>
>> Subject: [PATCH v6 7/7] vhost: convert inflight data to DPDK allocation API
>>
>> Inflight metadata are allocated using glibc's calloc.
>> This patch converts them to rte_zmalloc_socket to take
>> care of the NUMA affinity.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
>> ---
>>  lib/vhost/vhost.c      |  4 +--
>>  lib/vhost/vhost_user.c | 67 +++++++++++++++++++++++++++++++++++-------
>>  2 files changed, 58 insertions(+), 13 deletions(-)
>>
>> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
>> index 0000cd3297..53a470f547 100644
>> --- a/lib/vhost/vhost.c
>> +++ b/lib/vhost/vhost.c
> 
> [...]
> 
>> @@ -1779,15 +1820,17 @@ vhost_check_queue_inflights_split(struct virtio_net
>> *dev,
>>  	vq->last_avail_idx += resubmit_num;
>>
>>  	if (resubmit_num) {
>> -		resubmit  = calloc(1, sizeof(struct rte_vhost_resubmit_info));
>> +		resubmit  = rte_zmalloc_socket("resubmit", sizeof(struct
>> rte_vhost_resubmit_info),
>> +				0, vq->numa_node);
>>  		if (!resubmit) {
>>  			VHOST_LOG_CONFIG(ERR,
>>  				"failed to allocate memory for resubmit info.\n");
>>  			return RTE_VHOST_MSG_RESULT_ERR;
>>  		}
>>
>> -		resubmit->resubmit_list = calloc(resubmit_num,
>> -			sizeof(struct rte_vhost_resubmit_desc));
>> +		resubmit->resubmit_list = rte_zmalloc_socket("resubmit_list",
>> +				resubmit_num * sizeof(struct rte_vhost_resubmit_desc),
>> +				0, vq->numa_node);
>>  		if (!resubmit->resubmit_list) {
>>  			VHOST_LOG_CONFIG(ERR,
>>  				"failed to allocate memory for inflight desc.\n");
>> @@ -1873,15 +1916,17 @@ vhost_check_queue_inflights_packed(struct virtio_net
>> *dev,
>>  	}
>>
>>  	if (resubmit_num) {
>> -		resubmit = calloc(1, sizeof(struct rte_vhost_resubmit_info));
>> +		resubmit  = rte_zmalloc_socket("resubmit", sizeof(struct
>> rte_vhost_resubmit_info),
>> +				0, vq->numa_node);
> 
> There are still two 'free(resubmit)' in vhost_check_queue_inflights_split and
> vhost_check_queue_inflights_packed, which should be replaced with rte_free()

Good catch, I'll fix this in next revision.

Thanks,
Maxime

> Thanks,
> Chenbo 
> 
>>  		if (resubmit == NULL) {
>>  			VHOST_LOG_CONFIG(ERR,
>>  				"failed to allocate memory for resubmit info.\n");
>>  			return RTE_VHOST_MSG_RESULT_ERR;
>>  		}
>>
>> -		resubmit->resubmit_list = calloc(resubmit_num,
>> -			sizeof(struct rte_vhost_resubmit_desc));
>> +		resubmit->resubmit_list = rte_zmalloc_socket("resubmit_list",
>> +				resubmit_num * sizeof(struct rte_vhost_resubmit_desc),
>> +				0, vq->numa_node);
>>  		if (resubmit->resubmit_list == NULL) {
>>  			VHOST_LOG_CONFIG(ERR,
>>  				"failed to allocate memory for resubmit desc.\n");
>> --
>> 2.31.1
> 



More information about the dev mailing list