Skip to content

Commit 614ff53

Browse files
committed
net: page_pool: avoid false positive warning if NAPI was never added
JIRA: https://issues.redhat.com/browse/RHEL-93737 Conflicts: net/core/dev.h - context conflict due to missing commits like b9495b5 ("net: move kick_defer_list_purge() to net/core/dev.h") net/core/page_pool.c - simple context conflict in headers area commit c1e00bc Author: Jakub Kicinski <kuba@kernel.org> Date: Thu Feb 6 14:56:37 2025 -0800 net: page_pool: avoid false positive warning if NAPI was never added We expect NAPI to be in disabled state when page pool is torn down. But it is also legal if the NAPI is completely uninitialized. Reviewed-by: Mina Almasry <almasrymina@google.com> Link: https://patch.msgid.link/20250206225638.1387810-4-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
1 parent 2fa3810 commit 614ff53

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

net/core/dev.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,16 @@ static inline void netdev_set_gro_flush_timeout(struct net_device *netdev,
236236

237237
int rps_cpumask_housekeeping(struct cpumask *mask);
238238

239+
/* Best effort check that NAPI is not idle (can't be scheduled to run) */
240+
static inline void napi_assert_will_not_race(const struct napi_struct *napi)
241+
{
242+
/* uninitialized instance, can't race */
243+
if (!napi->poll_list.next)
244+
return;
245+
246+
/* SCHED bit is set on disabled instances */
247+
WARN_ON(!test_bit(NAPI_STATE_SCHED, &napi->state));
248+
WARN_ON(READ_ONCE(napi->list_owner) != -1);
249+
}
250+
239251
#endif

net/core/page_pool.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <trace/events/page_pool.h>
2525

26+
#include "dev.h"
2627
#include "page_pool_priv.h"
2728

2829
#define DEFER_TIME (msecs_to_jiffies(1000))
@@ -1076,11 +1077,7 @@ void page_pool_disable_direct_recycling(struct page_pool *pool)
10761077
if (!pool->p.napi)
10771078
return;
10781079

1079-
/* To avoid races with recycling and additional barriers make sure
1080-
* pool and NAPI are unlinked when NAPI is disabled.
1081-
*/
1082-
WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state));
1083-
WARN_ON(READ_ONCE(pool->p.napi->list_owner) != -1);
1080+
napi_assert_will_not_race(pool->p.napi);
10841081

10851082
mutex_lock(&page_pools_lock);
10861083
WRITE_ONCE(pool->p.napi, NULL);

0 commit comments

Comments
 (0)