From: zihan zhou <15645113830zzh@gmail.com>
To: 15645113830zzh@gmail.com
Cc: bsegall@google.com, dietmar.eggemann@arm.com,
juri.lelli@redhat.com, linux-kernel@vger.kernel.org,
mgorman@suse.de, mingo@redhat.com, peterz@infradead.org,
rostedt@goodmis.org, vincent.guittot@linaro.org,
vschneid@redhat.com
Subject: [PATCH V1 3/4] sched: add debug for predict load
Date: Fri, 21 Feb 2025 16:55:08 +0800 [thread overview]
Message-ID: <20250221085507.33329-1-15645113830zzh@gmail.com> (raw)
In-Reply-To: <20250221084437.31284-1-15645113830zzh@gmail.com>
We can see the debugging information about load prediction from
/proc/$pid/predict_load (task se) and /sys/kernel/debug/sched/debug
(group se)
An example:
[root@test sched]# cat /proc/1/predict_load
se.pldp->predict_correct_count : 7699
se.pldp->predict_count : 7820
se.pldp->no_predict_count : 263
enqueue_load_normalized: 0, dequeue_load_normalized: 0, confidence:255
enqueue_load_normalized: 16, dequeue_load_normalized: 16, confidence:42
enqueue_load_normalized: 32, dequeue_load_normalized: 32, confidence:14
enqueue_load_normalized: 48, dequeue_load_normalized: 48, confidence:5
enqueue_load_normalized: 64, dequeue_load_normalized: 64, confidence:8
enqueue_load_normalized: 80, dequeue_load_normalized: 80, confidence:9
enqueue_load_normalized: 96, dequeue_load_normalized: 96, confidence:3
enqueue_load_normalized: 112, dequeue_load_normalized: 128, confidence:2
/sys/kernel/debug/sched/debug only have predict_count.
Signed-off-by: zihan zhou <15645113830zzh@gmail.com>
---
fs/proc/base.c | 39 +++++++++++++++++++++++++++++++++++++
include/linux/sched/debug.h | 5 +++++
kernel/sched/debug.c | 39 +++++++++++++++++++++++++++++++++++++
3 files changed, 83 insertions(+)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index cd89e956c322..e66173ce941b 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1541,6 +1541,39 @@ static const struct file_operations proc_pid_sched_operations = {
#endif
+
+#ifdef CONFIG_SCHED_PREDICT_LOAD_DEBUG
+
+static int predict_load_show(struct seq_file *m, void *v)
+{
+ struct inode *inode = m->private;
+ struct pid_namespace *ns = proc_pid_ns(inode->i_sb);
+ struct task_struct *p;
+
+ p = get_proc_task(inode);
+ if (!p)
+ return -ESRCH;
+ proc_predict_load_show_task(p, ns, m);
+
+ put_task_struct(p);
+
+ return 0;
+}
+
+static int predict_load_open(struct inode *inode, struct file *filp)
+{
+ return single_open(filp, predict_load_show, inode);
+}
+
+static const struct file_operations proc_pid_predict_load_operations = {
+ .open = predict_load_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+#endif
+
#ifdef CONFIG_SCHED_AUTOGROUP
/*
* Print out autogroup related information:
@@ -3334,6 +3367,9 @@ static const struct pid_entry tgid_base_stuff[] = {
#ifdef CONFIG_SCHED_DEBUG
REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
#endif
+#ifdef CONFIG_SCHED_PREDICT_LOAD_DEBUG
+ REG("predict_load", S_IRUGO, proc_pid_predict_load_operations),
+#endif
#ifdef CONFIG_SCHED_AUTOGROUP
REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
#endif
@@ -3684,6 +3720,9 @@ static const struct pid_entry tid_base_stuff[] = {
ONE("limits", S_IRUGO, proc_pid_limits),
#ifdef CONFIG_SCHED_DEBUG
REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
+#endif
+#ifdef CONFIG_SCHED_PREDICT_LOAD_DEBUG
+ REG("predict_load", S_IRUGO, proc_pid_predict_load_operations),
#endif
NOD("comm", S_IFREG|S_IRUGO|S_IWUSR,
&proc_tid_comm_inode_operations,
diff --git a/include/linux/sched/debug.h b/include/linux/sched/debug.h
index b5035afa2396..5b2bab60afae 100644
--- a/include/linux/sched/debug.h
+++ b/include/linux/sched/debug.h
@@ -40,6 +40,11 @@ struct seq_file;
extern void proc_sched_show_task(struct task_struct *p,
struct pid_namespace *ns, struct seq_file *m);
extern void proc_sched_set_task(struct task_struct *p);
+
+#ifdef CONFIG_SCHED_PREDICT_LOAD_DEBUG
+extern void proc_predict_load_show_task(struct task_struct *p,
+ struct pid_namespace *ns, struct seq_file *m);
+#endif
#endif
/* Attach to any functions which should be ignored in wchan output. */
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index ef047add7f9e..619b96333f6a 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -690,6 +690,12 @@ static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group
P(se->avg.runnable_avg);
#endif
+#ifdef CONFIG_SCHED_PREDICT_LOAD_DEBUG
+ P(se->pldp->predict_correct_count);
+ P(se->pldp->predict_count);
+ P(se->pldp->no_predict_count);
+#endif
+
#undef PN_SCHEDSTAT
#undef PN
#undef P_SCHEDSTAT
@@ -1160,6 +1166,39 @@ static void sched_show_numa(struct task_struct *p, struct seq_file *m)
#endif
}
+#ifdef CONFIG_SCHED_PREDICT_LOAD_DEBUG
+
+void proc_predict_load_show_task(struct task_struct *p, struct pid_namespace *ns,
+ struct seq_file *m)
+{
+ struct predict_load_data *pldp = p->se.pldp;
+
+ if (pldp == NULL)
+ return;
+ struct record_load *rla = pldp->record_load_array;
+
+ unsigned long index, enqueue_load_normalized, dequeue_load_normalized, confidence;
+
+ P(se.pldp->predict_correct_count);
+ P(se.pldp->predict_count);
+ P(se.pldp->no_predict_count);
+
+
+ for (index = 0; index < (PREDICT_LOAD_MAX >> LOAD_GRAN_SHIFT); index++) {
+ enqueue_load_normalized = index << LOAD_GRAN_SHIFT;
+ dequeue_load_normalized = rla[index].load_after_offset << LOAD_GRAN_SHIFT;
+ confidence = rla[index].confidence;
+ if (confidence) {
+ SEQ_printf(m, "enqueue_load_normalized: %ld, ", enqueue_load_normalized);
+ SEQ_printf(m, "dequeue_load_normalized: %ld, ", dequeue_load_normalized);
+ SEQ_printf(m, "confidence:%ld\n", confidence);
+ }
+ }
+
+}
+
+#endif
+
void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
struct seq_file *m)
{
--
2.33.0
next prev parent reply other threads:[~2025-02-21 8:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 8:44 [PATCH V1 0/4] sched: Predict load based on conditional probability zihan zhou
2025-02-21 8:47 ` [PATCH V1 1/4] sched: Add kconfig of predict load zihan zhou
2025-02-21 8:50 ` [PATCH V1 2/4] sched: Do " zihan zhou
2025-02-28 8:38 ` kernel test robot
2025-03-01 20:19 ` kernel test robot
2025-02-21 8:55 ` zihan zhou [this message]
2025-02-21 8:57 ` [PATCH V1 4/4] sched: add feature PREDICT_NO_PREEMPT zihan zhou
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=20250221085507.33329-1-15645113830zzh@gmail.com \
--to=15645113830zzh@gmail.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--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 \
/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®