-
Notifications
You must be signed in to change notification settings - Fork 1
/
0001-Added-new-config-option-to-enable-threaded-NAPI.patch
113 lines (100 loc) · 2.85 KB
/
0001-Added-new-config-option-to-enable-threaded-NAPI.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
From 90236cdcb1783b3165a8719ba96e39e477f2ce07 Mon Sep 17 00:00:00 2001
From: Riccardo Mancini <[email protected]>
Date: Sun, 23 Jun 2019 19:36:09 +0200
Subject: [PATCH 1/4] Added new config option to enable threaded NAPI
---
net/Kconfig | 4 ++++
net/core/dev.c | 37 ++++++++++++++++++++++++++++++++-----
2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/net/Kconfig b/net/Kconfig
index d122f53c6fa2..a38033487f97 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -449,6 +449,10 @@ config FAILOVER
migration of VMs with direct attached VFs by failing over to the
paravirtual datapath when the VF is unplugged.
+config THREADED_NAPI
+ bool "Run NAPI on a dedicated kernel thread"
+ default n
+
endif # if NET
# Used by archs to tell that they support BPF JIT compiler plus which flavour.
diff --git a/net/core/dev.c b/net/core/dev.c
index eb7fb6daa1ef..007f3e15836a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3972,12 +3972,25 @@ int dev_weight_tx_bias __read_mostly = 1; /* bias for output_queue quota */
int dev_rx_weight __read_mostly = 64;
int dev_tx_weight __read_mostly = 64;
+#ifdef CONFIG_THREADED_NAPI
+
+#else
+
+/* Called with irq disabled */
+static inline void ______napi_schedule(void)
+{
+ __raise_softirq_irqoff(NET_RX_SOFTIRQ);
+}
+
+
+#endif
+
/* Called with irq disabled */
static inline void ____napi_schedule(struct softnet_data *sd,
struct napi_struct *napi)
{
list_add_tail(&napi->poll_list, &sd->poll_list);
- __raise_softirq_irqoff(NET_RX_SOFTIRQ);
+ ______napi_schedule();
}
#ifdef CONFIG_RPS
@@ -4203,8 +4216,7 @@ static int rps_ipi_queued(struct softnet_data *sd)
sd->rps_ipi_next = mysd->rps_ipi_list;
mysd->rps_ipi_list = sd;
- __raise_softirq_irqoff(NET_RX_SOFTIRQ);
- return 1;
+ ______napi_schedule();
}
#endif /* CONFIG_RPS */
return 0;
@@ -6369,12 +6381,14 @@ static int napi_poll(struct napi_struct *n, struct list_head *repoll)
return work;
}
-static __latent_entropy void net_rx_action(struct softirq_action *h)
+static __latent_entropy int napi_poll_everything(void)
{
struct softnet_data *sd = this_cpu_ptr(&softnet_data);
unsigned long time_limit = jiffies +
usecs_to_jiffies(netdev_budget_usecs);
int budget = netdev_budget;
+ int ret = 0;
+
LIST_HEAD(list);
LIST_HEAD(repoll);
@@ -6411,13 +6425,26 @@ static __latent_entropy void net_rx_action(struct softirq_action *h)
list_splice_tail(&repoll, &list);
list_splice(&list, &sd->poll_list);
if (!list_empty(&sd->poll_list))
- __raise_softirq_irqoff(NET_RX_SOFTIRQ);
+ ret = 1;
net_rps_action_and_irq_enable(sd);
out:
__kfree_skb_flush();
+ return ret;
}
+#ifdef CONFIG_THREADED_NAPI
+
+#else
+
+static void net_rx_action(struct softirq_action *h)
+{
+ if (napi_poll_everything())
+ raise_softirq(NET_RX_SOFTIRQ);
+}
+
+#endif
+
struct netdev_adjacent {
struct net_device *dev;
--
2.21.0