powerpc: split ftrace bits into separate files
v3 cover powerpc: split ftrace bits into separate files
v2: https://patchwork.ozlabs.org/patch/697787/
Michael,
Sorry this took as long as it did, but here's a take at v3. This series conflicts with the KPROBES_ON_FTRACE patchset, but I'm posting this so as to get feedback. I will rework these patches as needed.
Thanks,
Naveen
Naveen N. Rao (2):
powerpc: split ftrace bits into a separate file
powerpc: ftrace_64: split further based on -mprofile-kernel
arch/powerpc/kernel/Makefile | 9 +-
arch/powerpc/kernel/entry_32.S | 107 -------
arch/powerpc/kernel/entry_64.S | 380 -------------------------
arch/powerpc/kernel/trace/Makefile | 29 ++
arch/powerpc/kernel/{ => trace}/ftrace.c | 0
arch/powerpc/kernel/trace/ftrace_32.S | 118 ++++++++
arch/powerpc/kernel/trace/ftrace_64.S | 85 ++++++
arch/powerpc/kernel/trace/ftrace_64_mprofile.S | 274 ++++++++++++++++++
arch/powerpc/kernel/trace/ftrace_64_pg.S | 68 +++++
arch/powerpc/kernel/{ => trace}/trace_clock.c | 0
10 files changed, 575 insertions(+), 495 deletions(-)
create mode 100644 arch/powerpc/kernel/trace/Makefile
rename arch/powerpc/kernel/{ => trace}/ftrace.c (100%)
create mode 100644 arch/powerpc/kernel/trace/ftrace_32.S
create mode 100644 arch/powerpc/kernel/trace/ftrace_64.S
create mode 100644 arch/powerpc/kernel/trace/ftrace_64_mprofile.S
create mode 100644 arch/powerpc/kernel/trace/ftrace_64_pg.S
rename arch/powerpc/kernel/{ => trace}/trace_clock.c (100%)Signature · 1 line
2.11.0
PATCH v3 1/2 powerpc: split ftrace bits into a separate file
entry_*.S now includes a lot more than just kernel entry/exit code. As a first step at cleaning this up, let's split out the ftrace bits into separate files. Also move all related tracing code into a new trace/ subdirectory.
No functional changes.
---
arch/powerpc/kernel/Makefile | 9 +-
arch/powerpc/kernel/entry_32.S | 107 -------
arch/powerpc/kernel/entry_64.S | 380 -------------------------
arch/powerpc/kernel/trace/Makefile | 24 ++
arch/powerpc/kernel/{ => trace}/ftrace.c | 0
arch/powerpc/kernel/trace/ftrace_32.S | 118 ++++++++
arch/powerpc/kernel/trace/ftrace_64.S | 391 ++++++++++++++++++++++++++
arch/powerpc/kernel/{ => trace}/trace_clock.c | 0
8 files changed, 534 insertions(+), 495 deletions(-)
create mode 100644 arch/powerpc/kernel/trace/Makefile
rename arch/powerpc/kernel/{ => trace}/ftrace.c (100%)
create mode 100644 arch/powerpc/kernel/trace/ftrace_32.S
create mode 100644 arch/powerpc/kernel/trace/ftrace_64.S
rename arch/powerpc/kernel/{ => trace}/trace_clock.c (100%)arch/powerpc/kernel/Makefile +1 -8
@@ -29,8 +29,6 @@ CFLAGS_REMOVE_cputable.o = -mno-sched-epilog $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_prom_init.o = -mno-sched-epilog $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_btext.o = -mno-sched-epilog $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_prom.o = -mno-sched-epilog $(CC_FLAGS_FTRACE) -# do not trace tracer code -CFLAGS_REMOVE_ftrace.o = -mno-sched-epilog $(CC_FLAGS_FTRACE) # timers used by tracing CFLAGS_REMOVE_time.o = -mno-sched-epilog $(CC_FLAGS_FTRACE) endif
@@ -122,10 +120,7 @@ obj64-$(CONFIG_AUDIT) += compat_audit.o obj-$(CONFIG_PPC_IO_WORKAROUNDS) += io-workarounds.o -obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o -obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o -obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o -obj-$(CONFIG_TRACING) += trace_clock.o +obj-y += trace/ ifneq ($(CONFIG_PPC_INDIRECT_PIO),y) obj-y += iomap.o
@@ -146,8 +141,6 @@ obj-$(CONFIG_KVM_GUEST) += kvm.o kvm_emul.o # Disable GCOV & sanitizers in odd or sensitive code GCOV_PROFILE_prom_init.o := n UBSAN_SANITIZE_prom_init.o := n -GCOV_PROFILE_ftrace.o := n -UBSAN_SANITIZE_ftrace.o := n GCOV_PROFILE_machine_kexec_64.o := n UBSAN_SANITIZE_machine_kexec_64.o := n GCOV_PROFILE_machine_kexec_32.o := n
arch/powerpc/kernel/entry_32.S +0 -107
116 lines not on this page · raw message
arch/powerpc/kernel/entry_64.S +0 -380
395 lines not on this page · raw message
arch/powerpc/kernel/trace/Makefile new file +24 -0
@@ -0,0 +1,24 @@ +# +# Makefile for the powerpc trace subsystem +# + +subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror + +ifdef CONFIG_FUNCTION_TRACER +# do not trace tracer code +CFLAGS_REMOVE_ftrace.o = -mno-sched-epilog $(CC_FLAGS_FTRACE) +endif + +obj32-$(CONFIG_FUNCTION_TRACER) += ftrace_32.o +obj64-$(CONFIG_FUNCTION_TRACER) += ftrace_64.o +obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o +obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o +obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o +obj-$(CONFIG_TRACING) += trace_clock.o + +obj-$(CONFIG_PPC64) += $(obj64-y) +obj-$(CONFIG_PPC32) += $(obj32-y) + +# Disable GCOV & sanitizers in odd or sensitive code +GCOV_PROFILE_ftrace.o := n +UBSAN_SANITIZE_ftrace.o := n
arch/powerpc/kernel/trace/ftrace.c renamed from arch/powerpc/kernel/ftrace.c +0 -0
arch/powerpc/kernel/trace/ftrace_32.S new file +118 -0
118 lines not on this page · raw message
arch/powerpc/kernel/trace/ftrace_64.S new file +391 -0
391 lines not on this page · raw message
arch/powerpc/kernel/trace/trace_clock.c renamed from arch/powerpc/kernel/trace_clock.c +0 -0
Signature · 1 line
2.11.0
Steven Rostedt
maintainerRe: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
Quoted 6 lines · On Wed, 22 Feb 2017 00:31:01 +0530 "Naveen N. Rao"…
entry_*.S now includes a lot more than just kernel entry/exit code. As a first step at cleaning this up, let's split out the ftrace bits into separate files. Also move all related tracing code into a new trace/ subdirectory.
No functional changes.
I wonder if we should stay consistent among archs, and call these files "mcount_*.S". Or perhaps we should change x86 from mcount_64.S to ftrace_64.S?
-- Steve
Michael Ellerman
reviewerRe: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
Quoted 8 lines · Steven Rostedt
Quoted 5 lines · On Wed, 22 Feb 2017 00:31:01 +0530 "Naveen N. Rao"…
entry_*.S now includes a lot more than just kernel entry/exit code. As a first step at cleaning this up, let's split out the ftrace bits into separate files. Also move all related tracing code into a new trace/ subdirectory.
Quoted 5 lines
Quoted 1 line
No functional changes.
I wonder if we should stay consistent among archs, and call these files "mcount_*.S". Or perhaps we should change x86 from
mcount_64.Stoftrace_64.S?
I prefer ftrace_64.S, there's a lot more in those files than just the mcount() implementation, and it also makes the link to kernel/trace/ftrace.c more obvious.
I don't know if it's really worth keeping the names the same across arches, especially as we already have:
arch/arm64/kernel/entry-ftrace.S
arch/arm/kernel/entry-ftrace.S
arch/blackfin/kernel/ftrace-entry.S
arch/metag/kernel/ftrace_stub.S
But we can rename it if you feel strongly about it.
cheers
Steven Rostedt
maintainerRe: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
On Tue, 28 Feb 2017 15:04:15 +1100
Michael Ellerman <[email protected]> wrote:
kernel/trace/ftrace.c more obvious.
Quoted 10 lines
I don't know if it's really worth keeping the names the same across arches, especially as we already have:
arch/arm64/kernel/entry-ftrace.S
arch/arm/kernel/entry-ftrace.S
arch/blackfin/kernel/ftrace-entry.S
arch/metag/kernel/ftrace_stub.SBut we can rename it if you feel strongly about it.
Hmm, perhaps "entry-ftrace.S" would be the better name. I never liked the "mcount.S" name.
-- Steve
Re: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
Quoted 13 lines · Steven Rostedt
On Tue, 28 Feb 2017 15:04:15 +1100
Michael Ellerman <[email protected]> wrote:
kernel/trace/ftrace.cmore obvious.Quoted 9 lines
I don't know if it's really worth keeping the names the same across arches, especially as we already have:
arch/arm64/kernel/entry-ftrace.S
arch/arm/kernel/entry-ftrace.S
arch/blackfin/kernel/ftrace-entry.S
arch/metag/kernel/ftrace_stub.S
Quoted 4 lines
Quoted 1 line
But we can rename it if you feel strongly about it.
Hmm, perhaps "
entry-ftrace.S" would be the better name. I never liked the "mcount.S" name.
Ok, just to be sure I get this right -- do you want me to name the powerpc files entry_ftrace_64.S (and subsequently to a slightly long entry_ftrace_64_mprofile.S), or rename the x86 mcount* files? Or both?
Thanks for the review,
- Naveen
Michael Ellerman
reviewerRe: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
In reply to Steven RostedtQuoted 13 lines · Steven Rostedt
On Tue, 28 Feb 2017 15:04:15 +1100
Michael Ellerman <[email protected]> wrote:
kernel/trace/ftrace.cmore obvious.Quoted 9 lines
I don't know if it's really worth keeping the names the same across arches, especially as we already have:
arch/arm64/kernel/entry-ftrace.S
arch/arm/kernel/entry-ftrace.S
arch/blackfin/kernel/ftrace-entry.S
arch/metag/kernel/ftrace_stub.S
Quoted 4 lines
Quoted 1 line
But we can rename it if you feel strongly about it.
Hmm, perhaps "
entry-ftrace.S" would be the better name. I never liked the "mcount.S" name.
Except what does the "entry" part mean?
Traditionally entry.S has been for the code that "enters" the kernel, ie. from userspace or elsewhere. But that's not the case with any of the ftrace code, it's kernel code called from the kernel. So using "entry" is a bit wrong IMHO.
So if we drop that we're left with ftrace.S - which seems perfect to me.
cheers
Re: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
Quoted 20 lines · Michael Ellerman
Quoted 13 lines · Steven Rostedt
On Tue, 28 Feb 2017 15:04:15 +1100
Michael Ellerman <[email protected]> wrote:
kernel/trace/ftrace.cmore obvious.Quoted 9 lines
I don't know if it's really worth keeping the names the same across arches, especially as we already have:
arch/arm64/kernel/entry-ftrace.S
arch/arm/kernel/entry-ftrace.S
arch/blackfin/kernel/ftrace-entry.S
arch/metag/kernel/ftrace_stub.SQuoted 4 lines
Quoted 1 line
But we can rename it if you feel strongly about it.
Hmm, perhaps "
entry-ftrace.S" would be the better name. I never liked the "mcount.S" name.
Quoted 8 lines
Except what does the "entry" part mean?
Traditionally
entry.Shas been for the code that "enters" the kernel, ie. from userspace or elsewhere. But that's not the case with any of the ftrace code, it's kernel code called from the kernel. So using "entry" is a bit wrong IMHO.So if we drop that we're left with
ftrace.S- which seems perfect to me.
Hi Steve,
Are you ok with this? I'd prefer to not add the 'entry-' prefix too, seeing as it will make the file names quite long without necessarily adding much.
Thanks,
Naveen
Steven Rostedt
maintainerRe: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
In reply to Michael EllermanQuoted 20 lines · On Thu, 02 Mar 2017 20:38:53 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 13 lines · Steven Rostedt
On Tue, 28 Feb 2017 15:04:15 +1100
Michael Ellerman <[email protected]> wrote:
kernel/trace/ftrace.cmore obvious.Quoted 9 lines
I don't know if it's really worth keeping the names the same across arches, especially as we already have:
arch/arm64/kernel/entry-ftrace.S
arch/arm/kernel/entry-ftrace.S
arch/blackfin/kernel/ftrace-entry.S
arch/metag/kernel/ftrace_stub.SQuoted 4 lines
Quoted 1 line
But we can rename it if you feel strongly about it.
Hmm, perhaps "
entry-ftrace.S" would be the better name. I never liked the "mcount.S" name.
Quoted 8 lines
Except what does the "entry" part mean?
Traditionally
entry.Shas been for the code that "enters" the kernel, ie. from userspace or elsewhere. But that's not the case with any of the ftrace code, it's kernel code called from the kernel. So using "entry" is a bit wrong IMHO.So if we drop that we're left with
ftrace.S- which seems perfect to me.
Yeah, I agree. But then there's the problem that ftrace.c and ftrace.S will get the same ftrace.o. Maybe make it ftrace-hook.S ?
-- Steve
Re: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
Quoted 30 lines · Steven Rostedt
Quoted 27 lines · On Thu, 02 Mar 2017 20:38:53 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 13 lines · Steven Rostedt
On Tue, 28 Feb 2017 15:04:15 +1100
Michael Ellerman <[email protected]> wrote:
kernel/trace/ftrace.cmore obvious.Quoted 9 lines
I don't know if it's really worth keeping the names the same across arches, especially as we already have:
arch/arm64/kernel/entry-ftrace.S
arch/arm/kernel/entry-ftrace.S
arch/blackfin/kernel/ftrace-entry.S
arch/metag/kernel/ftrace_stub.SQuoted 4 lines
Quoted 1 line
But we can rename it if you feel strongly about it.
Hmm, perhaps "
entry-ftrace.S" would be the better name. I never liked the "mcount.S" name.Except what does the "entry" part mean?
Traditionally
entry.Shas been for the code that "enters" the kernel, ie. from userspace or elsewhere. But that's not the case with any of the ftrace code, it's kernel code called from the kernel. So using "entry" is a bit wrong IMHO.
Quoted 4 lines
Quoted 1 line
So if we drop that we're left with
ftrace.S- which seems perfect to me.Yeah, I agree. But then there's the problem that
ftrace.candftrace.Swill get the same ftrace.o. Maybe make itftrace-hook.S?
I've avoided that issue by naming the files ftrace_32.S and ftrace_64.S (which gets further split up).
Thanks,
Naveen
Steven Rostedt
maintainerRe: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
Quoted 11 lines · On Fri, 10 Mar 2017 21:38:53 +0530 "Naveen N. Rao"…
Quoted 7 lines · Steven Rostedt
Quoted 1 line · On Thu, 02 Mar 2017 20:38:53 +1100 Michael Ellerman <[email protected]> wrote:
So if we drop that we're left with
ftrace.S- which seems perfect to me.Yeah, I agree. But then there's the problem that
ftrace.candftrace.Swill get the same ftrace.o. Maybe make itftrace-hook.S?I've avoided that issue by naming the files
ftrace_32.Sandftrace_64.S(which gets further split up).
That's what I looked at doing for x86 as well. But not all archs have 32 / 64 splits. Should we look to have something that all archs can be consistent with?
-- Steve
Re: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
Quoted 12 lines · Steven Rostedt
Quoted 9 lines · On Fri, 10 Mar 2017 21:38:53 +0530 "Naveen N. Rao"…
Quoted 7 lines · Steven Rostedt
Quoted 1 line · On Thu, 02 Mar 2017 20:38:53 +1100 Michael Ellerman <[email protected]> wrote:
So if we drop that we're left with
ftrace.S- which seems perfect to me.Yeah, I agree. But then there's the problem that
ftrace.candftrace.Swill get the same ftrace.o. Maybe make itftrace-hook.S?
Quoted 6 lines
Quoted 2 lines
I've avoided that issue by naming the files
ftrace_32.Sandftrace_64.S(which gets further split up).That's what I looked at doing for x86 as well. But not all archs have 32 / 64 splits. Should we look to have something that all archs can be consistent with?
I don't have a strong opinion about this, but I feel that x86 can simply use ftrace_64.S, seeing as the current name is mcount_64.S.
Other architectures could do something similar too, or fall back to ftrace_hook.S. That way, all ftrace low-level code can simply be referred to as arch/*/ftrace_*.S
- Naveen
Steven Rostedt
maintainerRe: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
Quoted 6 lines · On Wed, 15 Mar 2017 14:35:16 +0530 "Naveen N. Rao"…
I don't have a strong opinion about this, but I feel that x86 can simply use
ftrace_64.S, seeing as the current name ismcount_64.S.Other architectures could do something similar too, or fall back to
ftrace_hook.S. That way, all ftrace low-level code can simply be referred to asarch/*/ftrace_*.S
Just to clarify, I'm currently working on patches to clean up the ftrace.S code in x86, and I renamed mcount_64.S to ftrace_64.S. I'm also moving the ftrace code out of entry_32.S into a ftrace_32.S file as well. Patches will hopefully be posted soon.
-- Steve
Re: [PATCH v3 1/2] powerpc: split ftrace bits into a separate file
Quoted 6 lines · Steven Rostedt
Quoted 3 lines · On Wed, 15 Mar 2017 14:35:16 +0530 "Naveen N. Rao"…
I don't have a strong opinion about this, but I feel that x86 can simply use
ftrace_64.S, seeing as the current name ismcount_64.S.
Quoted 8 lines
Quoted 3 lines
Other architectures could do something similar too, or fall back to
ftrace_hook.S. That way, all ftrace low-level code can simply be referred to asarch/*/ftrace_*.SJust to clarify, I'm currently working on patches to clean up the
ftrace.Scode in x86, and I renamedmcount_64.Stoftrace_64.S. I'm also moving the ftrace code out ofentry_32.Sinto aftrace_32.Sfile as well. Patches will hopefully be posted soon.
Good to know, thanks for clarifying.
In light of that, I hope that you're ok with the changes proposed to the ftrace bits under arch/powerpc in this patchset?
- Naveen
PATCH v3 2/2 powerpc: ftrace_64: split further based on -mprofile-kernel
In reply to Naveen N. RaoSplit ftrace_64.S further retaining the core ftrace 64-bit aspects in ftrace_64.S and moving ftrace_caller() and ftrace_graph_caller() into separate files based on -mprofile-kernel. The livepatch routines are all now contained within the mprofile file.
--- arch/powerpc/kernel/trace/Makefile | 5 + arch/powerpc/kernel/trace/ftrace_64.S | 308 +------------------------ arch/powerpc/kernel/trace/ftrace_64_mprofile.S | 274 ++++++++++++++++++++++ arch/powerpc/kernel/trace/ftrace_64_pg.S | 68 ++++++ 4 files changed, 348 insertions(+), 307 deletions(-) create mode 100644 arch/powerpc/kernel/trace/ftrace_64_mprofile.S create mode 100644 arch/powerpc/kernel/trace/ftrace_64_pg.S
arch/powerpc/kernel/trace/Makefile +5 -0
@@ -11,6 +11,11 @@ endif obj32-$(CONFIG_FUNCTION_TRACER) += ftrace_32.o obj64-$(CONFIG_FUNCTION_TRACER) += ftrace_64.o +ifdef CONFIG_MPROFILE_KERNEL +obj64-$(CONFIG_FUNCTION_TRACER) += ftrace_64_mprofile.o +else +obj64-$(CONFIG_FUNCTION_TRACER) += ftrace_64_pg.o +endif obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
arch/powerpc/kernel/trace/ftrace_64.S +1 -307
329 lines not on this page · raw message
arch/powerpc/kernel/trace/ftrace_64_mprofile.S new file +274 -0
274 lines not on this page · raw message
arch/powerpc/kernel/trace/ftrace_64_pg.S new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.11.0
Steven Rostedt
maintainerRe: [PATCH v3 2/2] powerpc: ftrace_64: split further based on -mprofile-kernel
Quoted 4 lines · On Wed, 22 Feb 2017 00:31:02 +0530 "Naveen N. Rao"…
Split
ftrace_64.Sfurther retaining the core ftrace 64-bit aspects inftrace_64.Sand movingftrace_caller()andftrace_graph_caller()into separate files based on -mprofile-kernel. The livepatch routines are all now contained within the mprofile file.
Why? I would think that it may be possible to share code if they stay in the same file. I haven't had the chance to look deeply into the current code, but there may be ways to make macros and consolidate duplicate code like we did in x86.
-- Steve
Quoted 2 lines
Signed-off-by Naveen N. Rao <[email protected]>
Michael Ellerman
reviewerRe: [PATCH v3 2/2] powerpc: ftrace_64: split further based on -mprofile-kernel
Quoted 9 lines · Steven Rostedt
Quoted 4 lines · On Wed, 22 Feb 2017 00:31:02 +0530 "Naveen N. Rao"…
Split
ftrace_64.Sfurther retaining the core ftrace 64-bit aspects inftrace_64.Sand movingftrace_caller()andftrace_graph_caller()into separate files based on -mprofile-kernel. The livepatch routines are all now contained within the mprofile file.Why?
Because we have two ABIs that are basically entirely different.
Splitting them into separate files makes it easier to work on one or the other without getting muddled.
It also makes it clearer that the livepatch code only relates to the mprofile ABI for example.
Quoted 2 lines
I would think that it may be possible to share code if they stay in the same file.
We can share code even if they're in separate files. But I don't think there's much that can be shared TBH.
Quoted 3 lines
I haven't had the chance to look deeply into the current code, but there may be ways to make macros and consolidate duplicate code like we did in x86.
I'd obviously be happy to remove duplicate code, but as I said above there's not much that is obviously shared.
There's a few shared lines such as:
.globl ftrace_graph_call
ftrace_graph_call:
b ftrace_graph_stub
Which could go in a macro I guess, but it's almost not worth the trouble.
cheers