Skip to content

Commit

Permalink
Merge branches 'sh/compressors' and 'sh/ftrace'
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Mundt committed Jul 12, 2009
2 parents 040f43e + e460ab2 commit 3e28ad7
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 73 deletions.
20 changes: 8 additions & 12 deletions arch/sh/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ config EARLY_PRINTK
select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using
the kernel command line option to toggle back and forth.

config DEBUG_STACKOVERFLOW
config STACK_DEBUG
bool "Check for stack overflows"
depends on DEBUG_KERNEL && SUPERH32
help
This option will cause messages to be printed if free stack space
drops below a certain limit.
drops below a certain limit. Saying Y here will add overhead to
every function call and will therefore incur a major
performance hit. Most users should say N.

config DEBUG_STACK_USAGE
bool "Stack utilization instrumentation"
Expand Down Expand Up @@ -123,15 +125,9 @@ config SH64_SR_WATCH
bool "Debug: set SR.WATCH to enable hardware watchpoints and trace"
depends on SUPERH64

config STACK_DEBUG
bool "Enable diagnostic checks of the kernel stack"
depends on FUNCTION_TRACER
select DEBUG_STACKOVERFLOW
default n
help
This option allows checks to be performed on the kernel stack
at runtime. Saying Y here will add overhead to every function
call and will therefore incur a major performance hit. Most
users should say N.
config MCOUNT
def_bool y
depends on SUPERH32
depends on STACK_DEBUG || FUNCTION_TRACER

endmenu
4 changes: 4 additions & 0 deletions arch/sh/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ KBUILD_CFLAGS += -pipe $(cflags-y)
KBUILD_CPPFLAGS += $(cflags-y)
KBUILD_AFLAGS += $(cflags-y)

ifeq ($(CONFIG_MCOUNT),y)
KBUILD_CFLAGS += -pg
endif

libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)

Expand Down
2 changes: 1 addition & 1 deletion arch/sh/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \

LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)

ifeq ($(CONFIG_FUNCTION_TRACER),y)
ifeq ($(CONFIG_MCOUNT),y)
ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
endif
Expand Down
17 changes: 0 additions & 17 deletions arch/sh/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,6 @@ asmlinkage int do_IRQ(unsigned int irq, struct pt_regs *regs)
#endif

irq_enter();

#ifdef CONFIG_DEBUG_STACKOVERFLOW
/* Debugging check for stack overflow: is there less than 1KB free? */
{
long sp;

__asm__ __volatile__ ("and r15, %0" :
"=r" (sp) : "0" (THREAD_SIZE - 1));

if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) {
printk("do_IRQ: stack overflow: %ld\n",
sp - sizeof(struct thread_info));
dump_stack();
}
}
#endif

irq = irq_demux(intc_evt2irq(irq));

#ifdef CONFIG_IRQSTACKS
Expand Down
4 changes: 2 additions & 2 deletions arch/sh/kernel/sh_ksyms_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ EXPORT_SYMBOL(flush_dcache_page);
EXPORT_SYMBOL(clear_user_page);
#endif

#ifdef CONFIG_FUNCTION_TRACER
EXPORT_SYMBOL(mcount);
#ifdef CONFIG_MCOUNT
DECLARE_EXPORT(mcount);
#endif
EXPORT_SYMBOL(csum_partial);
EXPORT_SYMBOL(csum_partial_copy_generic);
Expand Down
3 changes: 1 addition & 2 deletions arch/sh/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ memcpy-y := memcpy.o
memcpy-$(CONFIG_CPU_SH4) := memcpy-sh4.o

lib-$(CONFIG_MMU) += copy_page.o clear_page.o
lib-$(CONFIG_FUNCTION_TRACER) += mcount.o
lib-$(CONFIG_FUNCTION_GRAPH_TRACER) += mcount.o
lib-$(CONFIG_MCOUNT) += mcount.o
lib-y += $(memcpy-y) $(udivsi3-y)

EXTRA_CFLAGS += -Werror
83 changes: 44 additions & 39 deletions arch/sh/lib/mcount.S
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* arch/sh/lib/mcount.S
*
* Copyright (C) 2008 Paul Mundt
* Copyright (C) 2008, 2009 Paul Mundt
* Copyright (C) 2008, 2009 Matt Fleming
*
* This file is subject to the terms and conditions of the GNU General Public
Expand Down Expand Up @@ -86,13 +86,18 @@
.type mcount,@function
_mcount:
mcount:
STACK_CHECK()

#ifndef CONFIG_FUNCTION_TRACER
rts
nop
#else
#ifndef CONFIG_DYNAMIC_FTRACE
mov.l .Lfunction_trace_stop, r0
mov.l @r0, r0
tst r0, r0
bf ftrace_stub
#endif
STACK_CHECK()

MCOUNT_ENTER()

Expand Down Expand Up @@ -174,8 +179,6 @@ ftrace_caller:
tst r0, r0
bf ftrace_stub

STACK_CHECK()

MCOUNT_ENTER()

.globl ftrace_call
Expand All @@ -192,14 +195,17 @@ ftrace_call:
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
#endif /* CONFIG_DYNAMIC_FTRACE */

.align 2
.Lfunction_trace_stop:
.long function_trace_stop

/*
* NOTE: From here on the locations of the .Lftrace_stub label and
* ftrace_stub itself are fixed. Adding additional data here will skew
* the displacement for the memory table and break the block replacement.
* Place new labels either after the ftrace_stub body, or before
* ftrace_caller. You have been warned.
*/
.align 2
.Lftrace_stub:
.long ftrace_stub

Expand All @@ -208,40 +214,6 @@ ftrace_stub:
rts
nop

#ifdef CONFIG_STACK_DEBUG
.globl stack_panic
stack_panic:
mov.l .Ldump_stack, r0
jsr @r0
nop

mov.l .Lpanic, r0
jsr @r0
mov.l .Lpanic_s, r4

rts
nop

.align 2
.Lfunction_trace_stop:
.long function_trace_stop
.L_ebss:
.long _ebss
.L_init_thread_union:
.long init_thread_union
.Lpanic:
.long panic
.Lpanic_s:
.long .Lpanic_str
.Ldump_stack:
.long dump_stack

.section .rodata
.align 2
.Lpanic_str:
.string "Stack error"
#endif /* CONFIG_STACK_DEBUG */

#ifdef CONFIG_FUNCTION_GRAPH_TRACER
.globl ftrace_graph_caller
ftrace_graph_caller:
Expand Down Expand Up @@ -303,3 +275,36 @@ return_to_handler:
.Lftrace_return_to_handler:
.long ftrace_return_to_handler
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
#endif /* CONFIG_FUNCTION_TRACER */

#ifdef CONFIG_STACK_DEBUG
.globl stack_panic
stack_panic:
mov.l .Ldump_stack, r0
jsr @r0
nop

mov.l .Lpanic, r0
jsr @r0
mov.l .Lpanic_s, r4

rts
nop

.align 2
.L_ebss:
.long _ebss
.L_init_thread_union:
.long init_thread_union
.Lpanic:
.long panic
.Lpanic_s:
.long .Lpanic_str
.Ldump_stack:
.long dump_stack

.section .rodata
.align 2
.Lpanic_str:
.string "Stack error"
#endif /* CONFIG_STACK_DEBUG */

0 comments on commit 3e28ad7

Please sign in to comment.