Skip to content

Commit 9e3bf94

Browse files
Valentin SchneiderIngo Molnar
authored andcommitted
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: Qais Yousef <[email protected]> Signed-off-by: Valentin Schneider <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent c745a62 commit 9e3bf94

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

kernel/sched/debug.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,12 @@ static int __init init_sched_debug_procfs(void)
816816

817817
__initcall(init_sched_debug_procfs);
818818

819-
#define __P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F)
820-
#define P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F)
821-
#define __PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F))
822-
#define PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F))
819+
#define __PS(S, F) SEQ_printf(m, "%-45s:%21Ld\n", S, (long long)(F))
820+
#define __P(F) __PS(#F, F)
821+
#define P(F) __PS(#F, p->F)
822+
#define __PSN(S, F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", S, SPLIT_NS((long long)(F)))
823+
#define __PN(F) __PSN(#F, F)
824+
#define PN(F) __PSN(#F, p->F)
823825

824826

825827
#ifdef CONFIG_NUMA_BALANCING
@@ -868,10 +870,9 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
868870
SEQ_printf(m,
869871
"---------------------------------------------------------"
870872
"----------\n");
871-
#define P_SCHEDSTAT(F) \
872-
SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)schedstat_val(p->F))
873-
#define PN_SCHEDSTAT(F) \
874-
SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)schedstat_val(p->F)))
873+
874+
#define P_SCHEDSTAT(F) __PS(#F, schedstat_val(p->F))
875+
#define PN_SCHEDSTAT(F) __PSN(#F, schedstat_val(p->F))
875876

876877
PN(se.exec_start);
877878
PN(se.vruntime);
@@ -931,10 +932,8 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
931932
}
932933

933934
__P(nr_switches);
934-
SEQ_printf(m, "%-45s:%21Ld\n",
935-
"nr_voluntary_switches", (long long)p->nvcsw);
936-
SEQ_printf(m, "%-45s:%21Ld\n",
937-
"nr_involuntary_switches", (long long)p->nivcsw);
935+
__PS("nr_voluntary_switches", p->nvcsw);
936+
__PS("nr_involuntary_switches", p->nivcsw);
938937

939938
P(se.load.weight);
940939
#ifdef CONFIG_SMP
@@ -963,8 +962,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
963962

964963
t0 = cpu_clock(this_cpu);
965964
t1 = cpu_clock(this_cpu);
966-
SEQ_printf(m, "%-45s:%21Ld\n",
967-
"clock-delta", (long long)(t1-t0));
965+
__PS("clock-delta", t1-t0);
968966
}
969967

970968
sched_show_numa(p, m);

0 commit comments

Comments
 (0)