netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH for-rc 1/2] IB/hfi1: Restore kfree in dummy_netdev cleanup
       [not found]   ` <20200624185342.GM6578@ziepe.ca>
@ 2020-06-25 18:11     ` Marciniszyn, Mike
  0 siblings, 0 replies; only message in thread
From: Marciniszyn, Mike @ 2020-06-25 18:11 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: dledford, linux-rdma, Wan, Kaike,
	Dan Carpenter (dan.carpenter@oracle.com),
	Dalessandro, Dennis, David S. Miller, netdev

> 
> 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(&eth->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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-25 18:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200623202519.106975.94246.stgit@awfm-01.aw.intel.com>
     [not found] ` <20200623203224.106975.16926.stgit@awfm-01.aw.intel.com>
     [not found]   ` <20200624185342.GM6578@ziepe.ca>
2020-06-25 18:11     ` [PATCH for-rc 1/2] IB/hfi1: Restore kfree in dummy_netdev cleanup Marciniszyn, Mike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).