Linux Documentation
 help / color / mirror / Atom feed
From: Tio Zhang <tiozhang@didiglobal.com>
To: <mingo@redhat.com>, <peterz@infradead.org>,
	<juri.lelli@redhat.com>, <vincent.guittot@linaro.org>,
	<rostedt@goodmis.org>, <bsingharora@gmail.com>, <corbet@lwn.net>,
	<akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
	<dietmar.eggemann@arm.com>, <bsegall@google.com>,
	<mgorman@suse.de>, <bristot@redhat.com>, <vschneid@redhat.com>,
	<tiozhang@didiglobal.com>, <zyhtheonly@gmail.com>,
	<zyhtheonly@yeah.net>, <fuyuanli@didiglobal.com>
Subject: [PATCH 3/3] delayacct/taskstats: make soft_delay available in taskstats
Date: Tue, 2 Apr 2024 19:29:22 +0800	[thread overview]
Message-ID: <20240402112922.GA18945@didi-ThinkCentre-M930t-N000> (raw)
In-Reply-To: <20240402112700.GA18519@didi-ThinkCentre-M930t-N000>

Also update a new version of tools/accounting/getdelays.c.

	# ./getdelays -t 4600 -d
	print delayacct stats ON
	TGID	4600
	
	CPU             count     real total  virtual total    delay total  delay average
                 	3973    10700014780    10698803222   312345815813         78.617ms
	IO              count    delay total  delay average
                    	0              0              0.000ms
	SWAP            count    delay total  delay average
                    	0              0              0.000ms
	RECLAIM         count    delay total  delay average
                    	0              0              0.000ms
	THRASHING       count    delay total  delay average
                    	0              0              0.000ms
	COMPACT         count    delay total  delay average
                    	0              0              0.000ms
	WPCOPY          count    delay total  delay average
                   	40         266859             0.007ms
	IRQ             count    delay total  delay average
                	13450    17756373906          1.320ms
	SOFTIRQ         count    delay total  delay average

Signed-off-by: Tio Zhang <tiozhang@didiglobal.com>
---
 Documentation/accounting/delay-accounting.rst | 5 ++++-
 include/uapi/linux/taskstats.h                | 6 +++++-
 kernel/delayacct.c                            | 3 +++
 tools/accounting/getdelays.c                  | 8 +++++++-
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/delay-accounting.rst b/Documentation/accounting/delay-accounting.rst
index f61c01fc376e..babff410a39d 100644
--- a/Documentation/accounting/delay-accounting.rst
+++ b/Documentation/accounting/delay-accounting.rst
@@ -17,6 +17,7 @@ e) thrashing
 f) direct compact
 g) write-protect copy
 h) IRQ/SOFTIRQ
+i) SOFTIRQ
 
 and makes these statistics available to userspace through
 the taskstats interface.
@@ -50,7 +51,7 @@ this structure. See
 for a description of the fields pertaining to delay accounting.
 It will generally be in the form of counters returning the cumulative
 delay seen for cpu, sync block I/O, swapin, memory reclaim, thrash page
-cache, direct compact, write-protect copy, IRQ/SOFTIRQ etc.
+cache, direct compact, write-protect copy, IRQ/SOFTIRQ, SOFTIRQ etc.
 
 Taking the difference of two successive readings of a given
 counter (say cpu_delay_total) for a task will give the delay
@@ -123,6 +124,8 @@ Get sum of delays, since system boot, for all pids with tgid 5::
                        0              0          0.000ms
 	IRQ             count    delay total  delay average
                        0              0          0.000ms
+	SOFTIRQ         count    delay total  delay average
+                       0              0          0.000ms
 
 Get IO accounting for pid 1, it works only with -p::
 
diff --git a/include/uapi/linux/taskstats.h b/include/uapi/linux/taskstats.h
index b50b2eb257a0..5412c4d6734d 100644
--- a/include/uapi/linux/taskstats.h
+++ b/include/uapi/linux/taskstats.h
@@ -34,7 +34,7 @@
  */
 
 
-#define TASKSTATS_VERSION	14
+#define TASKSTATS_VERSION	15
 #define TS_COMM_LEN		32	/* should be >= TASK_COMM_LEN
 					 * in linux/sched.h */
 
@@ -202,6 +202,10 @@ struct taskstats {
 	/* v14: Delay waiting for IRQ/SOFTIRQ */
 	__u64    irq_count;
 	__u64    irq_delay_total;
+
+	/* v15: Delay waiting for SOFTIRQ */
+	__u64    soft_count;
+	__u64    soft_delay_total;
 };
 
 
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 8517f1c1df88..39d9430d723f 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -181,6 +181,8 @@ int delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
 	d->wpcopy_delay_total = (tmp < d->wpcopy_delay_total) ? 0 : tmp;
 	tmp = d->irq_delay_total + tsk->delays->irq_delay;
 	d->irq_delay_total = (tmp < d->irq_delay_total) ? 0 : tmp;
+	tmp = d->soft_delay_total + tsk->delays->soft_delay;
+	d->soft_delay_total = (tmp < d->soft_delay_total) ? 0 : tmp;
 	d->blkio_count += tsk->delays->blkio_count;
 	d->swapin_count += tsk->delays->swapin_count;
 	d->freepages_count += tsk->delays->freepages_count;
@@ -188,6 +190,7 @@ int delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
 	d->compact_count += tsk->delays->compact_count;
 	d->wpcopy_count += tsk->delays->wpcopy_count;
 	d->irq_count += tsk->delays->irq_count;
+	d->soft_count += tsk->delays->soft_count;
 	raw_spin_unlock_irqrestore(&tsk->delays->lock, flags);
 
 	return 0;
diff --git a/tools/accounting/getdelays.c b/tools/accounting/getdelays.c
index 1334214546d7..6e4e032e93c4 100644
--- a/tools/accounting/getdelays.c
+++ b/tools/accounting/getdelays.c
@@ -210,6 +210,8 @@ static void print_delayacct(struct taskstats *t)
 	       "WPCOPY   %12s%15s%15s\n"
 	       "      %15llu%15llu%15.3fms\n"
 	       "IRQ   %15s%15s%15s\n"
+	       "      %15llu%15llu%15.3fms\n"
+	       "SOFTIRQ  %12s%15s%15s\n"
 	       "      %15llu%15llu%15.3fms\n",
 	       "count", "real total", "virtual total",
 	       "delay total", "delay average",
@@ -245,7 +247,11 @@ static void print_delayacct(struct taskstats *t)
 	       "count", "delay total", "delay average",
 	       (unsigned long long)t->irq_count,
 	       (unsigned long long)t->irq_delay_total,
-	       average_ms((double)t->irq_delay_total, t->irq_count));
+	       average_ms((double)t->irq_delay_total, t->irq_count),
+	       "count", "delay total", "delay average",
+	       (unsigned long long)t->soft_count,
+	       (unsigned long long)t->soft_delay_total,
+	       average_ms((double)t->soft_delay_total, t->soft_count));
 }
 
 static void task_context_switch_counts(struct taskstats *t)
-- 
2.17.1


      reply	other threads:[~2024-04-02 11:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02 11:21 [PATCHSET] sched/delayacct: get task SOFTIRQ delay Tio Zhang
2024-04-02 11:24 ` [PATCH 1/3] sched: make softirq cputime accounting separately in irqtime Tio Zhang
2024-04-02 11:27   ` [PATCH 2/3] delayacct: get delay of SOFTIRQ Tio Zhang
2024-04-02 11:29     ` Tio Zhang [this message]

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=20240402112922.GA18945@didi-ThinkCentre-M930t-N000 \
    --to=tiozhang@didiglobal.com \
    --cc=akpm@linux-foundation.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=bsingharora@gmail.com \
    --cc=corbet@lwn.net \
    --cc=dietmar.eggemann@arm.com \
    --cc=fuyuanli@didiglobal.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=zyhtheonly@gmail.com \
    --cc=zyhtheonly@yeah.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox