diff mbox series

[v2] net/mlx5e: Use kvfree() in mlx5e_accel_fs_tcp_create()

Message ID 20221108140614.12968-1-yuehaibing@huawei.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [v2] net/mlx5e: Use kvfree() in mlx5e_accel_fs_tcp_create() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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: 0 this patch: 0
netdev/checkpatch warning WARNING: 'allocted' may be misspelled - perhaps 'allocated'?
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yue Haibing Nov. 8, 2022, 2:06 p.m. UTC
'accel_tcp' is allocted by kvzalloc(), which should freed by kvfree().

Fixes: f52f2faee581 ("net/mlx5e: Introduce flow steering API")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
v2: fix the same issue in mlx5e_accel_fs_tcp_destroy() and a commit log typo
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Tariq Toukan Nov. 8, 2022, 5:58 p.m. UTC | #1
On 11/8/2022 4:06 PM, YueHaibing wrote:
> 'accel_tcp' is allocted by kvzalloc(), which should freed by kvfree().
> 
> Fixes: f52f2faee581 ("net/mlx5e: Introduce flow steering API")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> v2: fix the same issue in mlx5e_accel_fs_tcp_destroy() and a commit log typo
> ---
>   drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
> index 285d32d2fd08..d7c020f72401 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
> @@ -365,7 +365,7 @@ void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs)
>   	for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++)
>   		accel_fs_tcp_destroy_table(fs, i);
>   
> -	kfree(accel_tcp);
> +	kvfree(accel_tcp);
>   	mlx5e_fs_set_accel_tcp(fs, NULL);
>   }
>   
> @@ -397,7 +397,7 @@ int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs)
>   err_destroy_tables:
>   	while (--i >= 0)
>   		accel_fs_tcp_destroy_table(fs, i);
> -	kfree(accel_tcp);
> +	kvfree(accel_tcp);
>   	mlx5e_fs_set_accel_tcp(fs, NULL);
>   	return err;
>   }

Reviewed-by: Tariq Toukan <tariqt@nvidia.com>

Thanks for your patch.
Eric Dumazet Nov. 8, 2022, 7:45 p.m. UTC | #2
On Tue, Nov 8, 2022 at 9:58 AM Tariq Toukan <ttoukan.linux@gmail.com> wrote:
>
>
>
> On 11/8/2022 4:06 PM, YueHaibing wrote:
> > 'accel_tcp' is allocted by kvzalloc(), which should freed by kvfree().
> >
> > Fixes: f52f2faee581 ("net/mlx5e: Introduce flow steering API")
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> > ---
> > v2: fix the same issue in mlx5e_accel_fs_tcp_destroy() and a commit log typo
> > ---
> >   drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
> > index 285d32d2fd08..d7c020f72401 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
> > @@ -365,7 +365,7 @@ void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs)
> >       for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++)
> >               accel_fs_tcp_destroy_table(fs, i);
> >
> > -     kfree(accel_tcp);
> > +     kvfree(accel_tcp);
> >       mlx5e_fs_set_accel_tcp(fs, NULL);
> >   }
> >
> > @@ -397,7 +397,7 @@ int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs)
> >   err_destroy_tables:
> >       while (--i >= 0)
> >               accel_fs_tcp_destroy_table(fs, i);
> > -     kfree(accel_tcp);
> > +     kvfree(accel_tcp);
> >       mlx5e_fs_set_accel_tcp(fs, NULL);
> >       return err;
> >   }
>
> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
>
> Thanks for your patch.

Although this structure is 64 bytes... Not sure why kvmalloc() has
been used for this small chunk.
Tariq Toukan Nov. 10, 2022, 7:31 a.m. UTC | #3
On 11/8/2022 9:45 PM, Eric Dumazet wrote:
> On Tue, Nov 8, 2022 at 9:58 AM Tariq Toukan <ttoukan.linux@gmail.com> wrote:
>>
>>
>>
>> On 11/8/2022 4:06 PM, YueHaibing wrote:
>>> 'accel_tcp' is allocted by kvzalloc(), which should freed by kvfree().
>>>
>>> Fixes: f52f2faee581 ("net/mlx5e: Introduce flow steering API")
>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>> ---
>>> v2: fix the same issue in mlx5e_accel_fs_tcp_destroy() and a commit log typo
>>> ---
>>>    drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 4 ++--
>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
>>> index 285d32d2fd08..d7c020f72401 100644
>>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
>>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
>>> @@ -365,7 +365,7 @@ void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs)
>>>        for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++)
>>>                accel_fs_tcp_destroy_table(fs, i);
>>>
>>> -     kfree(accel_tcp);
>>> +     kvfree(accel_tcp);
>>>        mlx5e_fs_set_accel_tcp(fs, NULL);
>>>    }
>>>
>>> @@ -397,7 +397,7 @@ int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs)
>>>    err_destroy_tables:
>>>        while (--i >= 0)
>>>                accel_fs_tcp_destroy_table(fs, i);
>>> -     kfree(accel_tcp);
>>> +     kvfree(accel_tcp);
>>>        mlx5e_fs_set_accel_tcp(fs, NULL);
>>>        return err;
>>>    }
>>
>> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
>>
>> Thanks for your patch.
> 
> Although this structure is 64 bytes... Not sure why kvmalloc() has
> been used for this small chunk.

It's a small chunk indeed. Unnecessary usage of kvmalloc.

Although it's not critical (used only in slowpath), it'd be nice to 
clean it up and directly call kzalloc, instead of aligning the kfree().

YueHaibing, can you please submit a v3 for this?

Regards,
Tariq
Yue Haibing Nov. 10, 2022, 11:04 a.m. UTC | #4
On 2022/11/10 15:31, Tariq Toukan wrote:
> 
> 
> On 11/8/2022 9:45 PM, Eric Dumazet wrote:
>> On Tue, Nov 8, 2022 at 9:58 AM Tariq Toukan <ttoukan.linux@gmail.com> wrote:
>>>
>>>
>>>
>>> On 11/8/2022 4:06 PM, YueHaibing wrote:
>>>> 'accel_tcp' is allocted by kvzalloc(), which should freed by kvfree().
>>>>
>>>> Fixes: f52f2faee581 ("net/mlx5e: Introduce flow steering API")
>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>>> ---
>>>> v2: fix the same issue in mlx5e_accel_fs_tcp_destroy() and a commit log typo
>>>> ---
>>>>    drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 4 ++--
>>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
>>>> index 285d32d2fd08..d7c020f72401 100644
>>>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
>>>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
>>>> @@ -365,7 +365,7 @@ void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs)
>>>>        for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++)
>>>>                accel_fs_tcp_destroy_table(fs, i);
>>>>
>>>> -     kfree(accel_tcp);
>>>> +     kvfree(accel_tcp);
>>>>        mlx5e_fs_set_accel_tcp(fs, NULL);
>>>>    }
>>>>
>>>> @@ -397,7 +397,7 @@ int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs)
>>>>    err_destroy_tables:
>>>>        while (--i >= 0)
>>>>                accel_fs_tcp_destroy_table(fs, i);
>>>> -     kfree(accel_tcp);
>>>> +     kvfree(accel_tcp);
>>>>        mlx5e_fs_set_accel_tcp(fs, NULL);
>>>>        return err;
>>>>    }
>>>
>>> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
>>>
>>> Thanks for your patch.
>>
>> Although this structure is 64 bytes... Not sure why kvmalloc() has
>> been used for this small chunk.
> 
> It's a small chunk indeed. Unnecessary usage of kvmalloc.
> 
> Although it's not critical (used only in slowpath), it'd be nice to clean it up and directly call kzalloc, instead of aligning the kfree().
> 
> YueHaibing, can you please submit a v3 for this?

Sure, will resend.
> 
> Regards,
> Tariq
> .
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
index 285d32d2fd08..d7c020f72401 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
@@ -365,7 +365,7 @@  void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs)
 	for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++)
 		accel_fs_tcp_destroy_table(fs, i);
 
-	kfree(accel_tcp);
+	kvfree(accel_tcp);
 	mlx5e_fs_set_accel_tcp(fs, NULL);
 }
 
@@ -397,7 +397,7 @@  int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs)
 err_destroy_tables:
 	while (--i >= 0)
 		accel_fs_tcp_destroy_table(fs, i);
-	kfree(accel_tcp);
+	kvfree(accel_tcp);
 	mlx5e_fs_set_accel_tcp(fs, NULL);
 	return err;
 }