linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dump_stack: convert generic dump_stack into a weak symbol
@ 2018-03-05  5:37 Sergey Senozhatsky
  2018-03-05 14:48 ` Petr Mladek
  2018-03-06 13:27 ` Arnd Bergmann
  0 siblings, 2 replies; 28+ messages in thread
From: Sergey Senozhatsky @ 2018-03-05  5:37 UTC (permalink / raw)
  To: Petr Mladek, Tejun Heo, Steven Rostedt, Dave Young, Andi Kleen,
	Greentime Hu, Vincent Chen, Arnd Bergmann
  Cc: Peter Zijlstra, Andrew Morton, Stephen Rothwell,
	adi-buildroot-devel, linux-kernel, Sergey Senozhatsky

We want to move dump_stack related functions out of printk C
code and consolidate them in lib/dump_stack file. The reason why
dump_stack_print_info()/etc ended up in printk.c was a "generic"
(dummy) lib dump_stack() function, which archs can override.
For example, blackfin and nds32, define their own EXPORT_SYMBOL
dump_stack() functions.

In case of blackfin that arch-specific dump_stack() symbol invokes
a global dump_stack_print_info() function. So we can't easily move
dump_stack_print_info() to lib/dump_stack, because this way we will
link with lib/dump_stack.o file, which will bring in a generic
dump_stack() symbol with it, causing a multiple definitions error:
  - one dump_stack() from arch/blackfin/dumpstack
  - the other one from lib/dump_stack

Convert generic dump_stack() into a weak symbol. So we will be
able link with lib/dump_stack and at the same time archs will
be able to override dump_stack(). It also opens up a way for us
to move dump_stack_set_arch_desc(), dump_stack_print_info() and
show_regs_print_info() to lib/dump_stack.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 arch/blackfin/kernel/dumpstack.c | 1 -
 arch/nds32/kernel/traps.c        | 2 --
 lib/dump_stack.c                 | 4 ++--
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/blackfin/kernel/dumpstack.c b/arch/blackfin/kernel/dumpstack.c
index 3c992c1f8ef2..61af017130cd 100644
--- a/arch/blackfin/kernel/dumpstack.c
+++ b/arch/blackfin/kernel/dumpstack.c
@@ -174,4 +174,3 @@ void dump_stack(void)
 	show_stack(current, &stack);
 	trace_buffer_restore(tflags);
 }
-EXPORT_SYMBOL(dump_stack);
diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c
index 8828b4aeb72b..455bb0787367 100644
--- a/arch/nds32/kernel/traps.c
+++ b/arch/nds32/kernel/traps.c
@@ -166,8 +166,6 @@ void dump_stack(void)
 	__dump(NULL, base_reg);
 }
 
-EXPORT_SYMBOL(dump_stack);
-
 void show_stack(struct task_struct *tsk, unsigned long *sp)
 {
 	unsigned long *base_reg;
diff --git a/lib/dump_stack.c b/lib/dump_stack.c
index c5edbedd364d..02a8ad163760 100644
--- a/lib/dump_stack.c
+++ b/lib/dump_stack.c
@@ -25,7 +25,7 @@ static void __dump_stack(void)
 #ifdef CONFIG_SMP
 static atomic_t dump_lock = ATOMIC_INIT(-1);
 
-asmlinkage __visible void dump_stack(void)
+asmlinkage __weak __visible void dump_stack(void)
 {
 	unsigned long flags;
 	int was_locked;
@@ -58,7 +58,7 @@ asmlinkage __visible void dump_stack(void)
 	local_irq_restore(flags);
 }
 #else
-asmlinkage __visible void dump_stack(void)
+asmlinkage __weak __visible void dump_stack(void)
 {
 	__dump_stack();
 }
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2018-03-14 23:59 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05  5:37 [PATCH] dump_stack: convert generic dump_stack into a weak symbol Sergey Senozhatsky
2018-03-05 14:48 ` Petr Mladek
2018-03-06  2:50   ` Greentime Hu
2018-03-06  4:31     ` Sergey Senozhatsky
2018-03-06  5:34       ` Greentime Hu
2018-03-06  4:29   ` Sergey Senozhatsky
2018-03-06 12:43     ` Petr Mladek
2018-03-06 22:52       ` Stephen Rothwell
2018-03-06 13:27 ` Arnd Bergmann
2018-03-07  2:21   ` Sergey Senozhatsky
2018-03-07  8:46     ` Arnd Bergmann
2018-03-07  9:09       ` Petr Mladek
2018-03-07  9:44         ` Greentime Hu
2018-03-07  9:50           ` Arnd Bergmann
2018-03-07 10:40       ` Sergey Senozhatsky
2018-03-07 10:57         ` Arnd Bergmann
2018-03-07 11:48           ` Sergey Senozhatsky
2018-03-07 12:41             ` Stephen Rothwell
2018-03-07 12:48               ` Arnd Bergmann
2018-03-07 12:53                 ` Stephen Rothwell
2018-03-07 12:58                   ` Arnd Bergmann
2018-03-07 13:10                     ` Stephen Rothwell
2018-03-07 13:40                 ` Sergey Senozhatsky
2018-03-07 14:01               ` Sergey Senozhatsky
2018-03-09  9:50             ` Petr Mladek
2018-03-14 23:42               ` Steven Rostedt
2018-03-14 23:58                 ` Stephen Rothwell
2018-03-07  8:49     ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).