From: Brett Creeley <bcreeley@amd.com>
To: Taehee Yoo <ap420073@gmail.com>,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, michael.chan@broadcom.com,
netdev@vger.kernel.org
Cc: somnath.kotur@broadcom.com, dw@davidwei.uk, horms@kernel.org
Subject: Re: [PATCH net v2] bnxt_en: update xdp_rxq_info in queue restart logic
Date: Tue, 23 Jul 2024 08:42:45 -0700 [thread overview]
Message-ID: <dcdf039f-4040-4a31-9738-367eda59fd04@amd.com> (raw)
In-Reply-To: <20240721053554.1233549-1-ap420073@gmail.com>
On 7/20/2024 10:35 PM, Taehee Yoo wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> When the netdev_rx_queue_restart() restarts queues, the bnxt_en driver
> updates(creates and deletes) a page_pool.
> But it doesn't update xdp_rxq_info, so the xdp_rxq_info is still
> connected to an old page_pool.
> So, bnxt_rx_ring_info->page_pool indicates a new page_pool, but
> bnxt_rx_ring_info->xdp_rxq is still connected to an old page_pool.
>
> An old page_pool is no longer used so it is supposed to be
> deleted by page_pool_destroy() but it isn't.
> Because the xdp_rxq_info is holding the reference count for it and the
> xdp_rxq_info is not updated, an old page_pool will not be deleted in
> the queue restart logic.
>
> Before restarting 1 queue:
> ./tools/net/ynl/samples/page-pool
> enp10s0f1np1[6] page pools: 4 (zombies: 0)
> refs: 8192 bytes: 33554432 (refs: 0 bytes: 0)
> recycling: 0.0% (alloc: 128:8048 recycle: 0:0)
>
> After restarting 1 queue:
> ./tools/net/ynl/samples/page-pool
> enp10s0f1np1[6] page pools: 5 (zombies: 0)
> refs: 10240 bytes: 41943040 (refs: 0 bytes: 0)
> recycling: 20.0% (alloc: 160:10080 recycle: 1920:128)
>
> Before restarting queues, an interface has 4 page_pools.
> After restarting one queue, an interface has 5 page_pools, but it
> should be 4, not 5.
> The reason is that queue restarting logic creates a new page_pool and
> an old page_pool is not deleted due to the absence of an update of
> xdp_rxq_info logic.
>
> Fixes: 2d694c27d32e ("bnxt_en: implement netdev_queue_mgmt_ops")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
> ---
>
> v2:
> - Do not use memcpy in the bnxt_queue_start
> - Call xdp_rxq_info_unreg() before page_pool_destroy() in the
> bnxt_queue_mem_free().
>
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index bb3be33c1bbd..ffa74c26ee53 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -4052,6 +4052,7 @@ static void bnxt_reset_rx_ring_struct(struct bnxt *bp,
>
> rxr->page_pool->p.napi = NULL;
> rxr->page_pool = NULL;
> + memset(&rxr->xdp_rxq, 0, sizeof(struct xdp_rxq_info));
>
> ring = &rxr->rx_ring_struct;
> rmem = &ring->ring_mem;
> @@ -15018,6 +15019,16 @@ static int bnxt_queue_mem_alloc(struct net_device *dev, void *qmem, int idx)
> if (rc)
> return rc;
>
> + rc = xdp_rxq_info_reg(&clone->xdp_rxq, bp->dev, idx, 0);
> + if (rc < 0)
> + goto err_page_pool_destroy;
> +
> + rc = xdp_rxq_info_reg_mem_model(&clone->xdp_rxq,
> + MEM_TYPE_PAGE_POOL,
> + clone->page_pool);
> + if (rc)
> + goto err_rxq_info_unreg;
> +
> ring = &clone->rx_ring_struct;
> rc = bnxt_alloc_ring(bp, &ring->ring_mem);
> if (rc)
> @@ -15047,6 +15058,9 @@ static int bnxt_queue_mem_alloc(struct net_device *dev, void *qmem, int idx)
> bnxt_free_ring(bp, &clone->rx_agg_ring_struct.ring_mem);
> err_free_rx_ring:
> bnxt_free_ring(bp, &clone->rx_ring_struct.ring_mem);
> +err_rxq_info_unreg:
> + xdp_rxq_info_unreg(&clone->xdp_rxq);
I think care needs to be taken calling xdp_rxq_info_unreg() here and
then page_pool_destroy() below due to the xdp_rxq_info_unreg() call flow
eventually calling page_pool_destroy(). Similar comment below.
> +err_page_pool_destroy:
> clone->page_pool->p.napi = NULL;
> page_pool_destroy(clone->page_pool);
> clone->page_pool = NULL;
> @@ -15062,6 +15076,8 @@ static void bnxt_queue_mem_free(struct net_device *dev, void *qmem)
> bnxt_free_one_rx_ring(bp, rxr);
> bnxt_free_one_rx_agg_ring(bp, rxr);
>
> + xdp_rxq_info_unreg(&rxr->xdp_rxq);
> +
If the memory type is MEM_TYPE_PAGE_POOL, xdp_rxq_info_unreg() will
eventually call page_pool_destroy(). Unless I am missing something I
think you want to remove the call below to page_pool_destroy()?
Thanks,
Brett
> page_pool_destroy(rxr->page_pool);
> rxr->page_pool = NULL;
>
> @@ -15145,6 +15161,7 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
> rxr->rx_sw_agg_prod = clone->rx_sw_agg_prod;
> rxr->rx_next_cons = clone->rx_next_cons;
> rxr->page_pool = clone->page_pool;
> + rxr->xdp_rxq = clone->xdp_rxq;
>
> bnxt_copy_rx_ring(bp, rxr, clone);
>
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2024-07-23 15:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-21 5:35 [PATCH net v2] bnxt_en: update xdp_rxq_info in queue restart logic Taehee Yoo
2024-07-21 16:57 ` David Wei
2024-07-23 10:59 ` Paolo Abeni
2024-07-23 17:37 ` Taehee Yoo
2024-07-23 15:42 ` Brett Creeley [this message]
2024-07-23 17:58 ` Taehee Yoo
2024-07-23 19:47 ` Brett Creeley
2024-07-25 5:00 ` Taehee Yoo
2024-07-25 5:45 ` Somnath Kotur
2024-07-25 14:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dcdf039f-4040-4a31-9738-367eda59fd04@amd.com \
--to=bcreeley@amd.com \
--cc=ap420073@gmail.com \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=somnath.kotur@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.