Message ID | 20230107044139.25787-1-gakula@marvell.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] octeontx2-pf: Use GFP_ATOMIC in atomic context | expand |
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 | warning | WARNING: line length of 84 exceeds 80 columns |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Sat, Jan 07, 2023 at 10:11:39AM +0530, Geetha sowjanya wrote: > Use GFP_ATOMIC flag instead of GFP_KERNEL while allocating memory > in atomic context. Awesome, but the changed functions don't run in atomic context. > > Fixes: 4af1b64f80fb ("octeontx2-pf: Fix lmtst ID used in aura free") > Signed-off-by: Sunil Goutham <sgoutham@marvell.com> > Signed-off-by: Geetha sowjanya <gakula@marvell.com> > --- > drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > index 88f8772a61cd..12e4365d53df 100644 > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > @@ -886,7 +886,7 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura) > } > > sq->sqe_base = sq->sqe->base; > - sq->sg = kcalloc(qset->sqe_cnt, sizeof(struct sg_list), GFP_KERNEL); > + sq->sg = kcalloc(qset->sqe_cnt, sizeof(struct sg_list), GFP_ATOMIC); > if (!sq->sg) > return -ENOMEM; > > @@ -1378,7 +1378,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf) > > sq = &qset->sq[qidx]; > sq->sqb_count = 0; > - sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(*sq->sqb_ptrs), GFP_KERNEL); > + sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(*sq->sqb_ptrs), GFP_ATOMIC); > if (!sq->sqb_ptrs) { > err = -ENOMEM; > goto err_mem; > -- > 2.25.1 >
-----Original Message----- From: Leon Romanovsky <leon@kernel.org> Sent: Sunday, January 8, 2023 6:39 PM To: Geethasowjanya Akula <gakula@marvell.com> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kuba@kernel.org; pabeni@redhat.com; davem@davemloft.net; edumazet@google.com; Subbaraya Sundeep Bhatta <sbhatta@marvell.com>; Hariprasad Kelam <hkelam@marvell.com>; Sunil Kovvuri Goutham <sgoutham@marvell.com> Subject: [EXT] Re: [net PATCH] octeontx2-pf: Use GFP_ATOMIC in atomic context External Email ---------------------------------------------------------------------- On Sat, Jan 07, 2023 at 10:11:39AM +0530, Geetha sowjanya wrote: >> Use GFP_ATOMIC flag instead of GFP_KERNEL while allocating memory in >> atomic context. >Awesome, but the changed functions don't run in atomic context. drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c 1368 /* Flush accumulated messages */ 1369 err = otx2_sync_mbox_msg(&pfvf->mbox); 1370 if (err) 1371 goto fail; 1372 1373 get_cpu(); ^^^^^^^^^ The get_cpu() disables preemption. 1374 /* Allocate pointers and free them to aura/pool */ 1375 for (qidx = 0; qidx < hw->tot_tx_queues; qidx++) { 1376 pool_id = otx2_get_pool_idx(pfvf, AURA_NIX_SQ, qidx); 1377 pool = &pfvf->qset.pool[pool_id]; 1378 1379 sq = &qset->sq[qidx]; 1380 sq->sqb_count = 0; 1381 sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(*sq->sqb_ptrs), GFP_ATOMIC); >> Fixes: 4af1b64f80fb ("octeontx2-pf: Fix lmtst ID used in aura free") >> Signed-off-by: Sunil Goutham <sgoutham@marvell.com> >> Signed-off-by: Geetha sowjanya <gakula@marvell.com> >> --- >> drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c >> b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c >> index 88f8772a61cd..12e4365d53df 100644 >> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c >> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c >> @@ -886,7 +886,7 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura) >> } >> >> sq->sqe_base = sq->sqe->base; >> - sq->sg = kcalloc(qset->sqe_cnt, sizeof(struct sg_list), GFP_KERNEL); >> + sq->sg = kcalloc(qset->sqe_cnt, sizeof(struct sg_list), >> +GFP_ATOMIC); >> if (!sq->sg) >> return -ENOMEM; >> >> @@ -1378,7 +1378,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic >> *pfvf) >> >> sq = &qset->sq[qidx]; >> sq->sqb_count = 0; >> - sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(*sq->sqb_ptrs), GFP_KERNEL); >> + sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(*sq->sqb_ptrs), >> +GFP_ATOMIC); >> if (!sq->sqb_ptrs) { >> err = -ENOMEM; >> goto err_mem; >> -- >> 2.25.1 >>
On Tue, Jan 10, 2023 at 8:54 AM Geethasowjanya Akula <gakula@marvell.com> wrote: > > > > -----Original Message----- > From: Leon Romanovsky <leon@kernel.org> > Sent: Sunday, January 8, 2023 6:39 PM > To: Geethasowjanya Akula <gakula@marvell.com> > Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kuba@kernel.org; pabeni@redhat.com; davem@davemloft.net; edumazet@google.com; Subbaraya Sundeep Bhatta <sbhatta@marvell.com>; Hariprasad Kelam <hkelam@marvell.com>; Sunil Kovvuri Goutham <sgoutham@marvell.com> > Subject: [EXT] Re: [net PATCH] octeontx2-pf: Use GFP_ATOMIC in atomic context > > External Email > > ---------------------------------------------------------------------- > On Sat, Jan 07, 2023 at 10:11:39AM +0530, Geetha sowjanya wrote: > >> Use GFP_ATOMIC flag instead of GFP_KERNEL while allocating memory in > >> atomic context. > > >Awesome, but the changed functions don't run in atomic context. > > drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > 1368 /* Flush accumulated messages */ > 1369 err = otx2_sync_mbox_msg(&pfvf->mbox); > 1370 if (err) > 1371 goto fail; > 1372 > 1373 get_cpu(); > ^^^^^^^^^ > The get_cpu() disables preemption. Forcing GFP_ATOMIC in init functions is not desirable. Please move around the get_cpu() so that we keep GFP_KERNEL whenever possible. diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c index 88f8772a61cd527c2ab138fb5a996470a7dfd456..2e628e12cd1ff92756f054639abd777ea185680f 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,17 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf) err = otx2_alloc_rbuf(pfvf, pool, &bufptr); if (err) goto err_mem; + /* __cn10k_aura_freeptr() needs to be called + * with preemption disabled. + */ + 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:
-----Original Message----- From: Eric Dumazet <edumazet@google.com> Sent: Tuesday, January 10, 2023 2:05 PM To: Geethasowjanya Akula <gakula@marvell.com> Cc: Leon Romanovsky <leon@kernel.org>; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kuba@kernel.org; pabeni@redhat.com; davem@davemloft.net; Subbaraya Sundeep Bhatta <sbhatta@marvell.com>; Hariprasad Kelam <hkelam@marvell.com>; Sunil Kovvuri Goutham <sgoutham@marvell.com> Subject: [EXT] Re: [net PATCH] octeontx2-pf: Use GFP_ATOMIC in atomic context External Email ---------------------------------------------------------------------- On Tue, Jan 10, 2023 at 8:54 AM Geethasowjanya Akula <gakula@marvell.com> wrote: >> >> >> >> -----Original Message----- >> From: Leon Romanovsky <leon@kernel.org> >> Sent: Sunday, January 8, 2023 6:39 PM >> To: Geethasowjanya Akula <gakula@marvell.com> >> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; >> kuba@kernel.org; pabeni@redhat.com; davem@davemloft.net; >> edumazet@google.com; Subbaraya Sundeep Bhatta <sbhatta@marvell.com>; >> Hariprasad Kelam <hkelam@marvell.com>; Sunil Kovvuri Goutham >> <sgoutham@marvell.com> >> Subject: [EXT] Re: [net PATCH] octeontx2-pf: Use GFP_ATOMIC in atomic >> context >> >> External Email >> >> ---------------------------------------------------------------------- >> On Sat, Jan 07, 2023 at 10:11:39AM +0530, Geetha sowjanya wrote: >> >> Use GFP_ATOMIC flag instead of GFP_KERNEL while allocating memory >> >> in atomic context. >> >> >Awesome, but the changed functions don't run in atomic context. >> >> drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c >> 1368 /* Flush accumulated messages */ >> 1369 err = otx2_sync_mbox_msg(&pfvf->mbox); >> 1370 if (err) >> 1371 goto fail; >> 1372 >> 1373 get_cpu(); >> ^^^^^^^^^ >> The get_cpu() disables preemption. >Forcing GFP_ATOMIC in init functions is not desirable. > >Please move around the get_cpu() so that we keep GFP_KERNEL whenever possible. Ok will submit v2 with suggested changes. > >diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c >b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c >index 88f8772a61cd527c2ab138fb5a996470a7dfd456..2e628e12cd1ff92756f054639abd777ea185680f >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,17 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf) > err = otx2_alloc_rbuf(pfvf, pool, &bufptr); > if (err) > goto err_mem; >+ /* __cn10k_aura_freeptr() needs to be called >+ * with preemption disabled. >+ */ >+ 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:
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c index 88f8772a61cd..12e4365d53df 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c @@ -886,7 +886,7 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura) } sq->sqe_base = sq->sqe->base; - sq->sg = kcalloc(qset->sqe_cnt, sizeof(struct sg_list), GFP_KERNEL); + sq->sg = kcalloc(qset->sqe_cnt, sizeof(struct sg_list), GFP_ATOMIC); if (!sq->sg) return -ENOMEM; @@ -1378,7 +1378,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf) sq = &qset->sq[qidx]; sq->sqb_count = 0; - sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(*sq->sqb_ptrs), GFP_KERNEL); + sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(*sq->sqb_ptrs), GFP_ATOMIC); if (!sq->sqb_ptrs) { err = -ENOMEM; goto err_mem;