* [PATCH net-next] net/mlx5e: kTLS, Avoid kzalloc(GFP_KERNEL) under spinlock
@ 2020-09-01 14:35 YueHaibing
2020-09-01 17:16 ` Saeed Mahameed
0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2020-09-01 14:35 UTC (permalink / raw)
To: borisp, saeedm, leon, davem, kuba, tariqt
Cc: netdev, linux-rdma, linux-kernel, YueHaibing
A spin lock is held before kzalloc, it may sleep with holding
the spinlock, so we should use GFP_ATOMIC instead.
This is detected by coccinelle.
Fixes: 0419d8c9d8f8 ("net/mlx5e: kTLS, Add kTLS RX resync support")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
index acf6d80a6bb7..1a32435acac3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
@@ -247,7 +247,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,
int err;
u16 pi;
- buf = kzalloc(sizeof(*buf), GFP_KERNEL);
+ buf = kzalloc(sizeof(*buf), GFP_ATOMIC);
if (unlikely(!buf)) {
err = -ENOMEM;
goto err_out;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net/mlx5e: kTLS, Avoid kzalloc(GFP_KERNEL) under spinlock
2020-09-01 14:35 [PATCH net-next] net/mlx5e: kTLS, Avoid kzalloc(GFP_KERNEL) under spinlock YueHaibing
@ 2020-09-01 17:16 ` Saeed Mahameed
0 siblings, 0 replies; 2+ messages in thread
From: Saeed Mahameed @ 2020-09-01 17:16 UTC (permalink / raw)
To: yuehaibing, tariqt, Boris Pismenny, davem, leon, kuba
Cc: netdev, linux-rdma, linux-kernel
On Tue, 2020-09-01 at 22:35 +0800, YueHaibing wrote:
> A spin lock is held before kzalloc, it may sleep with holding
> the spinlock, so we should use GFP_ATOMIC instead.
>
> This is detected by coccinelle.
>
> Fixes: 0419d8c9d8f8 ("net/mlx5e: kTLS, Add kTLS RX resync support")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git
> a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
> index acf6d80a6bb7..1a32435acac3 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
> @@ -247,7 +247,7 @@ resync_post_get_progress_params(struct
> mlx5e_icosq *sq,
> int err;
> u16 pi;
>
> - buf = kzalloc(sizeof(*buf), GFP_KERNEL);
> + buf = kzalloc(sizeof(*buf), GFP_ATOMIC);
> if (unlikely(!buf)) {
> err = -ENOMEM;
> goto err_out;
Thanks for the patch, the kzalloc can move outside the spinlock.
This patch should also go to net.
I will provide a newer version of the patch to deal with this and with
a missing kfree on error handling i found while looking at the code.
Thanks,
Saeed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-01 17:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 14:35 [PATCH net-next] net/mlx5e: kTLS, Avoid kzalloc(GFP_KERNEL) under spinlock YueHaibing
2020-09-01 17:16 ` Saeed Mahameed
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).