Commit 9e3bf946 authored by Valentin Schneider's avatar Valentin Schneider Committed by Ingo Molnar

sched/debug: Factor out printing formats into common macros

The printing macros in debug.c keep redefining the same output
format. Collect each output format in a single definition, and reuse that
definition in the other macros. While at it, add a layer of parentheses and
replace printf's  with the newly introduced macros.
Reviewed-by: default avatarQais Yousef <qais.yousef@arm.com>
Signed-off-by: default avatarValentin Schneider <valentin.schneider@arm.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20200226124543.31986-3-valentin.schneider@arm.com
parent c745a621
...@@ -816,10 +816,12 @@ static int __init init_sched_debug_procfs(void) ...@@ -816,10 +816,12 @@ static int __init init_sched_debug_procfs(void)
__initcall(init_sched_debug_procfs); __initcall(init_sched_debug_procfs);
#define __P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F) #define __PS(S, F) SEQ_printf(m, "%-45s:%21Ld\n", S, (long long)(F))
#define P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F) #define __P(F) __PS(#F, F)
#define __PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F)) #define P(F) __PS(#F, p->F)
#define PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F)) #define __PSN(S, F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", S, SPLIT_NS((long long)(F)))
#define __PN(F) __PSN(#F, F)
#define PN(F) __PSN(#F, p->F)
#ifdef CONFIG_NUMA_BALANCING #ifdef CONFIG_NUMA_BALANCING
...@@ -868,10 +870,9 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, ...@@ -868,10 +870,9 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
SEQ_printf(m, SEQ_printf(m,
"---------------------------------------------------------" "---------------------------------------------------------"
"----------\n"); "----------\n");
#define P_SCHEDSTAT(F) \
SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)schedstat_val(p->F)) #define P_SCHEDSTAT(F) __PS(#F, schedstat_val(p->F))
#define PN_SCHEDSTAT(F) \ #define PN_SCHEDSTAT(F) __PSN(#F, schedstat_val(p->F))
SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)schedstat_val(p->F)))
PN(se.exec_start); PN(se.exec_start);
PN(se.vruntime); PN(se.vruntime);
...@@ -931,10 +932,8 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, ...@@ -931,10 +932,8 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
} }
__P(nr_switches); __P(nr_switches);
SEQ_printf(m, "%-45s:%21Ld\n", __PS("nr_voluntary_switches", p->nvcsw);
"nr_voluntary_switches", (long long)p->nvcsw); __PS("nr_involuntary_switches", p->nivcsw);
SEQ_printf(m, "%-45s:%21Ld\n",
"nr_involuntary_switches", (long long)p->nivcsw);
P(se.load.weight); P(se.load.weight);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
...@@ -963,8 +962,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, ...@@ -963,8 +962,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
t0 = cpu_clock(this_cpu); t0 = cpu_clock(this_cpu);
t1 = cpu_clock(this_cpu); t1 = cpu_clock(this_cpu);
SEQ_printf(m, "%-45s:%21Ld\n", __PS("clock-delta", t1-t0);
"clock-delta", (long long)(t1-t0));
} }
sched_show_numa(p, m); sched_show_numa(p, m);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment