@@ -6763,6 +6763,15 @@ static int __napi_poll(struct napi_struct *n, bool *repoll)
gro_normal_list(n);
+ /* Some drivers may have called napi_schedule
+ * prior to exhausting their budget.
+ */
+ if (unlikely(!list_empty(&n->poll_list))) {
+ pr_warn_once("%s: Budget exhausted after napi rescheduled\n",
+ n->dev ? n->dev->name : "backlog");
+ return work;
+ }
+
*repoll = true;
return work;
@@ -6783,15 +6792,6 @@ static int napi_poll(struct napi_struct *n, struct list_head *repoll)
if (!do_repoll)
goto out_unlock;
- /* Some drivers may have called napi_schedule
- * prior to exhausting their budget.
- */
- if (unlikely(!list_empty(&n->poll_list))) {
- pr_warn_once("%s: Budget exhausted after napi rescheduled\n",
- n->dev ? n->dev->name : "backlog");
- goto out_unlock;
- }
-
list_add_tail(&n->poll_list, repoll);
out_unlock:
@@ -6820,40 +6820,26 @@ static int napi_thread_wait(struct napi_struct *napi)
static int napi_threaded_poll(void *data)
{
struct napi_struct *napi = data;
+ void *have;
while (!napi_thread_wait(napi)) {
- struct list_head dummy_repoll;
- int budget = netdev_budget;
- unsigned long time_limit;
- bool again = true;
+ for (;;) {
+ bool repoll = false;
- INIT_LIST_HEAD(&dummy_repoll);
- local_bh_disable();
- time_limit = jiffies + 2;
- do {
- /* ensure that the poll list is not empty */
- if (list_empty(&dummy_repoll))
- list_add(&napi->poll_list, &dummy_repoll);
-
- budget -= napi_poll(napi, &dummy_repoll);
- if (unlikely(budget <= 0 ||
- time_after_eq(jiffies, time_limit))) {
- cond_resched();
-
- /* refresh the budget */
- budget = netdev_budget;
- __kfree_skb_flush();
- time_limit = jiffies + 2;
- }
+ local_bh_disable();
- if (napi_disable_pending(napi))
- again = false;
- else if (!test_bit(NAPI_STATE_SCHED, &napi->state))
- again = false;
- } while (again);
+ have = netpoll_poll_lock(napi);
+ __napi_poll(napi, &repoll);
+ netpoll_poll_unlock(have);
- __kfree_skb_flush();
- local_bh_enable();
+ __kfree_skb_flush();
+ local_bh_enable();
+
+ if (!repoll)
+ break;
+
+ cond_resched();
+ }
}
return 0;
}