mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xiaobing Li <xiaobing.li@samsung.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, vschneid@redhat.com, axboe@kernel.dk,
	asml.silence@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	io-uring@vger.kernel.org, kun.dou@samsung.com,
	peiwei.li@samsung.com, joshi.k@samsung.com,
	kundan.kumar@samsung.com, wenwen.chen@samsung.com,
	ruyi.zhang@samsung.com, Xiaobing Li <xiaobing.li@samsung.com>
Subject: [PATCH 2/3] PROC FILESYSTEM: Add real utilization data of sq thread.
Date: Thu, 28 Sep 2023 10:22:27 +0800	[thread overview]
Message-ID: <20230928022228.15770-3-xiaobing.li@samsung.com> (raw)
In-Reply-To: <20230928022228.15770-1-xiaobing.li@samsung.com>

Since it is necessary to count and record the real utilization of the sq
thread, it is recorded in the /proc/stat file.

Signed-off-by: Xiaobing Li <xiaobing.li@samsung.com>
---
 fs/proc/stat.c              | 25 ++++++++++++++++++++++++-
 include/linux/kernel_stat.h |  3 +++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index da60956b2915..bd86c0657874 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -79,6 +79,29 @@ static void show_all_irqs(struct seq_file *p)
 	show_irq_gap(p, nr_irqs - next);
 }
 
+static void show_sqthread_util(struct seq_file *p)
+{
+	int i, j;
+
+	for_each_online_cpu(i) {
+		struct kernel_cpustat kcpustat;
+
+		kcpustat_cpu_fetch(&kcpustat, i);
+		struct task_struct **sqstat = kcpustat.sq_util;
+
+		for (j = 0; j < MAX_SQ_NUM; j++) {
+			if (sqstat[j]) {
+				seq_printf(p, "%d %s", sqstat[j]->pid, sqstat[j]->comm);
+				seq_put_decimal_ull(p, " pelt ",
+				(unsigned long long)sqstat[j]->se.avg.util_avg);
+				seq_put_decimal_ull(p, " real ",
+				(unsigned long long)sqstat[j]->se.sq_avg.util_avg);
+				seq_putc(p, '\n');
+			}
+		}
+	}
+}
+
 static int show_stat(struct seq_file *p, void *v)
 {
 	int i, j;
@@ -187,7 +210,7 @@ static int show_stat(struct seq_file *p, void *v)
 	for (i = 0; i < NR_SOFTIRQS; i++)
 		seq_put_decimal_ull(p, " ", per_softirq_sums[i]);
 	seq_putc(p, '\n');
-
+	show_sqthread_util(p);
 	return 0;
 }
 
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 9935f7ecbfb9..722703da681e 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -11,6 +11,7 @@
 #include <linux/vtime.h>
 #include <asm/irq.h>
 
+#define MAX_SQ_NUM 16
 /*
  * 'kernel_stat.h' contains the definitions needed for doing
  * some kernel statistics (CPU usage, context switches ...),
@@ -36,6 +37,8 @@ enum cpu_usage_stat {
 
 struct kernel_cpustat {
 	u64 cpustat[NR_STATS];
+	bool flag;
+	struct task_struct *sq_util[MAX_SQ_NUM];
 };
 
 struct kernel_stat {
-- 
2.34.1


  parent reply	other threads:[~2023-09-28  2:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230928023004epcas5p4a6dac4cda9c867f3673690521a8c18b6@epcas5p4.samsung.com>
2023-09-28  2:22 ` [PATCH 0/3] Sq thread real utilization statistics Xiaobing Li
     [not found]   ` <CGME20230928023007epcas5p276b6e029a67001a6ed8ab28c05b2be9c@epcas5p2.samsung.com>
2023-09-28  2:22     ` [PATCH 1/3] SCHEDULER: Add an interface for counting real utilization Xiaobing Li
2023-09-28  7:52       ` kernel test robot
2023-09-28  8:02       ` Peter Zijlstra
2023-09-29  0:31       ` Thomas Gleixner
     [not found]   ` <CGME20230928023011epcas5p32668b193b447f1cd6bf78035f4894c42@epcas5p3.samsung.com>
2023-09-28  2:22     ` Xiaobing Li [this message]
     [not found]   ` <CGME20230928023015epcas5p273b3eaebf3759790c278b03c7f0341c8@epcas5p2.samsung.com>
2023-09-28  2:22     ` [PATCH 3/3] IO_URING: Statistics of the true utilization of sq threads Xiaobing Li
2023-09-28  8:01       ` Peter Zijlstra
2023-09-28  8:23         ` Jens Axboe
2023-09-28  8:37         ` Matthew Wilcox
2023-09-28  8:41           ` Jens Axboe
2023-09-28 18:33       ` kernel test robot

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=20230928022228.15770-3-xiaobing.li@samsung.com \
    --to=xiaobing.li@samsung.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=io-uring@vger.kernel.org \
    --cc=joshi.k@samsung.com \
    --cc=juri.lelli@redhat.com \
    --cc=kun.dou@samsung.com \
    --cc=kundan.kumar@samsung.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peiwei.li@samsung.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=ruyi.zhang@samsung.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=wenwen.chen@samsung.com \
    /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

all inboxes | Powered by JetHome®