Skip to content

Commit 3e28ad7

Browse files
committed
Merge branches 'sh/compressors' and 'sh/ftrace'
2 parents 040f43e + e460ab2 commit 3e28ad7

7 files changed

Lines changed: 60 additions & 73 deletions

File tree

‎arch/sh/Kconfig.debug‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ config EARLY_PRINTK
6161
select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using
6262
the kernel command line option to toggle back and forth.
6363

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

7173
config DEBUG_STACK_USAGE
7274
bool "Stack utilization instrumentation"
@@ -123,15 +125,9 @@ config SH64_SR_WATCH
123125
bool "Debug: set SR.WATCH to enable hardware watchpoints and trace"
124126
depends on SUPERH64
125127

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

137133
endmenu

‎arch/sh/Makefile‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ KBUILD_CFLAGS += -pipe $(cflags-y)
186186
KBUILD_CPPFLAGS += $(cflags-y)
187187
KBUILD_AFLAGS += $(cflags-y)
188188

189+
ifeq ($(CONFIG_MCOUNT),y)
190+
KBUILD_CFLAGS += -pg
191+
endif
192+
189193
libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
190194
libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
191195

‎arch/sh/boot/compressed/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \
2424

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

27-
ifeq ($(CONFIG_FUNCTION_TRACER),y)
27+
ifeq ($(CONFIG_MCOUNT),y)
2828
ORIG_CFLAGS := $(KBUILD_CFLAGS)
2929
KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
3030
endif

‎arch/sh/kernel/irq.c‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,6 @@ asmlinkage int do_IRQ(unsigned int irq, struct pt_regs *regs)
114114
#endif
115115

116116
irq_enter();
117-
118-
#ifdef CONFIG_DEBUG_STACKOVERFLOW
119-
/* Debugging check for stack overflow: is there less than 1KB free? */
120-
{
121-
long sp;
122-
123-
__asm__ __volatile__ ("and r15, %0" :
124-
"=r" (sp) : "0" (THREAD_SIZE - 1));
125-
126-
if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) {
127-
printk("do_IRQ: stack overflow: %ld\n",
128-
sp - sizeof(struct thread_info));
129-
dump_stack();
130-
}
131-
}
132-
#endif
133-
134117
irq = irq_demux(intc_evt2irq(irq));
135118

136119
#ifdef CONFIG_IRQSTACKS

‎arch/sh/kernel/sh_ksyms_32.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ EXPORT_SYMBOL(flush_dcache_page);
106106
EXPORT_SYMBOL(clear_user_page);
107107
#endif
108108

109-
#ifdef CONFIG_FUNCTION_TRACER
110-
EXPORT_SYMBOL(mcount);
109+
#ifdef CONFIG_MCOUNT
110+
DECLARE_EXPORT(mcount);
111111
#endif
112112
EXPORT_SYMBOL(csum_partial);
113113
EXPORT_SYMBOL(csum_partial_copy_generic);

‎arch/sh/lib/Makefile‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ memcpy-y := memcpy.o
2424
memcpy-$(CONFIG_CPU_SH4) := memcpy-sh4.o
2525

2626
lib-$(CONFIG_MMU) += copy_page.o clear_page.o
27-
lib-$(CONFIG_FUNCTION_TRACER) += mcount.o
28-
lib-$(CONFIG_FUNCTION_GRAPH_TRACER) += mcount.o
27+
lib-$(CONFIG_MCOUNT) += mcount.o
2928
lib-y += $(memcpy-y) $(udivsi3-y)
3029

3130
EXTRA_CFLAGS += -Werror

‎arch/sh/lib/mcount.S‎

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* arch/sh/lib/mcount.S
33
*
4-
* Copyright (C) 2008 Paul Mundt
4+
* Copyright (C) 2008, 2009 Paul Mundt
55
* Copyright (C) 2008, 2009 Matt Fleming
66
*
77
* This file is subject to the terms and conditions of the GNU General Public
@@ -86,13 +86,18 @@
8686
.type mcount,@function
8787
_mcount:
8888
mcount:
89+
STACK_CHECK()
90+
91+
#ifndef CONFIG_FUNCTION_TRACER
92+
rts
93+
nop
94+
#else
8995
#ifndef CONFIG_DYNAMIC_FTRACE
9096
mov.l .Lfunction_trace_stop, r0
9197
mov.l @r0, r0
9298
tst r0, r0
9399
bf ftrace_stub
94100
#endif
95-
STACK_CHECK()
96101

97102
MCOUNT_ENTER()
98103

@@ -174,8 +179,6 @@ ftrace_caller:
174179
tst r0, r0
175180
bf ftrace_stub
176181

177-
STACK_CHECK()
178-
179182
MCOUNT_ENTER()
180183

181184
.globl ftrace_call
@@ -192,14 +195,17 @@ ftrace_call:
192195
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
193196
#endif /* CONFIG_DYNAMIC_FTRACE */
194197

198+
.align 2
199+
.Lfunction_trace_stop:
200+
.long function_trace_stop
201+
195202
/*
196203
* NOTE: From here on the locations of the .Lftrace_stub label and
197204
* ftrace_stub itself are fixed. Adding additional data here will skew
198205
* the displacement for the memory table and break the block replacement.
199206
* Place new labels either after the ftrace_stub body, or before
200207
* ftrace_caller. You have been warned.
201208
*/
202-
.align 2
203209
.Lftrace_stub:
204210
.long ftrace_stub
205211

@@ -208,40 +214,6 @@ ftrace_stub:
208214
rts
209215
nop
210216

211-
#ifdef CONFIG_STACK_DEBUG
212-
.globl stack_panic
213-
stack_panic:
214-
mov.l .Ldump_stack, r0
215-
jsr @r0
216-
nop
217-
218-
mov.l .Lpanic, r0
219-
jsr @r0
220-
mov.l .Lpanic_s, r4
221-
222-
rts
223-
nop
224-
225-
.align 2
226-
.Lfunction_trace_stop:
227-
.long function_trace_stop
228-
.L_ebss:
229-
.long _ebss
230-
.L_init_thread_union:
231-
.long init_thread_union
232-
.Lpanic:
233-
.long panic
234-
.Lpanic_s:
235-
.long .Lpanic_str
236-
.Ldump_stack:
237-
.long dump_stack
238-
239-
.section .rodata
240-
.align 2
241-
.Lpanic_str:
242-
.string "Stack error"
243-
#endif /* CONFIG_STACK_DEBUG */
244-
245217
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
246218
.globl ftrace_graph_caller
247219
ftrace_graph_caller:
@@ -303,3 +275,36 @@ return_to_handler:
303275
.Lftrace_return_to_handler:
304276
.long ftrace_return_to_handler
305277
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
278+
#endif /* CONFIG_FUNCTION_TRACER */
279+
280+
#ifdef CONFIG_STACK_DEBUG
281+
.globl stack_panic
282+
stack_panic:
283+
mov.l .Ldump_stack, r0
284+
jsr @r0
285+
nop
286+
287+
mov.l .Lpanic, r0
288+
jsr @r0
289+
mov.l .Lpanic_s, r4
290+
291+
rts
292+
nop
293+
294+
.align 2
295+
.L_ebss:
296+
.long _ebss
297+
.L_init_thread_union:
298+
.long init_thread_union
299+
.Lpanic:
300+
.long panic
301+
.Lpanic_s:
302+
.long .Lpanic_str
303+
.Ldump_stack:
304+
.long dump_stack
305+
306+
.section .rodata
307+
.align 2
308+
.Lpanic_str:
309+
.string "Stack error"
310+
#endif /* CONFIG_STACK_DEBUG */

0 commit comments

Comments
 (0)