diff mbox series

[iwl-net] ice: add missing napi deletion

Message ID 20230620082454.377001-1-maciej.fijalkowski@intel.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [iwl-net] ice: add missing napi deletion | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers fail 2 blamed authors not CCed: jacob.e.keller@intel.com michal.swiatkowski@linux.intel.com; 7 maintainers not CCed: kuba@kernel.org jesse.brandeburg@intel.com davem@davemloft.net pabeni@redhat.com jacob.e.keller@intel.com michal.swiatkowski@linux.intel.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Maciej Fijalkowski June 20, 2023, 8:24 a.m. UTC
Error path from ice_probe() is missing ice_napi_del() calls, add it to
ice_deinit_eth() as ice_init_eth() was the one to add napi instances. It
is also a good habit to delete napis when removing driver and this also
addresses that. FWIW ice_napi_del() had no callsites.

Fixes: 6624e780a577 ("ice: split ice_vsi_setup into smaller functions")
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_main.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Przemek Kitszel June 20, 2023, 9:58 a.m. UTC | #1
On 6/20/23 10:24, Maciej Fijalkowski wrote:
> Error path from ice_probe() is missing ice_napi_del() calls, add it to
> ice_deinit_eth() as ice_init_eth() was the one to add napi instances. It
> is also a good habit to delete napis when removing driver and this also
> addresses that. FWIW ice_napi_del() had no callsites.
> 
> Fixes: 6624e780a577 ("ice: split ice_vsi_setup into smaller functions")
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
>   drivers/net/ethernet/intel/ice/ice_main.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index cd562856f23a..f6b041490154 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -4485,6 +4485,7 @@ static void ice_deinit_eth(struct ice_pf *pf)
>   	if (!vsi)
>   		return;
>   
> +	ice_napi_del(vsi);
>   	ice_vsi_close(vsi);
>   	ice_unregister_netdev(vsi);
>   	ice_devlink_destroy_pf_port(pf);

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Jakub Kicinski June 20, 2023, 4:53 p.m. UTC | #2
On Tue, 20 Jun 2023 10:24:54 +0200 Maciej Fijalkowski wrote:
> Error path from ice_probe() is missing ice_napi_del() calls, add it to
> ice_deinit_eth() as ice_init_eth() was the one to add napi instances. It
> is also a good habit to delete napis when removing driver and this also
> addresses that. FWIW ice_napi_del() had no callsites.
> 
> Fixes: 6624e780a577 ("ice: split ice_vsi_setup into smaller functions")
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

Is there user visible impact? I agree that it's a good habit, but
since unregister cleans up NAPI instances automatically the patch
is not necessarily a fix.
Maciej Fijalkowski June 20, 2023, 5:22 p.m. UTC | #3
On Tue, Jun 20, 2023 at 09:53:35AM -0700, Jakub Kicinski wrote:
> On Tue, 20 Jun 2023 10:24:54 +0200 Maciej Fijalkowski wrote:
> > Error path from ice_probe() is missing ice_napi_del() calls, add it to
> > ice_deinit_eth() as ice_init_eth() was the one to add napi instances. It
> > is also a good habit to delete napis when removing driver and this also
> > addresses that. FWIW ice_napi_del() had no callsites.
> > 
> > Fixes: 6624e780a577 ("ice: split ice_vsi_setup into smaller functions")
> > Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> 
> Is there user visible impact? I agree that it's a good habit, but
> since unregister cleans up NAPI instances automatically the patch
> is not necessarily a fix.

It's rather free_netdev() not unregistering per se, no? I sent this patch
as I found that cited commit didn't delete napis on ice_probe()'s error
path - I just saw that as a regression. 

But as you're saying when getting rid of netdev we actually do
netif_napi_del() - it seems redundant to do explicit napi delete on remove
path as it is supposed do free the netdev. Does it mean that many drivers
should be verified against that? Sorta tired so might be missing
something, pardon. If not, I'll send a v2 that just removes
ice_napi_del().
Jakub Kicinski June 20, 2023, 5:49 p.m. UTC | #4
On Tue, 20 Jun 2023 19:22:01 +0200 Maciej Fijalkowski wrote:
> On Tue, Jun 20, 2023 at 09:53:35AM -0700, Jakub Kicinski wrote:
> > Is there user visible impact? I agree that it's a good habit, but
> > since unregister cleans up NAPI instances automatically the patch
> > is not necessarily a fix.  
> 
> It's rather free_netdev() not unregistering per se, no? I sent this patch
> as I found that cited commit didn't delete napis on ice_probe()'s error
> path - I just saw that as a regression. 
> 
> But as you're saying when getting rid of netdev we actually do
> netif_napi_del() - it seems redundant to do explicit napi delete on remove
> path as it is supposed do free the netdev. Does it mean that many drivers
> should be verified against that? Sorta tired so might be missing
> something, pardon. If not, I'll send a v2 that just removes
> ice_napi_del().

I personally prefer to keep track of my resources, so I avoid devm_*
and delete NAPI instances by hand. It's up to the author and/or
maintainer of the driver in question.

My only real ask is to no route this via net and drop the Fixes tag.
Whether you prefer to keep the patch as is or drop ice_napi_del() --
up to you.
Maciej Fijalkowski June 21, 2023, 11:43 a.m. UTC | #5
On Tue, Jun 20, 2023 at 10:49:11AM -0700, Jakub Kicinski wrote:
> On Tue, 20 Jun 2023 19:22:01 +0200 Maciej Fijalkowski wrote:
> > On Tue, Jun 20, 2023 at 09:53:35AM -0700, Jakub Kicinski wrote:
> > > Is there user visible impact? I agree that it's a good habit, but
> > > since unregister cleans up NAPI instances automatically the patch
> > > is not necessarily a fix.  
> > 
> > It's rather free_netdev() not unregistering per se, no? I sent this patch
> > as I found that cited commit didn't delete napis on ice_probe()'s error
> > path - I just saw that as a regression. 
> > 
> > But as you're saying when getting rid of netdev we actually do
> > netif_napi_del() - it seems redundant to do explicit napi delete on remove
> > path as it is supposed do free the netdev. Does it mean that many drivers
> > should be verified against that? Sorta tired so might be missing
> > something, pardon. If not, I'll send a v2 that just removes
> > ice_napi_del().
> 
> I personally prefer to keep track of my resources, so I avoid devm_*
> and delete NAPI instances by hand. It's up to the author and/or
> maintainer of the driver in question.

Hmm I am not a fan of devm either but I didn't mean that in my response at
all.

There are quite a few drivers that do this:

net/core/dev.c:
void free_netdev(struct net_device *dev)
{
	(...)
	list_for_each_entry_safe(p, n, &dev->napi_list, dev_list)
		netif_napi_del(p);
	(...)
}

static inline void netif_napi_del(struct napi_struct *napi)
{
	__netif_napi_del(napi);
	synchronize_net();
}

drivers/net/ethernet/xxxcorp/xxx/xxx_main.c:
static void xxx_remove(struct pci_dev *pdev)
{
	// retrieve net_device and napi_struct ptrs

	netif_napi_del(napi); // redundant, covered below
	(...)
	free_netdev(netdev);
	(...)
}

I believe this is what you were referring to originally and I said that
after a short drivers audit there is a bunch going via flow shown
above...plus my patch was trying to introduce that :)

Although in such case __netif_napi_del() will exit early as
NAPI_STATE_LISTED bit was cleared, if driver holds multiple napi instances
we will be going unnecessarily via synchronize_net() calls.

> 
> My only real ask is to no route this via net and drop the Fixes tag.
> Whether you prefer to keep the patch as is or drop ice_napi_del() --
> up to you.

I'll go through -next and remove ice_napi_del(), given the above
explanation what I meant previously.

>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index cd562856f23a..f6b041490154 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -4485,6 +4485,7 @@  static void ice_deinit_eth(struct ice_pf *pf)
 	if (!vsi)
 		return;
 
+	ice_napi_del(vsi);
 	ice_vsi_close(vsi);
 	ice_unregister_netdev(vsi);
 	ice_devlink_destroy_pf_port(pf);