Re: [dpdk-dev] [RFC V1] examples/l3fwd-power: fix memory leak for rte_pci_device
From: Huisong Li <lihuisong@huawei.com>
Date: 2021-09-08 02:01:47
From: Huisong Li <lihuisong@huawei.com>
Date: 2021-09-08 02:01:47
Hi, Thomas 在 2021/9/7 16:53, Thomas Monjalon 写道:
07/09/2021 05:41, Huisong Li:quoted
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.
quoted
+ /* 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.
quoted
+ rte_dev = eth_dev->device; rte_eth_dev_close(portid); + ret = rte_dev_remove(rte_dev);.