lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250221085507.33329-1-15645113830zzh@gmail.com>
Date: Fri, 21 Feb 2025 16:55:08 +0800
From: zihan zhou <15645113830zzh@...il.com>
To: 15645113830zzh@...il.com
Cc: bsegall@...gle.com,
	dietmar.eggemann@....com,
	juri.lelli@...hat.com,
	linux-kernel@...r.kernel.org,
	mgorman@...e.de,
	mingo@...hat.com,
	peterz@...radead.org,
	rostedt@...dmis.org,
	vincent.guittot@...aro.org,
	vschneid@...hat.com
Subject: [PATCH V1 3/4] sched: add debug for predict load

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@...t 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@...il.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ