lkml.org 
[lkml]   [2012]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 2/2] enable dumpstack() to printk log level
From
Date
From: he bo <bo.he@intel.com>

Function dump_stack calls printk with default log level.
At some scenarios, we need dump the logs at special log level.
For example, Android aplog saves log at a low level to reduce
log storage. With __might_sleep checking, it just prints out
the warning source line with KERNE_ERR and Android saves it to aplog,
but later dump_stack log is not saved. We couldn’t see the
important information when developers check it.
the patch adds function dump_stack_log_lvl to support this capability.

Signed-off-by: he, bo <bo.he@intel.com>
Reviewed-by: zhang, yanmin <yanmin.zhang@intel.com>
---
arch/x86/kernel/dumpstack.c | 19 ++++++++++++++-----
include/linux/printk.h | 1 +
kernel/sched/core.c | 2 +-
lib/dump_stack.c | 7 ++++++-
4 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 4025fe4..7b2160c 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -177,20 +177,29 @@ void show_stack(struct task_struct *task, unsigned long *sp)
}

/*
- * The architecture-independent dump_stack generator
+ * The architecture-independent dump_stack_log_lvl generator
*/
-void dump_stack(void)
+void dump_stack_log_lvl(char *log_lvl)
{
unsigned long bp;
unsigned long stack;

bp = stack_frame(current, NULL);
- printk("Pid: %d, comm: %.20s %s %s %.*s\n",
- current->pid, current->comm, print_tainted(),
+ printk("%sPid: %d, comm: %.20s %s %s %.*s\n",
+ log_lvl, current->pid, current->comm, print_tainted(),
init_utsname()->release,
(int)strcspn(init_utsname()->version, " "),
init_utsname()->version);
- show_trace(NULL, NULL, &stack, bp);
+ show_trace_log_lvl(NULL, NULL, &stack, bp, log_lvl);
+}
+EXPORT_SYMBOL(dump_stack_log_lvl);
+
+/*
+ * The architecture-independent dump_stack generator
+ */
+void dump_stack(void)
+{
+ dump_stack_log_lvl("");
}
EXPORT_SYMBOL(dump_stack);

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 0525927..2a13dd8 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -157,6 +157,7 @@ static inline void setup_log_buf(int early)
#endif

extern void dump_stack(void) __cold;
+extern void dump_stack_log_lvl(char *log_lvl) __cold;

#ifndef pr_fmt
#define pr_fmt(fmt) fmt
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 503d642..ab0dcdf 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7060,7 +7060,7 @@ void __might_sleep(const char *file, int line, int preempt_offset)
debug_show_held_locks(current);
if (irqs_disabled())
print_irqtrace_events(current);
- dump_stack();
+ dump_stack_log_lvl(KERN_ERR);
}
EXPORT_SYMBOL(__might_sleep);
#endif
diff --git a/lib/dump_stack.c b/lib/dump_stack.c
index 53bff4c..d44ca5e 100644
--- a/lib/dump_stack.c
+++ b/lib/dump_stack.c
@@ -11,5 +11,10 @@ void dump_stack(void)
printk(KERN_NOTICE
"This architecture does not implement dump_stack()\n");
}
-
EXPORT_SYMBOL(dump_stack);
+
+void dump_stack_log_lvl(char *log_lvl)
+{
+ dump_stack();
+}
+EXPORT_SYMBOL(dump_stack_log_lvl);
--
1.7.1



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-03-23 10:03    [from the cache]
©2003-2011 Jasper Spaans