From acfa0f545c7dd43f959c28e8ab4b139c927ba387 Mon Sep 17 00:00:00 2001 From: Qiang Xu Date: Mon, 28 Oct 2019 20:29:59 +0800 Subject: [PATCH] svm: reduce log of run queue and atomic->atomic64 ascend inclusion category: feature bugzilla: 16554 CVE: NA -------- svm add the catch the log of run queue, when open the sched debug Signed-off-by: Jiankang Chen Signed-off-by: Qiang Xu Signed-off-by: Lijun Fang Reviewed-by: Li Zefan Reviewed-by: Kefeng Wang Signed-off-by: Yang Yingliang --- drivers/char/svm.c | 21 ++++++++++++++++++--- kernel/sched/debug.c | 27 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/drivers/char/svm.c b/drivers/char/svm.c index 7ce90edbab11..cdd294ce23b5 100644 --- a/drivers/char/svm.c +++ b/drivers/char/svm.c @@ -108,7 +108,7 @@ struct svm_context { struct svm_process *process; struct svm_device *sdev; struct list_head process_head; - atomic_t ref; + atomic64_t ref; }; #ifndef CONFIG_ACPI @@ -169,6 +169,21 @@ static char *svm_cmd_to_string(unsigned int cmd) return NULL; } +#ifndef CONFIG_ACPI + +extern void sysrq_sched_debug_tidy(void); + +void sysrq_sched_debug_show_export(void) +{ +#ifdef CONFIG_SCHED_DEBUG + sysrq_sched_debug_tidy(); +#else + pr_err("Not open CONFIG_SCHED_DEBUG\n"); +#endif +} +EXPORT_SYMBOL(sysrq_sched_debug_show_export); +#endif + static struct svm_process *find_svm_process(unsigned long asid) { struct rb_node *node = svm_process_root.rb_node; @@ -742,7 +757,7 @@ static struct svm_context *svm_process_attach(struct svm_process *process, context->process = process; context->sdev = sdev; - atomic_set(&context->ref, 1); + atomic64_set(&context->ref, 1); #ifdef CONFIG_ACPI list_for_each_entry(pos, &child_list, entry) { svm_bind_core(pos, process); @@ -844,7 +859,7 @@ static int svm_process_bind(struct task_struct *task, *ttbr = virt_to_phys(mm->pgd) | asid << ASID_SHIFT; *tcr = read_sysreg(tcr_el1); *pasid = process->pasid; - atomic_inc(&context->ref); + atomic64_inc(&context->ref); /* One context keep a ref of process */ svm_process_put_locked(process); diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 78fadf0438ea..f664a7c2ea3e 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -780,6 +780,33 @@ void sysrq_sched_debug_show(void) } +static void print_cpu_tidy(struct seq_file *m, int cpu) +{ + struct rq *run_queue = cpu_rq(cpu); + unsigned long flags; + + SEQ_printf(m, "cpu#%d\n", cpu); + spin_lock_irqsave(&sched_debug_lock, flags); + + print_rq(m, run_queue, cpu); + spin_unlock_irqrestore(&sched_debug_lock, flags); + SEQ_printf(m, "\n"); + +} + +void sysrq_sched_debug_tidy(void) +{ + int cpu; + + SEQ_printf(NULL, "Sched Debug Version: v0.11, %s %.*s\n", + init_utsname()->release, + (int)strcspn(init_utsname()->version, " "), + init_utsname()->version); + + for_each_online_cpu(cpu) + print_cpu_tidy(NULL, cpu); +} + /* * This itererator needs some explanation. * It returns 1 for the header position. -- GitLab