All of lore.kernel.org
 help / color / mirror / Atom feed
From: <yang.yang29@zte.com.cn>
To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>
Cc: <pabeni@redhat.com>, <bigeasy@linutronix.de>,
	<imagedong@tencent.com>, <kuniyu@amazon.com>, <petrm@nvidia.com>,
	<liu3101@purdue.edu>, <wujianguo@chinatelecom.cn>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH linux-next] net: record times of netdev_budget exhausted
Date: Sat, 3 Dec 2022 16:12:05 +0800 (CST)	[thread overview]
Message-ID: <202212031612057505056@zte.com.cn> (raw)

From: Yang Yang <yang.yang29@zte.com>

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 netdev_budget exhausted from netdev_budget_usecs
elapsed, so add a new recorder 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")

Signed-off-by: Yang Yang <yang.yang29@zte.com>
---
 include/linux/netdevice.h |  1 +
 net/core/dev.c            | 11 +++++++----
 net/core/net-procfs.c     |  5 +++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 5aa35c58c342..a77719b956a6 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -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
diff --git a/net/core/dev.c b/net/core/dev.c
index 7627c475d991..42ae2dc62661 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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 time and packet budget.
+		 * 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;
 		}
diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
index 1ec23bf8b05c..e09e245125f0 100644
--- a/net/core/net-procfs.c
+++ b/net/core/net-procfs.c
@@ -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;
 }

-- 
2.15.2

             reply	other threads:[~2022-12-03  8:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-03  8:12 yang.yang29 [this message]
2022-12-03 10:06 ` [PATCH linux-next] net: record times of netdev_budget exhausted kernel test robot
2022-12-03 16:50 ` kernel test robot
2022-12-03 16:50 ` kernel test robot
2022-12-06  1:53 ` Jakub Kicinski
2022-12-06  2:35   ` yang.yang29
2022-12-06  2:47     ` Jakub Kicinski
2022-12-07  7:27       ` yang.yang29
2022-12-07  7:58         ` Eric Dumazet
2022-12-07  8:17           ` yang.yang29
2022-12-07 23:28             ` Jakub Kicinski
2022-12-07 12:30           ` yang.yang29
2022-12-07 23:32             ` Jakub Kicinski
2022-12-08  1:12               ` yang.yang29
2022-12-08  1:23                 ` Jakub Kicinski
2022-12-08  1:42                   ` yang.yang29

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202212031612057505056@zte.com.cn \
    --to=yang.yang29@zte.com.cn \
    --cc=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=imagedong@tencent.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liu3101@purdue.edu \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=wujianguo@chinatelecom.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.