2023-06-11 21:44:19

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH net-next] ice: Remove managed memory usage in ice_get_fw_log_cfg()

There is no need to use managed memory allocation here. The memory is
released at the end of the function.

You kzalloc()/kfree() to simplify the code.

Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/net/ethernet/intel/ice/ice_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index eb2dc0983776..4b799a5d378a 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -834,7 +834,7 @@ static int ice_get_fw_log_cfg(struct ice_hw *hw)
u16 size;

size = sizeof(*config) * ICE_AQC_FW_LOG_ID_MAX;
- config = devm_kzalloc(ice_hw_to_dev(hw), size, GFP_KERNEL);
+ config = kzalloc(size, GFP_KERNEL);
if (!config)
return -ENOMEM;

@@ -857,7 +857,7 @@ static int ice_get_fw_log_cfg(struct ice_hw *hw)
}
}

- devm_kfree(ice_hw_to_dev(hw), config);
+ kfree(config);

return status;
}
--
2.34.1



2023-06-12 04:50:08

by Pavan Chebbi

[permalink] [raw]
Subject: Re: [PATCH net-next] ice: Remove managed memory usage in ice_get_fw_log_cfg()

On Mon, Jun 12, 2023 at 2:14 AM Christophe JAILLET
<[email protected]> wrote:
>
> There is no need to use managed memory allocation here. The memory is
> released at the end of the function.
>
> You kzalloc()/kfree() to simplify the code.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/net/ethernet/intel/ice/ice_common.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Looks good to me.
Reviewed-by: Pavan Chebbi <[email protected]>

>
> diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
> index eb2dc0983776..4b799a5d378a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_common.c
> +++ b/drivers/net/ethernet/intel/ice/ice_common.c
> @@ -834,7 +834,7 @@ static int ice_get_fw_log_cfg(struct ice_hw *hw)
> u16 size;
>
> size = sizeof(*config) * ICE_AQC_FW_LOG_ID_MAX;
> - config = devm_kzalloc(ice_hw_to_dev(hw), size, GFP_KERNEL);
> + config = kzalloc(size, GFP_KERNEL);
> if (!config)
> return -ENOMEM;
>
> @@ -857,7 +857,7 @@ static int ice_get_fw_log_cfg(struct ice_hw *hw)
> }
> }
>
> - devm_kfree(ice_hw_to_dev(hw), config);
> + kfree(config);
>
> return status;
> }
> --
> 2.34.1
>
>


Attachments:
smime.p7s (4.11 kB)
S/MIME Cryptographic Signature

2023-06-12 06:11:49

by Jacob Keller

[permalink] [raw]
Subject: RE: [Intel-wired-lan] [PATCH net-next] ice: Remove managed memory usage in ice_get_fw_log_cfg()



> -----Original Message-----
> From: Intel-wired-lan <[email protected]> On Behalf Of
> Christophe JAILLET
> Sent: Sunday, June 11, 2023 1:44 PM
> To: Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L
> <[email protected]>; David S. Miller <[email protected]>; Eric
> Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo
> Abeni <[email protected]>
> Cc: Christophe JAILLET <[email protected]>; intel-wired-
> [email protected]; [email protected]; linux-
> [email protected]; [email protected]
> Subject: [Intel-wired-lan] [PATCH net-next] ice: Remove managed memory usage
> in ice_get_fw_log_cfg()
>
> There is no need to use managed memory allocation here. The memory is
> released at the end of the function.
>
> You kzalloc()/kfree() to simplify the code.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---

Agreed.

Reviewed-by: Jacob Keller <[email protected]>

> drivers/net/ethernet/intel/ice/ice_common.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_common.c
> b/drivers/net/ethernet/intel/ice/ice_common.c
> index eb2dc0983776..4b799a5d378a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_common.c
> +++ b/drivers/net/ethernet/intel/ice/ice_common.c
> @@ -834,7 +834,7 @@ static int ice_get_fw_log_cfg(struct ice_hw *hw)
> u16 size;
>
> size = sizeof(*config) * ICE_AQC_FW_LOG_ID_MAX;
> - config = devm_kzalloc(ice_hw_to_dev(hw), size, GFP_KERNEL);
> + config = kzalloc(size, GFP_KERNEL);
> if (!config)
> return -ENOMEM;
>
> @@ -857,7 +857,7 @@ static int ice_get_fw_log_cfg(struct ice_hw *hw)
> }
> }
>
> - devm_kfree(ice_hw_to_dev(hw), config);
> + kfree(config);
>
> return status;
> }
> --
> 2.34.1
>
> _______________________________________________
> Intel-wired-lan mailing list
> [email protected]
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

2023-06-12 06:49:00

by Paul Menzel

[permalink] [raw]
Subject: Re: [Intel-wired-lan] [PATCH net-next] ice: Remove managed memory usage in ice_get_fw_log_cfg()

Dear Christophe,


Thank you for the patch.

Am 11.06.23 um 22:44 schrieb Christophe JAILLET:
> There is no need to use managed memory allocation here. The memory is
> released at the end of the function.
>
> You kzalloc()/kfree() to simplify the code.

s/You/Use/?


Kind regards,

Paul


> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/net/ethernet/intel/ice/ice_common.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
> index eb2dc0983776..4b799a5d378a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_common.c
> +++ b/drivers/net/ethernet/intel/ice/ice_common.c
> @@ -834,7 +834,7 @@ static int ice_get_fw_log_cfg(struct ice_hw *hw)
> u16 size;
>
> size = sizeof(*config) * ICE_AQC_FW_LOG_ID_MAX;
> - config = devm_kzalloc(ice_hw_to_dev(hw), size, GFP_KERNEL);
> + config = kzalloc(size, GFP_KERNEL);
> if (!config)
> return -ENOMEM;
>
> @@ -857,7 +857,7 @@ static int ice_get_fw_log_cfg(struct ice_hw *hw)
> }
> }
>
> - devm_kfree(ice_hw_to_dev(hw), config);
> + kfree(config);
>
> return status;
> }