2
0

600-v5.12-net-extract-napi-poll-functionality-to-__napi_poll.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From: Felix Fietkau <[email protected]>
  2. Date: Mon, 8 Feb 2021 11:34:08 -0800
  3. Subject: [PATCH] net: extract napi poll functionality to __napi_poll()
  4. This commit introduces a new function __napi_poll() which does the main
  5. logic of the existing napi_poll() function, and will be called by other
  6. functions in later commits.
  7. This idea and implementation is done by Felix Fietkau <[email protected]> and
  8. is proposed as part of the patch to move napi work to work_queue
  9. context.
  10. This commit by itself is a code restructure.
  11. Signed-off-by: Felix Fietkau <[email protected]>
  12. Signed-off-by: Wei Wang <[email protected]>
  13. Reviewed-by: Alexander Duyck <[email protected]>
  14. Signed-off-by: David S. Miller <[email protected]>
  15. ---
  16. --- a/net/core/dev.c
  17. +++ b/net/core/dev.c
  18. @@ -6809,15 +6809,10 @@ void __netif_napi_del(struct napi_struct
  19. }
  20. EXPORT_SYMBOL(__netif_napi_del);
  21. -static int napi_poll(struct napi_struct *n, struct list_head *repoll)
  22. +static int __napi_poll(struct napi_struct *n, bool *repoll)
  23. {
  24. - void *have;
  25. int work, weight;
  26. - list_del_init(&n->poll_list);
  27. -
  28. - have = netpoll_poll_lock(n);
  29. -
  30. weight = n->weight;
  31. /* This NAPI_STATE_SCHED test is for avoiding a race
  32. @@ -6837,7 +6832,7 @@ static int napi_poll(struct napi_struct
  33. n->poll, work, weight);
  34. if (likely(work < weight))
  35. - goto out_unlock;
  36. + return work;
  37. /* Drivers must not modify the NAPI state if they
  38. * consume the entire weight. In such cases this code
  39. @@ -6846,7 +6841,7 @@ static int napi_poll(struct napi_struct
  40. */
  41. if (unlikely(napi_disable_pending(n))) {
  42. napi_complete(n);
  43. - goto out_unlock;
  44. + return work;
  45. }
  46. if (n->gro_bitmask) {
  47. @@ -6864,12 +6859,29 @@ static int napi_poll(struct napi_struct
  48. if (unlikely(!list_empty(&n->poll_list))) {
  49. pr_warn_once("%s: Budget exhausted after napi rescheduled\n",
  50. n->dev ? n->dev->name : "backlog");
  51. - goto out_unlock;
  52. + return work;
  53. }
  54. - list_add_tail(&n->poll_list, repoll);
  55. + *repoll = true;
  56. +
  57. + return work;
  58. +}
  59. +
  60. +static int napi_poll(struct napi_struct *n, struct list_head *repoll)
  61. +{
  62. + bool do_repoll = false;
  63. + void *have;
  64. + int work;
  65. +
  66. + list_del_init(&n->poll_list);
  67. +
  68. + have = netpoll_poll_lock(n);
  69. +
  70. + work = __napi_poll(n, &do_repoll);
  71. +
  72. + if (do_repoll)
  73. + list_add_tail(&n->poll_list, repoll);
  74. -out_unlock:
  75. netpoll_poll_unlock(have);
  76. return work;