All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: wwan: t7xx: fix GFP_KERNEL usage in spin_lock context
@ 2022-05-14  9:14 Ziyang Xuan
  2022-05-16 20:36 ` Sergey Ryazanov
  0 siblings, 1 reply; 4+ messages in thread
From: Ziyang Xuan @ 2022-05-14  9:14 UTC (permalink / raw)
  To: chandrashekar.devegowda, linuxwwan, chiranjeevi.rapolu,
	haijun.liu, m.chetan.kumar, ricardo.martinez, loic.poulain,
	ryazanov.s.a, davem, edumazet, kuba, pabeni, netdev
  Cc: linux-kernel

t7xx_cldma_clear_rxq() call t7xx_cldma_alloc_and_map_skb() in spin_lock
context, But __dev_alloc_skb() in t7xx_cldma_alloc_and_map_skb() uses
GFP_KERNEL, that will introduce scheduling factor in spin_lock context.

Replace GFP_KERNEL with GFP_ATOMIC to fix it.

Fixes: 39d439047f1d ("net: wwan: t7xx: Add control DMA interface")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 drivers/net/wwan/t7xx/t7xx_hif_cldma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
index 46066dcd2607..54c34639f1a5 100644
--- a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
+++ b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
@@ -93,7 +93,7 @@ static void t7xx_cldma_gpd_set_next_ptr(struct cldma_gpd *gpd, dma_addr_t next_p
 static int t7xx_cldma_alloc_and_map_skb(struct cldma_ctrl *md_ctrl, struct cldma_request *req,
 					size_t size)
 {
-	req->skb = __dev_alloc_skb(size, GFP_KERNEL);
+	req->skb = __dev_alloc_skb(size, GFP_ATOMIC);
 	if (!req->skb)
 		return -ENOMEM;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: wwan: t7xx: fix GFP_KERNEL usage in spin_lock context
  2022-05-14  9:14 [PATCH net-next] net: wwan: t7xx: fix GFP_KERNEL usage in spin_lock context Ziyang Xuan
@ 2022-05-16 20:36 ` Sergey Ryazanov
  2022-05-16 20:57   ` Martinez, Ricardo
  0 siblings, 1 reply; 4+ messages in thread
From: Sergey Ryazanov @ 2022-05-16 20:36 UTC (permalink / raw)
  To: Ziyang Xuan
  Cc: Devegowda, Chandrashekar, Intel Corporation, chiranjeevi.rapolu,
	Haijun Liu (刘海军),
	M Chetan Kumar, Ricardo Martinez, Loic Poulain, David Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, open list

Hello Ziyang,

On Sat, May 14, 2022 at 11:57 AM Ziyang Xuan
<william.xuanziyang@huawei.com> wrote:
> t7xx_cldma_clear_rxq() call t7xx_cldma_alloc_and_map_skb() in spin_lock
> context, But __dev_alloc_skb() in t7xx_cldma_alloc_and_map_skb() uses
> GFP_KERNEL, that will introduce scheduling factor in spin_lock context.
>
> Replace GFP_KERNEL with GFP_ATOMIC to fix it.

Would not it will be more reliable to just rework
t7xx_cldma_clear_rxq() to avoid calling t7xx_cldma_alloc_and_map_skb()
under the spin lock instead of doing each allocation with GFP_ATOMIC?
E.g. t7xx_cldma_gpd_rx_from_q() calls t7xx_cldma_alloc_and_map_skb()
avoiding any lock holding.

-- 
Sergey

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: wwan: t7xx: fix GFP_KERNEL usage in spin_lock context
  2022-05-16 20:36 ` Sergey Ryazanov
@ 2022-05-16 20:57   ` Martinez, Ricardo
  2022-05-17  3:12     ` Ziyang Xuan (William)
  0 siblings, 1 reply; 4+ messages in thread
From: Martinez, Ricardo @ 2022-05-16 20:57 UTC (permalink / raw)
  To: Sergey Ryazanov, Ziyang Xuan
  Cc: Devegowda, Chandrashekar, Intel Corporation, chiranjeevi.rapolu,
	Haijun Liu (刘海军),
	M Chetan Kumar, Loic Poulain, David Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, open list


On 5/16/2022 1:36 PM, Sergey Ryazanov wrote:
> Hello Ziyang,
>
> On Sat, May 14, 2022 at 11:57 AM Ziyang Xuan
> <william.xuanziyang@huawei.com> wrote:
>> t7xx_cldma_clear_rxq() call t7xx_cldma_alloc_and_map_skb() in spin_lock
>> context, But __dev_alloc_skb() in t7xx_cldma_alloc_and_map_skb() uses
>> GFP_KERNEL, that will introduce scheduling factor in spin_lock context.
>>
>> Replace GFP_KERNEL with GFP_ATOMIC to fix it.
> Would not it will be more reliable to just rework
> t7xx_cldma_clear_rxq() to avoid calling t7xx_cldma_alloc_and_map_skb()
> under the spin lock instead of doing each allocation with GFP_ATOMIC?
> E.g. t7xx_cldma_gpd_rx_from_q() calls t7xx_cldma_alloc_and_map_skb()
> avoiding any lock holding.

t7xx_cldma_clear_rxq() is a helper for t7xx_cldma_clear_all_qs() which 
is only called by t7xx_cldma_exception() after stopping CLDMA, so it 
should be OK to remove the spin lock from t7xx_cldma_clear_rxq().


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: wwan: t7xx: fix GFP_KERNEL usage in spin_lock context
  2022-05-16 20:57   ` Martinez, Ricardo
@ 2022-05-17  3:12     ` Ziyang Xuan (William)
  0 siblings, 0 replies; 4+ messages in thread
From: Ziyang Xuan (William) @ 2022-05-17  3:12 UTC (permalink / raw)
  To: Martinez, Ricardo, Sergey Ryazanov
  Cc: Devegowda, Chandrashekar, Intel Corporation, chiranjeevi.rapolu,
	Haijun Liu (刘海军),
	M Chetan Kumar, Loic Poulain, David Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, open list

> 
> On 5/16/2022 1:36 PM, Sergey Ryazanov wrote:
>> Hello Ziyang,
>>
>> On Sat, May 14, 2022 at 11:57 AM Ziyang Xuan
>> <william.xuanziyang@huawei.com> wrote:
>>> t7xx_cldma_clear_rxq() call t7xx_cldma_alloc_and_map_skb() in spin_lock
>>> context, But __dev_alloc_skb() in t7xx_cldma_alloc_and_map_skb() uses
>>> GFP_KERNEL, that will introduce scheduling factor in spin_lock context.
>>>
>>> Replace GFP_KERNEL with GFP_ATOMIC to fix it.
>> Would not it will be more reliable to just rework
>> t7xx_cldma_clear_rxq() to avoid calling t7xx_cldma_alloc_and_map_skb()
>> under the spin lock instead of doing each allocation with GFP_ATOMIC?
>> E.g. t7xx_cldma_gpd_rx_from_q() calls t7xx_cldma_alloc_and_map_skb()
>> avoiding any lock holding.
> 
> t7xx_cldma_clear_rxq() is a helper for t7xx_cldma_clear_all_qs() which is only called by t7xx_cldma_exception() after stopping CLDMA, so it should be OK to remove the spin lock from t7xx_cldma_clear_rxq().
> 

OK, I see. Thus we can remove spink_lock and annotate it.

> 
> .

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-17  3:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-14  9:14 [PATCH net-next] net: wwan: t7xx: fix GFP_KERNEL usage in spin_lock context Ziyang Xuan
2022-05-16 20:36 ` Sergey Ryazanov
2022-05-16 20:57   ` Martinez, Ricardo
2022-05-17  3:12     ` Ziyang Xuan (William)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.