Expose each task's preferred LLC to aid diagnosis of cache-aware scheduling decisions. Suggested-by: XIAO WU Signed-off-by: Jianyong Wu --- kernel/sched/debug.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 40584b27ea0c..d18dbc1da67c 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -9,7 +9,9 @@ #include #include #include +#include #include "sched.h" +#include /* * This allows printing both to /sys/kernel/debug/sched/debug and @@ -1304,7 +1306,6 @@ void print_numa_stats(struct seq_file *m, int node, unsigned long tsf, } #endif - static void sched_show_numa(struct task_struct *p, struct seq_file *m) { #ifdef CONFIG_NUMA_BALANCING @@ -1320,6 +1321,30 @@ static void sched_show_numa(struct task_struct *p, struct seq_file *m) #endif /* CONFIG_NUMA_BALANCING */ } +static void sched_show_cache(struct task_struct *p, struct seq_file *m) +{ +#ifdef CONFIG_SCHED_CACHE + struct mm_struct *mm = NULL; + int sc_cpu, sc_llc, sc_node, pref_llc, pref_node; + + mm = get_task_mm(p); + + if (mm) { + sc_cpu = READ_ONCE(mm->sc_stat.cpu); + sc_llc = (sc_cpu >= 0) ? per_cpu(sd_llc_id, sc_cpu) : -1; + sc_node = (sc_cpu >= 0) ? cpu_to_node(sc_cpu) : -1; + pref_llc = READ_ONCE(p->preferred_llc); + pref_node = (pref_llc >= 0) ? llc_to_node(pref_llc) : -1; + + SEQ_printf(m, "sc_stat_cpu=%d, sc_llc=%d, sc_node=%d\n", + sc_cpu, sc_llc, sc_node); + SEQ_printf(m, "preferred_llc=%d, preferred_llc_node=%d\n", + pref_llc, pref_node); + mmput(mm); + } +#endif /* CONFIG_SCHED_CACHE */ +} + void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, struct seq_file *m) { @@ -1439,6 +1464,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, } sched_show_numa(p, m); + sched_show_cache(p, m); } void proc_sched_set_task(struct task_struct *p) -- 2.34.1