diff mbox series

[net,v2] octeontx2-pf: Avoid use of GFP_KERNEL in atomic context

Message ID 20230113061902.6061-1-gakula@marvell.com (mailing list archive)
State Accepted
Commit 87b93b678e95c7d93fe6a55b0e0fbda26d8c7760
Delegated to: Netdev Maintainers
Headers show
Series [net,v2] octeontx2-pf: Avoid use of GFP_KERNEL in atomic context | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
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 9 of 9 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: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Geetha sowjanya Jan. 13, 2023, 6:19 a.m. UTC
Using GFP_KERNEL in preemption disable context, causing below warning
when CONFIG_DEBUG_ATOMIC_SLEEP is enabled.

[   32.542271] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:274
[   32.550883] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
[   32.558707] preempt_count: 1, expected: 0
[   32.562710] RCU nest depth: 0, expected: 0
[   32.566800] CPU: 3 PID: 1 Comm: swapper/0 Tainted: G        W          6.2.0-rc2-00269-gae9dcb91c606 #7
[   32.576188] Hardware name: Marvell CN106XX board (DT)
[   32.581232] Call trace:
[   32.583670]  dump_backtrace.part.0+0xe0/0xf0
[   32.587937]  show_stack+0x18/0x30
[   32.591245]  dump_stack_lvl+0x68/0x84
[   32.594900]  dump_stack+0x18/0x34
[   32.598206]  __might_resched+0x12c/0x160
[   32.602122]  __might_sleep+0x48/0xa0
[   32.605689]  __kmem_cache_alloc_node+0x2b8/0x2e0
[   32.610301]  __kmalloc+0x58/0x190
[   32.613610]  otx2_sq_aura_pool_init+0x1a8/0x314
[   32.618134]  otx2_open+0x1d4/0x9d0

To avoid use of GFP_ATOMIC for memory allocation, disable preemption 
after all memory allocation is done.

Fixes: 4af1b64f80fb ("octeontx2-pf: Fix lmtst ID used in aura free")
Signed-off-by: Geetha sowjanya <gakula@marvell.com>
Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com>
---
v1-v2:
- Moved get_cpu to avolid use of GFP_ATOMIC. 
- reworked commit message.

 drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Leon Romanovsky Jan. 15, 2023, 11:38 a.m. UTC | #1
On Fri, Jan 13, 2023 at 11:49:02AM +0530, Geetha sowjanya wrote:
> Using GFP_KERNEL in preemption disable context, causing below warning
> when CONFIG_DEBUG_ATOMIC_SLEEP is enabled.
> 
> [   32.542271] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:274
> [   32.550883] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
> [   32.558707] preempt_count: 1, expected: 0
> [   32.562710] RCU nest depth: 0, expected: 0
> [   32.566800] CPU: 3 PID: 1 Comm: swapper/0 Tainted: G        W          6.2.0-rc2-00269-gae9dcb91c606 #7
> [   32.576188] Hardware name: Marvell CN106XX board (DT)
> [   32.581232] Call trace:
> [   32.583670]  dump_backtrace.part.0+0xe0/0xf0
> [   32.587937]  show_stack+0x18/0x30
> [   32.591245]  dump_stack_lvl+0x68/0x84
> [   32.594900]  dump_stack+0x18/0x34
> [   32.598206]  __might_resched+0x12c/0x160
> [   32.602122]  __might_sleep+0x48/0xa0
> [   32.605689]  __kmem_cache_alloc_node+0x2b8/0x2e0
> [   32.610301]  __kmalloc+0x58/0x190
> [   32.613610]  otx2_sq_aura_pool_init+0x1a8/0x314
> [   32.618134]  otx2_open+0x1d4/0x9d0
> 
> To avoid use of GFP_ATOMIC for memory allocation, disable preemption 
> after all memory allocation is done.
> 
> Fixes: 4af1b64f80fb ("octeontx2-pf: Fix lmtst ID used in aura free")
> Signed-off-by: Geetha sowjanya <gakula@marvell.com>
> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com>
> ---
> v1-v2:
> - Moved get_cpu to avolid use of GFP_ATOMIC. 
> - reworked commit message.
> 
>  drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
patchwork-bot+netdevbpf@kernel.org Jan. 16, 2023, 2:10 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 13 Jan 2023 11:49:02 +0530 you wrote:
> Using GFP_KERNEL in preemption disable context, causing below warning
> when CONFIG_DEBUG_ATOMIC_SLEEP is enabled.
> 
> [   32.542271] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:274
> [   32.550883] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
> [   32.558707] preempt_count: 1, expected: 0
> [   32.562710] RCU nest depth: 0, expected: 0
> [   32.566800] CPU: 3 PID: 1 Comm: swapper/0 Tainted: G        W          6.2.0-rc2-00269-gae9dcb91c606 #7
> [   32.576188] Hardware name: Marvell CN106XX board (DT)
> [   32.581232] Call trace:
> [   32.583670]  dump_backtrace.part.0+0xe0/0xf0
> [   32.587937]  show_stack+0x18/0x30
> [   32.591245]  dump_stack_lvl+0x68/0x84
> [   32.594900]  dump_stack+0x18/0x34
> [   32.598206]  __might_resched+0x12c/0x160
> [   32.602122]  __might_sleep+0x48/0xa0
> [   32.605689]  __kmem_cache_alloc_node+0x2b8/0x2e0
> [   32.610301]  __kmalloc+0x58/0x190
> [   32.613610]  otx2_sq_aura_pool_init+0x1a8/0x314
> [   32.618134]  otx2_open+0x1d4/0x9d0
> 
> [...]

Here is the summary with links:
  - [net,v2] octeontx2-pf: Avoid use of GFP_KERNEL in atomic context
    https://git.kernel.org/netdev/net/c/87b93b678e95

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
index 88f8772a61cd..497b777b6a34 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
@@ -1370,7 +1370,6 @@  int otx2_sq_aura_pool_init(struct otx2_nic *pfvf)
 	if (err)
 		goto fail;
 
-	get_cpu();
 	/* Allocate pointers and free them to aura/pool */
 	for (qidx = 0; qidx < hw->tot_tx_queues; qidx++) {
 		pool_id = otx2_get_pool_idx(pfvf, AURA_NIX_SQ, qidx);
@@ -1388,13 +1387,14 @@  int otx2_sq_aura_pool_init(struct otx2_nic *pfvf)
 			err = otx2_alloc_rbuf(pfvf, pool, &bufptr);
 			if (err)
 				goto err_mem;
+			get_cpu();
 			pfvf->hw_ops->aura_freeptr(pfvf, pool_id, bufptr);
+			put_cpu();
 			sq->sqb_ptrs[sq->sqb_count++] = (u64)bufptr;
 		}
 	}
 
 err_mem:
-	put_cpu();
 	return err ? -ENOMEM : 0;
 
 fail: