[dpdk-dev] [RFC V1] examples/l3fwd-power: fix memory leak for rte_pci_device

Huisong Li lihuisong at huawei.com
Wed Sep 8 04:01:41 CEST 2021


Hi, Thomas

在 2021/9/7 16:53, Thomas Monjalon 写道:
> 07/09/2021 05:41, Huisong Li:
>> Calling rte_eth_dev_close() will release resources of eth device and close
>> it. But rte_pci_device struct isn't released when app exit, which will lead
>> to memory leak.
> That's a PMD issue.
> When the last port of a PCI device is closed, the device should be freed.

Why is this a PMD problem? I don't understand.

As far as I know, most apps or examples in the DPDK project have only 
one port for a pci device.

When the port is closed, the rte_pci_device should be freed. But none of 
the apps seem to do this.

>
>> +		/* Retrieve device address in eth device before closing it. */
>> +		eth_dev = &rte_eth_devices[portid];
> You should not access this array, considered internal.

We have to save the address of rte_device to free rte_pci_device before 
closing eth device.

Because the the device address in rte_eth_dev struct will be set to a 
NULL after closing eth device.

It's also handled in OVS in this way.

>
>> +		rte_dev = eth_dev->device;
>>   		rte_eth_dev_close(portid);
>> +		ret = rte_dev_remove(rte_dev);
>
>
> .


More information about the dev mailing list