Skip to content

Commit 883d933

Browse files
committed
Merge: CNB97: net: page_pool: avoid false positive warning if NAPI was never added
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6973 JIRA: https://issues.redhat.com/browse/RHEL-93737 Commits: ``` 3e61103 ("page_pool: remove WARN_ON() with OR") c1e00bc ("net: page_pool: avoid false positive warning if NAPI was never added") ``` Signed-off-by: Ivan Vecera <ivecera@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: Davide Caratti <dcaratti@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents fb06120 + 614ff53 commit 883d933

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
@@ -246,4 +246,16 @@ static inline void netdev_set_gro_flush_timeout(struct net_device *netdev,
246246

247247
int rps_cpumask_housekeeping(struct cpumask *mask);
248248

249+
/* Best effort check that NAPI is not idle (can't be scheduled to run) */
250+
static inline void napi_assert_will_not_race(const struct napi_struct *napi)
251+
{
252+
/* uninitialized instance, can't race */
253+
if (!napi->poll_list.next)
254+
return;
255+
256+
/* SCHED bit is set on disabled instances */
257+
WARN_ON(!test_bit(NAPI_STATE_SCHED, &napi->state));
258+
WARN_ON(READ_ONCE(napi->list_owner) != -1);
259+
}
260+
249261
#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-
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)