netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>, <davem@davemloft.net>,
	<kuba@kernel.org>, <pabeni@redhat.com>, <edumazet@google.com>,
	<netdev@vger.kernel.org>,
	Michal Swiatkowski <michal.swiatkowski@linux.intel.com>,
	Michal Wilczynski <michal.wilczynski@intel.com>,
	Simon Horman <simon.horman@corigine.com>,
	Arpana Arland <arpanax.arland@intel.com>
Subject: Re: [PATCH net-next 4/6] ice: remove null checks before devm_kfree() calls
Date: Fri, 23 Jun 2023 13:13:57 +0200	[thread overview]
Message-ID: <ZJV+dUvm4Mg1QNeR@boxer> (raw)
In-Reply-To: <ffe3bbdf-eb26-5223-c1ed-1bdbaf577d84@intel.com>

On Fri, Jun 23, 2023 at 12:44:29PM +0200, Przemek Kitszel wrote:
> On 6/23/23 12:23, Maciej Fijalkowski wrote:
> > On Thu, Jun 22, 2023 at 11:35:59AM -0700, Tony Nguyen wrote:
> > > From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> > > 
> > > We all know they are redundant.
> > 
> > Przemek,
> > 
> > Ok, they are redundant, but could you also audit the driver if these devm_
> > allocations could become a plain kzalloc/kfree calls?
> 
> Olek was also motivating such audit :)
> 
> I have some cases collected with intention to send in bulk for next window,
> list is not exhaustive though.

When rev-by count tag would be considered too much? I have a mixed
feelings about providing yet another one, however...

> 
> > 
> > > 
> > > Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> > > Reviewed-by: Michal Wilczynski <michal.wilczynski@intel.com>
> > > Reviewed-by: Simon Horman <simon.horman@corigine.com>
> > > Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> > > Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
> > > Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> > > ---
> > >   drivers/net/ethernet/intel/ice/ice_common.c   |  6 +--
> > >   drivers/net/ethernet/intel/ice/ice_controlq.c |  3 +-
> > >   drivers/net/ethernet/intel/ice/ice_flow.c     | 23 ++--------
> > >   drivers/net/ethernet/intel/ice/ice_lib.c      | 42 +++++++------------
> > >   drivers/net/ethernet/intel/ice/ice_sched.c    | 11 ++---
> > >   drivers/net/ethernet/intel/ice/ice_switch.c   | 19 +++------
> > >   6 files changed, 29 insertions(+), 75 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
> > > index eb2dc0983776..6acb40f3c202 100644
> > > --- a/drivers/net/ethernet/intel/ice/ice_common.c
> > > +++ b/drivers/net/ethernet/intel/ice/ice_common.c
> > > @@ -814,8 +814,7 @@ static void ice_cleanup_fltr_mgmt_struct(struct ice_hw *hw)
> > >   				devm_kfree(ice_hw_to_dev(hw), lst_itr);
> > >   			}
> > >   		}
> > > -		if (recps[i].root_buf)
> > > -			devm_kfree(ice_hw_to_dev(hw), recps[i].root_buf);
> > > +		devm_kfree(ice_hw_to_dev(hw), recps[i].root_buf);
> > >   	}
> > >   	ice_rm_all_sw_replay_rule_info(hw);
> > >   	devm_kfree(ice_hw_to_dev(hw), sw->recp_list);
> > > @@ -1011,8 +1010,7 @@ static int ice_cfg_fw_log(struct ice_hw *hw, bool enable)
> > >   	}
> > >   out:
> > > -	if (data)
> > > -		devm_kfree(ice_hw_to_dev(hw), data);
> > > +	devm_kfree(ice_hw_to_dev(hw), data);
> > >   	return status;
> > >   }
> > > diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.c b/drivers/net/ethernet/intel/ice/ice_controlq.c
> > > index 385fd88831db..e7d2474c431c 100644
> > > --- a/drivers/net/ethernet/intel/ice/ice_controlq.c
> > > +++ b/drivers/net/ethernet/intel/ice/ice_controlq.c
> > > @@ -339,8 +339,7 @@ do {									\
> > >   		}							\
> > >   	}								\
> > >   	/* free the buffer info list */					\
> > > -	if ((qi)->ring.cmd_buf)						\
> > > -		devm_kfree(ice_hw_to_dev(hw), (qi)->ring.cmd_buf);	\
> > > +	devm_kfree(ice_hw_to_dev(hw), (qi)->ring.cmd_buf);		\
> > >   	/* free DMA head */						\
> > >   	devm_kfree(ice_hw_to_dev(hw), (qi)->ring.dma_head);		\
> > >   } while (0)
> > > diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c
> > > index ef103e47a8dc..85cca572c22a 100644
> > > --- a/drivers/net/ethernet/intel/ice/ice_flow.c
> > > +++ b/drivers/net/ethernet/intel/ice/ice_flow.c
> > > @@ -1303,23 +1303,6 @@ ice_flow_find_prof_id(struct ice_hw *hw, enum ice_block blk, u64 prof_id)
> > >   	return NULL;
> > >   }
> > > -/**
> > > - * ice_dealloc_flow_entry - Deallocate flow entry memory
> > > - * @hw: pointer to the HW struct
> > > - * @entry: flow entry to be removed
> > > - */
> > > -static void
> > > -ice_dealloc_flow_entry(struct ice_hw *hw, struct ice_flow_entry *entry)
> > > -{
> > > -	if (!entry)
> > > -		return;
> > > -
> > > -	if (entry->entry)

...would you be able to point me to the chunk of code that actually sets
ice_flow_entry::entry? because from a quick glance I can't seem to find
it.

> > > -		devm_kfree(ice_hw_to_dev(hw), entry->entry);
> > > -
> > > -	devm_kfree(ice_hw_to_dev(hw), entry);
> > > -}
> > > -
> > >   /**
> > >    * ice_flow_rem_entry_sync - Remove a flow entry
> > >    * @hw: pointer to the HW struct
> > > @@ -1335,7 +1318,8 @@ ice_flow_rem_entry_sync(struct ice_hw *hw, enum ice_block __always_unused blk,
> > >   	list_del(&entry->l_entry);
> > > -	ice_dealloc_flow_entry(hw, entry);
> > > +	devm_kfree(ice_hw_to_dev(hw), entry->entry);
> > > +	devm_kfree(ice_hw_to_dev(hw), entry);
> > >   	return 0;
> > >   }
> > > @@ -1662,8 +1646,7 @@ ice_flow_add_entry(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
> > >   out:
> > >   	if (status && e) {
> > > -		if (e->entry)
> > > -			devm_kfree(ice_hw_to_dev(hw), e->entry);
> > > +		devm_kfree(ice_hw_to_dev(hw), e->entry);
> > >   		devm_kfree(ice_hw_to_dev(hw), e);
> > >   	}

(...)

  reply	other threads:[~2023-06-23 11:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22 18:35 [PATCH net-next 0/6][pull request] Intel Wired LAN Driver Updates 2023-06-22 (ice) Tony Nguyen
2023-06-22 18:35 ` [PATCH net-next 1/6] ice: reduce initial wait for control queue messages Tony Nguyen
2023-06-22 18:35 ` [PATCH net-next 2/6] ice: allow hot-swapping XDP programs Tony Nguyen
2023-06-22 18:35 ` [PATCH net-next 3/6] ice: clean up freeing SR-IOV VFs Tony Nguyen
2023-06-22 18:35 ` [PATCH net-next 4/6] ice: remove null checks before devm_kfree() calls Tony Nguyen
2023-06-23 10:23   ` Maciej Fijalkowski
2023-06-23 10:44     ` Przemek Kitszel
2023-06-23 11:13       ` Maciej Fijalkowski [this message]
2023-06-23 13:21         ` Przemek Kitszel
2023-06-23 13:25           ` Maciej Fijalkowski
2023-06-23 14:28             ` Przemek Kitszel
2023-06-23 14:40               ` Maciej Fijalkowski
2023-06-22 18:36 ` [PATCH net-next 5/6] ice: Remove managed memory usage in ice_get_fw_log_cfg() Tony Nguyen
2023-06-22 18:36 ` [PATCH net-next 6/6] ice: use ice_down_up() where applicable Tony Nguyen
2023-06-24 22:40 ` [PATCH net-next 0/6][pull request] Intel Wired LAN Driver Updates 2023-06-22 (ice) patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZJV+dUvm4Mg1QNeR@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=arpanax.arland@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=michal.wilczynski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=simon.horman@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).