Maybe let's just check the poll list.
Checking the poll list fixes the earlier race where the watchdog has
already finished. However, the timer can still be consumed without
triggering another poll if it fires after the old caller's check:
old poll / watchdog successor busy-poll
------------------- -------------------
napi_complete_done():
clear SCHED, arm timer,
return false
acquire NAPI
enable callbacks,
then pause before completion
disable callbacks
napi_has_pending_poll():
timer is still queued,
so skip napi_schedule()
old poll exits
watchdog expires, sees SCHED=1:
no scheduling, no MISSED
watchdog returns
napi_complete_done(..., 0):
clear SCHED, return true
queue is empty, exit
At that point, the next used entry ends up with neither notifications
enabled nor a pending timer or scheduled poll to process it.
Stepping back, the fundamental ordering issue here is:
old releases SCHED
-> successor rearms callbacks
-> old masks callbacks
Right now, nothing guarantees that the old mask happens before the
successor's rearm. Even if the successor still holds SCHED, it might
have already done its final rearm. Similarly, having a queued timer
doesn't guarantee another poll—the watchdog will simply bail out without
scheduling because SCHED is already set. So all these state checks can
look completely valid at the time, yet still fail to guarantee recovery.
The root cause is that with the timer introduced by NAPI defer,
napi_complete_done() can return false while still giving up SCHED
ownership, leaving us with nothing else to synchronize the callback
state. Before NAPI defer, returning false meant we still held onto
SCHED, so everything worked as expected.
To fix this properly, I think we either need to call
virtqueue_disable_cb() before giving up SCHED ownership, or introduce a
separate synchronization mechanism (like a lock) to ensure we can always
recover NAPI execution. Simple flag checks alone don't seem enough to
close this race completely.