Skip to content

Commit c1e00bc

Browse files
committed
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3e7efc3 commit c1e00bc

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
@@ -299,6 +299,18 @@ void xdp_do_check_flushed(struct napi_struct *napi);
299299
static inline void xdp_do_check_flushed(struct napi_struct *napi) { }
300300
#endif
301301

302+
/* Best effort check that NAPI is not idle (can't be scheduled to run) */
303+
static inline void napi_assert_will_not_race(const struct napi_struct *napi)
304+
{
305+
/* uninitialized instance, can't race */
306+
if (!napi->poll_list.next)
307+
return;
308+
309+
/* SCHED bit is set on disabled instances */
310+
WARN_ON(!test_bit(NAPI_STATE_SCHED, &napi->state));
311+
WARN_ON(READ_ONCE(napi->list_owner) != -1);
312+
}
313+
302314
void kick_defer_list_purge(struct softnet_data *sd, unsigned int cpu);
303315

304316
#define XMIT_RECURSION_LIMIT 8

net/core/page_pool.c

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

2727
#include <trace/events/page_pool.h>
2828

29+
#include "dev.h"
2930
#include "mp_dmabuf_devmem.h"
3031
#include "netmem_priv.h"
3132
#include "page_pool_priv.h"
@@ -1147,11 +1148,7 @@ void page_pool_disable_direct_recycling(struct page_pool *pool)
11471148
if (!pool->p.napi)
11481149
return;
11491150

1150-
/* To avoid races with recycling and additional barriers make sure
1151-
* pool and NAPI are unlinked when NAPI is disabled.
1152-
*/
1153-
WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state));
1154-
WARN_ON(READ_ONCE(pool->p.napi->list_owner) != -1);
1151+
napi_assert_will_not_race(pool->p.napi);
11551152

11561153
mutex_lock(&page_pools_lock);
11571154
WRITE_ONCE(pool->p.napi, NULL);

0 commit comments

Comments
 (0)