From: Jakub Kicinski <kuba@kernel.org>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: Mina Almasry <almasrymina@google.com>,
davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
hawk@kernel.org, ilias.apalodimas@linaro.org,
asml.silence@gmail.com, kaiyuanz@google.com, willemb@google.com,
mkarsten@uwaterloo.ca, jdamato@fastly.com
Subject: Re: [PATCH net] net: page_pool: don't try to stash the napi id
Date: Mon, 27 Jan 2025 11:37:50 -0800 [thread overview]
Message-ID: <20250127113750.54ed83d4@kernel.org> (raw)
In-Reply-To: <877c6gpen5.fsf@toke.dk>
On Mon, 27 Jan 2025 14:31:10 +0100 Toke Høiland-Jørgensen wrote:
> > +
> > +/* page_pool_destroy or page_pool_disable_direct_recycling must be
> > called before
> > + * netif_napi_del if pool->p.napi is set.
> > + */
FWIW the comment is better placed on the warning, that's where people
will look when they hit it ;)
> > void page_pool_destroy(struct page_pool *pool);
> > void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *),
> > const struct xdp_mem_info *mem);
> >
> > diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> > index 5c4b788b811b..dc82767b2516 100644
> > --- a/net/core/page_pool.c
> > +++ b/net/core/page_pool.c
> > @@ -1161,6 +1161,8 @@ void page_pool_destroy(struct page_pool *pool)
> > if (!page_pool_put(pool))
> > return;
> >
> > + DEBUG_NET_WARN_ON(pool->p.napi && !napi_is_valid(pool->p.napi));
IDK what "napi_is_valid()" is. I think like this:
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index a3de752c5178..837ed36472db 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -1145,6 +1145,7 @@ void page_pool_disable_direct_recycling(struct page_pool *pool)
* pool and NAPI are unlinked when NAPI is disabled.
*/
WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state));
+ WARN_ON(!test_bit(NAPI_STATE_LISTED, &pool->p.napi->state));
WARN_ON(READ_ONCE(pool->p.napi->list_owner) != -1);
WRITE_ONCE(pool->p.napi, NULL);
Because page_pool_disable_direct_recycling() must also be called while
NAPI is listed. Technically we should also sync rcu if the driver calls
this directly, because NAPI may be reused :(
> > page_pool_disable_direct_recycling(pool);
> > page_pool_free_frag(pool);
>
> Yeah, good idea; care to send a proper patch? :)
...for net-next ? :)
next prev parent reply other threads:[~2025-01-27 19:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 23:16 [PATCH net] net: page_pool: don't try to stash the napi id Jakub Kicinski
2025-01-24 21:00 ` Mina Almasry
2025-01-24 22:18 ` Toke Høiland-Jørgensen
2025-01-24 23:49 ` Mina Almasry
2025-01-27 13:31 ` Toke Høiland-Jørgensen
2025-01-27 19:37 ` Jakub Kicinski [this message]
2025-01-27 19:41 ` Mina Almasry
2025-01-25 1:31 ` Jakub Kicinski
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=20250127113750.54ed83d4@kernel.org \
--to=kuba@kernel.org \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=asml.silence@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=jdamato@fastly.com \
--cc=kaiyuanz@google.com \
--cc=mkarsten@uwaterloo.ca \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=toke@redhat.com \
--cc=willemb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).