Message ID | 20230107044139.25787-1-gakula@marvell.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1165158wrt; Fri, 6 Jan 2023 21:16:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXsPX3sxDla2Y9PmldVZF9LfKbatPib+KZxSNHo+hQ5A/9RDCU5TlcUbt0zLinUPqUxAUGDB X-Received: by 2002:a17:903:3251:b0:193:211:fb33 with SMTP id ji17-20020a170903325100b001930211fb33mr7492289plb.35.1673068562754; Fri, 06 Jan 2023 21:16:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673068562; cv=none; d=google.com; s=arc-20160816; b=brL6+O+fKXGKE9nMDMiLr47alQxNo14uyOIfFSds4yTOubD2kQmgv+CCTgf92/Eb3B qaGGxCM3hj15FABQPPpW3Z8pNZVcc8ttOkV6+SoCzYfegf/YZ1bY047xXcqiyYcrBaiM 9iidIDC0Yv168D0VPb/5ZfbLZESWoa+P+JRtjqnmccr1HKlJ9Uh4AuQucaBrr6v3qfru ADa4aYKNiFpD9aEj2S4QUwXR8RzphkbHI9WfLERR7S2H2fnf0WeibawUbpMPo6N57h2u 1nZxt9erAaJUTKGODLKKjHBji5Voj09HRtpCSt9YiCmptLOY46/tzjPlU2xL064ZEh7K ZctQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=BVxoW8PmXFMv3h+4qTBfZny95ISCtWzgZuWh5HvWCfM=; b=dy76r+B2SrUaRsB2xBM2J4WAWDzKyZhEnXLW0tHaIc8hbN01NL/ntX8EFHaxvAJWq5 /GjLJ7rTRlUb62NkiVOT0rdGXAd3R3Ce8xFsQybEm1iOqLn3cMt6D5DcaBXb4U0CvB6Y DI3AaBHBsIJId3hIZjEnr74DEq3IsVbHe5ZRGjd/75pO5AMz3dbpb5pTjI4ebhmNfHiG wsLdQA/EcAckNpF1kMnxvvOZON+dwXbnJKYhvk8IwsgjHzVZUwGvRQlejs2u33MRiMBc 6LswdlMYOBLrrxMtPxP+mLl1AohN9ZFLYAqDIBMtlQNKuV0FMsSRTgazoYEgHYHGToUK i1Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Xbs5d+9y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020a639247000000b004915c5ca6b1si2957580pgn.866.2023.01.06.21.15.48; Fri, 06 Jan 2023 21:16:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Xbs5d+9y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236693AbjAGEmC (ORCPT <rfc822;dolce.eric@gmail.com> + 99 others); Fri, 6 Jan 2023 23:42:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjAGEl4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 6 Jan 2023 23:41:56 -0500 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AA7684635; Fri, 6 Jan 2023 20:41:56 -0800 (PST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3072vWtZ003726; Fri, 6 Jan 2023 20:41:45 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0220; bh=BVxoW8PmXFMv3h+4qTBfZny95ISCtWzgZuWh5HvWCfM=; b=Xbs5d+9ytUe6Agj6Tue9c4UDHCAhdNc30SYEDcwbQIDNTJLXXdew1XNx69H4Oj+hKIIz anZXwCOtNshZ3ES/GP1B8D3jTR7t1G/jaidDf5UcFloAPl8shj0FGTx7aZ3ruIdIIYa2 la1AggW241uAtz7tEvQDb0WgrfFsnhfKMays3CKq/ffZ924lJFWHPMo24axLgoSzRpkH q+4kAdpYIgx9EtJOp/vW/cUfav+I9uGmHixDVq7s9jzcxoEi4iE3uaBncDFSNJCwShsk 0LYArjDdEFY+aQu18GUaPD+ONCFozcUN2LaJXVBqjrQai/U2sOlBbdFbYSuBHYVsaYw3 6Q== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3mx4hhbf6p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 06 Jan 2023 20:41:45 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 6 Jan 2023 20:41:43 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Fri, 6 Jan 2023 20:41:43 -0800 Received: from hyd1soter3.marvell.com (unknown [10.29.37.12]) by maili.marvell.com (Postfix) with ESMTP id 4084B5B72F4; Fri, 6 Jan 2023 20:41:40 -0800 (PST) From: Geetha sowjanya <gakula@marvell.com> To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> CC: <kuba@kernel.org>, <pabeni@redhat.com>, <davem@davemloft.net>, <edumazet@google.com>, <sbhatta@marvell.com>, <hkelam@marvell.com>, <gakula@marvell.com>, <sgoutham@marvell.com> Subject: [net PATCH] octeontx2-pf: Use GFP_ATOMIC in atomic context Date: Sat, 7 Jan 2023 10:11:39 +0530 Message-ID: <20230107044139.25787-1-gakula@marvell.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: O1jxXlW2LUljYUlLuwIwi4j2VulCaoBy X-Proofpoint-ORIG-GUID: O1jxXlW2LUljYUlLuwIwi4j2VulCaoBy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-06_14,2023-01-06_01,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754339541419934075?= X-GMAIL-MSGID: =?utf-8?q?1754339541419934075?= |
Series |
[net] octeontx2-pf: Use GFP_ATOMIC in atomic context
|
|
Commit Message
Geetha sowjanya
Jan. 7, 2023, 4:41 a.m. UTC
Use GFP_ATOMIC flag instead of GFP_KERNEL while allocating memory 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(-)
Comments
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;