[PATCHv2 12/50] csky: Add show_stack_loglvl()
From: Dmitry Safonov
Date: Mon Mar 16 2020 - 10:40:41 EST
Currently, the log-level of show_stack() depends on a platform
realization. It creates situations where the headers are printed with
lower log level or higher than the stacktrace (depending on
a platform or user).
Furthermore, it forces the logic decision from user to an architecture
side. In result, some users as sysrq/kdb/etc are doing tricks with
temporary rising console_loglevel while printing their messages.
And in result it not only may print unwanted messages from other CPUs,
but also omit printing at all in the unlucky case where the printk()
was deferred.
Introducing log-level parameter and KERN_UNSUPPRESSED [1] seems
an easier approach than introducing more printk buffers.
Also, it will consolidate printings with headers.
Introduce show_stack_loglvl(), that eventually will substitute
show_stack().
Cc: Guo Ren <guoren@xxxxxxxxxx>
[1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@xxxxxxxxxx/T/#u
Signed-off-by: Dmitry Safonov <dima@xxxxxxxxxx>
---
arch/csky/kernel/dumpstack.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/arch/csky/kernel/dumpstack.c b/arch/csky/kernel/dumpstack.c
index d67f9777cfd9..c500837390d3 100644
--- a/arch/csky/kernel/dumpstack.c
+++ b/arch/csky/kernel/dumpstack.c
@@ -5,7 +5,7 @@
int kstack_depth_to_print = 48;
-void show_trace(unsigned long *stack)
+static void show_trace(unsigned long *stack, const char *loglvl)
{
unsigned long *stack_end;
unsigned long *stack_start;
@@ -17,7 +17,7 @@ void show_trace(unsigned long *stack)
stack_end = (unsigned long *) (addr + THREAD_SIZE);
fp = stack;
- pr_info("\nCall Trace:");
+ printk("%s\nCall Trace:", loglvl);
while (fp > stack_start && fp < stack_end) {
#ifdef CONFIG_STACKTRACE
@@ -32,7 +32,8 @@ void show_trace(unsigned long *stack)
pr_cont("\n");
}
-void show_stack(struct task_struct *task, unsigned long *stack)
+void show_stack_loglvl(struct task_struct *task, unsigned long *stack,
+ const char *loglvl)
{
if (!stack) {
if (task)
@@ -45,5 +46,10 @@ void show_stack(struct task_struct *task, unsigned long *stack)
#endif
}
- show_trace(stack);
+ show_trace(stack, loglvl);
+}
+
+void show_stack(struct task_struct *task, unsigned long *stack)
+{
+ show_stack_loglvl(task, stack, KERN_INFO);
}
--
2.25.1