: Add sparc64 ftrace support.
cover : Add sparc64 ftrace support.
This was a lot more trivial than I expected, about a 20 minute hack. Most of the time was spent on test boots :)
The first patch removes the packed attribute from the ftrace_page blob of dynamic ftrace entries, because not only does it cause unaligned accesses on sparc64 it's also totally useless.
The second patch adds sparc64 ftrace support.
One thing I noticed is that sparc64 uses an mcount implementation already for a quick-and-dirty stack usage checker. I tried to make them live alongside eachother.
Next, I think the mcount symbol export needs some tweaking. On sparc, the symbol _mcount is what the compiler references (this seems to be a sparc sysv4'ism) whereas on x86 it appears that plain "mcount" is used. I provide both symbols and we already have a local export of "_mcount" to take care of this. I think architectures should deal with this symbol exporting since it is different on every system.
Ingo Molnar
AppliedQuoted 2 lines · David Miller
This was a lot more trivial than I expected, about a 20 minute hack. Most of the time was spent on test boots :)
applied, thanks David. Cool stuff! :-)
Quoted 3 lines
The first patch removes the packed attribute from the
ftrace_pageblob of dynamic ftrace entries, because not only does it cause unaligned accesses on sparc64 it's also totally useless.
ok. It was so for purely histeric raisons, when we still tried to stuff it all into 32 bytes per trace entry, 3-4 years ago or so.
Quoted 5 lines
The second patch adds sparc64 ftrace support.
One thing I noticed is that sparc64 uses an mcount implementation already for a quick-and-dirty stack usage checker. I tried to make them live alongside eachother.
my thinking would be to perhaps also do an ftrace/max-stack plugin that would just measure the maximum stack footprint - coupled with emitting the stack trace itself to the trace buffer. This way we could measure the maximum stack footprint even of very yucky codepaths where we couldnt do a printk or other ad-hoc things.
While such an ftrace/max-stack plugin would be something very similar to and would reuse much of trace_functions.c, i think on the UI side it should be a separate tracer plugin. I.e. we could tell people "activate ftrace/max-stack" and they'd know what to do, and it would just do the right thing by default after a:
echo max-stack > /debug/tracing/current_tracer
Quoted 6 lines
Next, I think the mcount symbol export needs some tweaking. On sparc, the symbol
_mcountis what the compiler references (this seems to be a sparc sysv4'ism) whereas on x86 it appears that plain "mcount" is used. I provide both symbols and we already have a local export of "_mcount" to take care of this. I think architectures should deal with this symbol exporting since it is different on every system.
ok, agreed, fixed this bug on x86 - see the first patch below.
[ also a patch integration detail: i took the liberty to move your
arch/sparc64/Kconfig's HAVE_FTRACE to the first spot of the SPARC64 select lines as per the second patch below - your patch had a conflict against current mainline (which probably means you already changed this file in your Sparc64 tree). By moving that entry to the first line your tree and the ftrace tree should auto-merge just fine without any conflicts. ]
btw., if you have any ftrace usability observations (or any observations about it), let us know. ftrace tries to be self-contained (no user-space tools required) and 'intuitive by default' - i.e. someone looking into /debug/tracing/ and at the trace output for the first time should find his way around and should be able to operate most of its functionality without much effort.
But there lies the minor complication: it is pretty hard for us ftrace developers to look into /debug/tracing/ "for the first time", so we rely on others to tell us their first impressions, to improve the code :-)
Ingo
------------>
Subject: ftrace: fix mcount export bug
From: Ingo Molnar <[email protected]>
Date: Wed May 14 08:10:31 CEST 2008
David S. Miller noticed the following bug: the -pg instrumentation function callback is named differently on each platform. On x86 it is mcount, on sparc it is _mcount. So the export does not make sense in kernel/trace/ftrace.c - move it to x86.
--- arch/x86/kernel/i386_ksyms_32.c | 3 +++ arch/x86/kernel/x8664_ksyms_64.c | 3 +++ kernel/trace/ftrace.c | 3 --- 3 files changed, 6 insertions(+), 3 deletions(-)
arch/x86/kernel/i386_ksyms_32.c +3 -0
@@ -3,6 +3,9 @@#include <asm/desc.h> #include <asm/pgtable.h> +/* mcount is defined in assembly */ +EXPORT_SYMBOL (mcount); +/* Networking helper routines. */ EXPORT_SYMBOL (csum_partial_copy_generic);
arch/x86/kernel/x8664_ksyms_64.c +3 -0
@@ -10,6 +10,9 @@#include <asm/pgtable.h> #include <asm/desc.h> +/* mcount is defined in assembly */ +EXPORT_SYMBOL (mcount); +EXPORT_SYMBOL (kernel_thread);EXPORT_SYMBOL (__get_user_1);
kernel/trace/ftrace.c +0 -3
@@ -50,9 +50,6 @@ static struct ftrace_ops ftrace_list_endstatic struct ftrace_ops *ftrace_list__read_mostly = &ftrace_list_end;ftrace_func_t ftrace_trace_function__read_mostly = ftrace_stub; -/* mcount is defined per arch in assembly */ -EXPORT_SYMBOL (mcount); -void ftrace_list_func (unsigned long ip,unsigned long parent_ip) {struct ftrace_ops *op = ftrace_list;
------------------->
Subject: sparc64: add ftrace support.
From: David Miller <[email protected]>
Date: Tue, 13 May 2008 22:06:59 -0700 (PDT)
--- arch/sparc64/Kconfig | 1 arch/sparc64/Kconfig.debug | 2 arch/sparc64/kernel/Makefile | 1 arch/sparc64/kernel/ftrace.c | 99 +++++++++++++++++++++++++++++++++++++++++++ arch/sparc64/lib/mcount.S | 58 +++++++++++++++++++++++-- 5 files changed, 156 insertions(+), 5 deletions(-) create mode 100644 arch/sparc64/kernel/ftrace.c
arch/sparc64/Kconfig +1 -0
@@ -11,6 +11,7 @@ config SPARC config SPARC64 bool default y + select HAVE_FTRACE select HAVE_IDE select HAVE_LMB select HAVE_ARCH_KGDB
arch/sparc64/Kconfig.debug +1 -1
@@ -33,7 +33,7 @@ config DEBUG_PAGEALLOC config MCOUNT bool - depends on STACK_DEBUG + depends on STACK_DEBUG || FTRACE default y config FRAME_POINTER
arch/sparc64/kernel/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-y := process.o setup.o cpu.o idprom power.o sbus.o sparc64_ksyms.o chmc.o \ visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o +obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-$(CONFIG_PCI) += ebus.o pci_common.o \ pci_psycho.o pci_sabre.o pci_schizo.o \
arch/sparc64/kernel/ftrace.c new file +99 -0
99 lines not on this page · raw message
arch/sparc64/lib/mcount.S +54 -4
70 lines not on this page · raw message
Quoted 8 lines
[ also a patch integration detail: i took the liberty to move your
arch/sparc64/Kconfig'sHAVE_FTRACEto the first spot of the SPARC64 select lines as per the second patch below - your patch had a conflict against current mainline (which probably means you already changed this file in your Sparc64 tree). By moving that entry to the first line your tree and the ftrace tree should auto-merge just fine without any conflicts. ]
When adding new select entries I try to keep them sorted alphabetically. It will not solve all the merge issues but as the list grows this should help. At least betterthan adding to the end.
Sam
Quoted 11 lines · Sam Ravnborg
Quoted 7 lines
[ also a patch integration detail: i took the liberty to move your
arch/sparc64/Kconfig'sHAVE_FTRACEto the first spot of the SPARC64 select lines as per the second patch below - your patch had a conflict against current mainline (which probably means you already changed this file in your Sparc64 tree). By moving that entry to the first line your tree and the ftrace tree should auto-merge just fine without any conflicts. ]When adding new select entries I try to keep them sorted alphabetically. It will not solve all the merge issues but as the list grows this should help. At least betterthan adding to the end.
yep, i do that too in other cases - but the list here is very short. Btw., i also do sorting for include file names, such as in kernel/trace/ftrace.c:
#include <linux/stop_machine.h>
#include <linux/clocksource.h>
#include <linux/kallsyms.h>
#include <linux/seq_file.h>
#include <linux/debugfs.h>
#include <linux/kthread.h>
#include <linux/hardirq.h>
#include <linux/ftrace.h>
#include <linux/uaccess.h>
#include <linux/sysctl.h>
#include <linux/hash.h>
#include <linux/ctype.h>
#include <linux/list.h>
#include "trace.h"
(i also sort by length to make it visually more appealing. "Reverse christmas tree" sorting ;-)
[ and yes, linux/uaccess.h is mis-sorted - fixed. ]
Ingo
From: Ingo Molnar <[email protected]>
Date: Wed, 14 May 2008 09:01:48 +0200
Quoted 2 lines
(i also sort by length to make it visually more appealing. "Reverse christmas tree" sorting ;-)
I do this for local variable declarations too.
Quoted 7 lines · David Miller
From: Ingo Molnar <[email protected]>
Date: Wed, 14 May 2008 09:01:48 +0200Quoted 2 lines
(i also sort by length to make it visually more appealing. "Reverse christmas tree" sorting ;-)
I do this for local variable declarations too.
yeah, same here:
--------------------------------->
static void
ftrace_record_ip(unsigned long ip)
{
struct dyn_ftrace *node;
unsigned long flags;
unsigned long key;
int resched;
int atomic;
int cpu;
[...]
<--------------------------------for me the primary motivation isnt even merge conflicts in this case (getting conflicts on this level is rare), but readability and making it smooth to move the eye off the variable declarations.
IMO good code is obvious even without having to read the types, so the less visually intrusive the variable declarations section is, the better.
Ingo
Steven Rostedt
maintainerPATCH 1/1 ftrace: add have dynamic ftrace config for archs
In reply to David MillerNow that ftrace is being ported to other architectures, it has become apparent that DYNAMIC_FTRACE is dependent on whether or not that architecture implements dynamic ftrace. FTRACE itself may be ported to an architecture without porting dynamic ftrace.
This patch adds HAVE_DYNAMIC_FTRACE to allow architectures to port ftrace without having to also port the dynamic aspect as well.
--- arch/powerpc/Kconfig | 1 + arch/sparc64/Kconfig | 1 + arch/x86/Kconfig | 1 + kernel/trace/Kconfig | 4 ++++ 4 files changed, 7 insertions(+)
arch/powerpc/Kconfig +1 -0
@@ -107,6 +107,7 @@ config PPC default y select HAVE_IDE select HAVE_IMMEDIATE + select HAVE_DYNAMIC_FTRACE select HAVE_FTRACE select HAVE_KPROBES select HAVE_KRETPROBES
arch/sparc64/Kconfig +1 -0
@@ -11,6 +11,7 @@ config SPARC config SPARC64 bool default y + select HAVE_DYNAMIC_FTRACE select HAVE_FTRACE select HAVE_IDE select HAVE_LMB
arch/x86/Kconfig +1 -0
@@ -23,6 +23,7 @@ config X86 select HAVE_OPROFILE select HAVE_KPROBES select HAVE_KRETPROBES + select HAVE_DYNAMIC_FTRACE select HAVE_FTRACE select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) select HAVE_ARCH_KGDB if !X86_VOYAGER
kernel/trace/Kconfig +4 -0
@@ -4,6 +4,9 @@ config HAVE_FTRACE bool +config HAVE_DYNAMIC_FTRACE + bool + config TRACER_MAX_TRACE bool
@@ -102,6 +105,7 @@ config CONTEXT_SWITCH_TRACER config DYNAMIC_FTRACE bool "enable/disable ftrace tracepoints dynamically" depends on FTRACE + depends on HAVE_DYNAMIC_FTRACE default y help This option will modify all the calls to ftrace dynamically
Ingo Molnar
AppliedRe: [PATCH] ftrace: add have dynamic ftrace config for archs
Quoted 7 lines · Steven Rostedt
Now that ftrace is being ported to other architectures, it has become apparent that
DYNAMIC_FTRACEis dependent on whether or not that architecture implements dynamic ftrace. FTRACE itself may be ported to an architecture without porting dynamic ftrace.This patch adds
HAVE_DYNAMIC_FTRACEto allow architectures to port ftrace without having to also port the dynamic aspect as well.
applied, thanks Steven.
Ingo
Quoted 2 lines · David Miller
This was a lot more trivial than I expected, about a 20 minute hack. Most of the time was spent on test boots :)
Cool! This is what we tried to do with ftrace (make it trivial ;-)
Quoted 11 lines
The first patch removes the packed attribute from the
ftrace_pageblob of dynamic ftrace entries, because not only does it cause unaligned accesses on sparc64 it's also totally useless.The second patch adds sparc64 ftrace support.
One thing I noticed is that sparc64 uses an mcount implementation already for a quick-and-dirty stack usage checker. I tried to make them live alongside eachother.
Quoted 6 lines
Next, I think the mcount symbol export needs some tweaking. On sparc, the symbol
_mcountis what the compiler references (this seems to be a sparc sysv4'ism) whereas on x86 it appears that plain "mcount" is used. I provide both symbols and we already have a local export of "_mcount" to take care of this. I think architectures should deal with this symbol exporting since it is different on every system.
No, the same is for PPC (_mcount). I have a port for this ready. I'll look at your code and compare it with my PPC port.
Ingo, do you think it's time I can hand the PPC stuff over to you? I'll just have to update it to the lastest linux-ftrace.git.
Thanks,
-- Steve