Skip to contentSkip to conversation

net: record times of netdev_budget exhausted

PATCH In review [email protected] 3 participants 4 messages Dec 5, 2022 – Dec 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: record times of netdev_budget exhausted

From: Yang Yang <[email protected]>

A long time ago time_squeeze was used to only record netdev_budget exhausted[1]. Then we added netdev_budget_usecs to enable softirq tuning[2]. And when polling elapsed netdev_budget_usecs, it's also record by time_squeeze.
For tuning netdev_budget and netdev_budget_usecs respectively, we'd better distinguish from netdev_budget exhausted and netdev_budget_usecs elapsed, so add budget_exhaust to record netdev_budget exhausted.

[1] commit 1da177e4c3f4("Linux-2.6.12-rc2")
[2] commit 7acf8a1e8a28("Replace 2 jiffies with sysctl netdev_budget_usecs to enable softirq tuning")

---
Changes since v1: - Fix compile error of patch making error

---
 include/linux/netdevice.h |  1 +
 net/core/dev.c            | 11 +++++++----
 net/core/net-procfs.c     |  5 +++--
 3 files changed, 11 insertions(+), 6 deletions(-)
include/linux/netdevice.h +1 -0
index 5aa35c58c342..a77719b956a6 100644
@@ -3135,6 +3135,7 @@ struct softnet_data {
 	/* stats */
 	unsigned int		processed;
 	unsigned int		time_squeeze;
+	unsigned int		budget_exhaust;
 #ifdef CONFIG_RPS
 	struct softnet_data	*rps_ipi_list;
 #endif
net/core/dev.c +7 -4
index 7627c475d991..42ae2dc62661 100644
@@ -6663,11 +6663,14 @@ static __latent_entropy void net_rx_action(struct softirq_action *h)
 		budget -= napi_poll(n, &repoll);
 
 		/* If softirq window is exhausted then punt.
-		 * Allow this to run for 2 jiffies since which will allow
-		 * an average latency of 1.5/HZ.
+		 * The window is controlled by packets budget and time.
+		 * See Documentation/admin-guide/sysctl/net.rst for details.
 		 */
-		if (unlikely(budget <= 0 ||
-			     time_after_eq(jiffies, time_limit))) {
+		if (unlikely(budget <= 0)) {
+			sd->budget_exhaust++;
+			break;
+		}
+		if (unlikely(time_after_eq(jiffies, time_limit))) {
 			sd->time_squeeze++;
 			break;
 		}
net/core/net-procfs.c +3 -2
index 1ec23bf8b05c..e09e245125f0 100644
@@ -169,12 +169,13 @@ static int softnet_seq_show(struct seq_file *seq, void *v)
 	 * mapping the data a specific CPU
 	 */
 	seq_printf(seq,
-		   "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
+		   "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
 		   sd->processed, sd->dropped, sd->time_squeeze, 0,
 		   0, 0, 0, 0, /* was fastroute */
 		   0,	/* was cpu_collision */
 		   sd->received_rps, flow_limit_count,
-		   softnet_backlog_len(sd), (int)seq->index);
+		   softnet_backlog_len(sd), (int)seq->index,
+		   sd->budget_exhaust);
 	return 0;
 }
 
Signature · 1 line
2.15.2
maintainer
#1 lore raw
Quoted 10 lines · On Mon, 5 Dec 2022 09:36:12 +0800 (CST) [email protected] wrote:

A long time ago time_squeeze was used to only record netdev_budget exhausted[1]. Then we added netdev_budget_usecs to enable softirq tuning[2]. And when polling elapsed netdev_budget_usecs, it's also record by time_squeeze.
For tuning netdev_budget and netdev_budget_usecs respectively, we'd better distinguish from netdev_budget exhausted and netdev_budget_usecs elapsed, so add budget_exhaust to record netdev_budget exhausted.

[1] commit 1da177e4c3f4("Linux-2.6.12-rc2")
[2] commit 7acf8a1e8a28("Replace 2 jiffies with sysctl netdev_budget_usecs to enable softirq tuning")

Same comments as on v1.

#2 lore raw
Quoted 10 lines · Jakub Kicinski
Quoted 8 lines · On Mon, 5 Dec 2022 09:36:12 +0800 (CST) [email protected] wrote:

A long time ago time_squeeze was used to only record netdev_budget exhausted[1]. Then we added netdev_budget_usecs to enable softirq tuning[2]. And when polling elapsed netdev_budget_usecs, it's also record by time_squeeze.
For tuning netdev_budget and netdev_budget_usecs respectively, we'd better distinguish from netdev_budget exhausted and netdev_budget_usecs elapsed, so add budget_exhaust to record netdev_budget exhausted.

Quoted 4 lines
Quoted 2 lines

[1] commit 1da177e4c3f4("Linux-2.6.12-rc2")
[2] commit 7acf8a1e8a28("Replace 2 jiffies with sysctl netdev_budget_usecs to enable softirq tuning")

Same comments as on v1.

Yes, and if we really want to track all these kinds of events the break caused by need_resched() in do_softirq would
also need some monitoring.

I feel that more granular tracing (did I say tracepoints) would be more useful.

#3 lore raw
Quoted 3 lines · Eric Dumazet

Yes, and if we really want to track all these kinds of events the break caused by need_resched() in do_softirq would
also need some monitoring.

I think this situation is a bit different. The break caused by need_resched() in __do_softirq() is some kind of internal events, kernel hacker may track it by something like tracepoint.

But netdev_budget* are sysctl for administrator, when administrator adjust them, they may want to see the effect in a direct or easy way.