[PATCH v1] sched/debug: Update print_task formatin /sys/kernel/debug/sched/debug

From: Junwen Wu
Date: Sat Dec 16 2023 - 10:45:22 EST


For the sched_debug interface, print_task function has output
sum_exec_runtime twice, and the promt message not align with
the output, so optimize the output.

Signed-off-by: Junwen Wu <wudaemon@xxxxxxx>
---
kernel/sched/debug.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 4580a450700e..459109c12d68 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -579,13 +579,12 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
else
SEQ_printf(m, " %c", task_state_to_char(p));

- SEQ_printf(m, "%15s %5d %9Ld.%06ld %c %9Ld.%06ld %9Ld.%06ld %9Ld.%06ld %9Ld %5d ",
+ SEQ_printf(m, "%15s %5d %9Ld.%06ld %c %9Ld.%06ld %9Ld.%06ld %9Ld %5d ",
p->comm, task_pid_nr(p),
SPLIT_NS(p->se.vruntime),
entity_eligible(cfs_rq_of(&p->se), &p->se) ? 'E' : 'N',
SPLIT_NS(p->se.deadline),
SPLIT_NS(p->se.slice),
- SPLIT_NS(p->se.sum_exec_runtime),
(long long)(p->nvcsw + p->nivcsw),
p->prio);

@@ -596,10 +595,10 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
SPLIT_NS(schedstat_val_or_zero(p->stats.sum_block_runtime)));

#ifdef CONFIG_NUMA_BALANCING
- SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
+ SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
#endif
#ifdef CONFIG_CGROUP_SCHED
- SEQ_printf_task_group_path(m, task_group(p), " %s")
+ SEQ_printf_task_group_path(m, task_group(p), " %s")
#endif

SEQ_printf(m, "\n");
@@ -611,11 +610,18 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)

SEQ_printf(m, "\n");
SEQ_printf(m, "runnable tasks:\n");
- SEQ_printf(m, " S task PID tree-key switches prio"
- " wait-time sum-exec sum-sleep\n");
- SEQ_printf(m, "-------------------------------------------------------"
- "------------------------------------------------------\n");
-
+ SEQ_printf(m, " S task PID tree-key deadline"
+ " slice switches prio"
+ " wait-time sum-exec sum-sleep sum-block"
+#ifdef CONFIG_NUMA_BALANCING
+ " node_id"
+#endif
+#ifdef CONFIG_CGROUP_SCHED
+ " group\n");
+#endif
+ SEQ_printf(m, "-----------------------------------------------------------------"
+ "--------------------------------------------------------------------"
+ "------------------------------------------\n");
rcu_read_lock();
for_each_process_thread(g, p) {
if (task_cpu(p) != rq_cpu)
--
2.34.1