Message ID | 20200623203224.106975.16926.stgit@awfm-01.aw.intel.com (mailing list archive) |
---|---|
State | Mainlined |
Commit | b46925a24a9ca7db03655657565e03d2de3027c8 |
Delegated to: | Jason Gunthorpe |
Headers | show |
Series | Fixes for module unload | expand |
On Tue, Jun 23, 2020 at 04:32:24PM -0400, Dennis Dalessandro wrote: > We need to do some rework on the dummy netdev. Calling the free_netdev() would > normally make sense, and that will be addressed in an upcoming patch. For now > just revert the behavior to what it was before keeping the unused variable > removal part of the patch. > > The dd->dumm_netdev is mainly used for packet receiving through > NAPI. Consequently, it is allocated with kcalloc_node instead of > alloc_netdev_mqs for typical net devices. Gross - make sure your rework allocates netdevs using alloc_netdev. Jason
> > Gross - make sure your rework allocates netdevs using alloc_netdev. > I don't think that is the correct solution. All other users of the dummy net device embed it in other structures: init_dummy_netdev(&mal->dummy_dev); init_dummy_netdev(ð->dummy_dev); init_dummy_netdev(&ar->napi_dev); init_dummy_netdev(&irq_grp->napi_ndev); init_dummy_netdev(&wil->napi_ndev); init_dummy_netdev(&trans_pcie->napi_dev); init_dummy_netdev(&dev->napi_dev); init_dummy_netdev(&bus->mux_dev); There is NO explicit free of the dummy since its lifetime is controlled by its parent struct. The fault with the current AIP use of the dummy netdev is that it confuses an is-a with a has-a relationship. This code highlights the confusion by extending the allocation to include the real rx data: const int netdev_size = sizeof(*dd->dummy_netdev) + sizeof(struct hfi1_netdev_priv); <snip> dd->dummy_netdev = kcalloc_node(1, netdev_size, GFP_KERNEL, dd->node); and this kludgy code to find the rx data given a net_device: static inline struct hfi1_netdev_priv *hfi1_netdev_priv(struct net_device *dev) { return (struct hfi1_netdev_priv *)&dev[1]; } The solution is to embed the dummy net_device in a renamed hfi1_netdev_rx struct like other use cases. The lifetime of that struct IS controlled properly and a kfree() of the renamed struct would include the embedded dummy. Mike
diff --git a/drivers/infiniband/hw/hfi1/netdev_rx.c b/drivers/infiniband/hw/hfi1/netdev_rx.c index 63688e8..6d263c9 100644 --- a/drivers/infiniband/hw/hfi1/netdev_rx.c +++ b/drivers/infiniband/hw/hfi1/netdev_rx.c @@ -373,7 +373,7 @@ void hfi1_netdev_free(struct hfi1_devdata *dd) { if (dd->dummy_netdev) { dd_dev_info(dd, "hfi1 netdev freed\n"); - free_netdev(dd->dummy_netdev); + kfree(dd->dummy_netdev); dd->dummy_netdev = NULL; } }