[PATCH v2] MAINTAINERS: Enlarge coverage of TRACING inside architectures

2022-03-24 Thread Christophe Leroy
Most architectures have ftrace related stuff in arch/*/kernel/ftrace.c but powerpc has it spread in multiple files located in arch/powerpc/kernel/trace/ In several architectures, there are also additional files containing 'ftrace' as part of the name but with some prefix or suffix. Use wildcards t

Re: [PATCH 1/2] powerpc: Reject probes on instructions that can't be single stepped

2022-03-24 Thread Michael Ellerman
Murilo Opsfelder Araújo writes: > On 3/23/22 08:51, Naveen N. Rao wrote: ... >> +case 31: >> +switch ((inst >> 1) & 0x3ff) { >> +case 4: /* tw */ >> +return false; >> +case 68:/* td */ >> +return false;

Re: [PATCH v1] ftrace: Make ftrace_graph_is_dead() static inline

2022-03-24 Thread Steven Rostedt
On Thu, 24 Mar 2022 11:01:45 +0100 Christophe Leroy wrote: > @@ -1006,7 +1006,20 @@ unsigned long ftrace_graph_ret_addr(struct task_struct > *task, int *idx, > extern int register_ftrace_graph(struct fgraph_ops *ops); > extern void unregister_ftrace_graph(struct fgraph_ops *ops); > > -extern

Re: [PATCH] MAINTAINERS: Add arch/powerpc/kernel/trace to TRACING

2022-03-24 Thread Steven Rostedt
On Thu, 24 Mar 2022 15:38:28 +0100 Christophe Leroy wrote: > diff --git a/MAINTAINERS b/MAINTAINERS > index e127c2fb08a7..3b5943f34568 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -19592,6 +19592,7 @@ T:git > git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git > F:

Re: [PATCH 2/2] powerpc/eeh: Use pcie_reset_state_t type in function arguments

2022-03-24 Thread Bjorn Helgaas
On Thu, Mar 10, 2022 at 09:51:13AM +0100, Christophe Leroy wrote: > Le 13/07/2021 à 02:25, Krzysztof Wilczyński a écrit : > > The pcie_reset_state_t type has been introduced in the commit > > f7bdd12d234d ("pci: New PCI-E reset API") along with the enum > > pcie_reset_state, but it has never been u

[PATCH] MAINTAINERS: Add arch/powerpc/kernel/trace to TRACING

2022-03-24 Thread Christophe Leroy
Most architectures have ftrace related stuff in arch/*/kernel/ftrace.c but powerpc has spread in multiple files located in arch/powerpc/kernel/trace/ Signed-off-by: Christophe Leroy --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index e127c2fb08a7..

[PATCH v1 02/22] powerpc/ftrace: Remove redundant create_branch() calls

2022-03-24 Thread Christophe Leroy
Since commit d5937db114e4 ("powerpc/code-patching: Fix patch_branch() return on out-of-range failure") patch_branch() fails with -ERANGE when trying to branch out of range. No need to perform the test twice. Remove redundant create_branch() calls. Signed-off-by: Christophe Leroy --- arch/powerp

[PATCH v1 07/22] powerpc/ftrace: Use patch_instruction() return directly

2022-03-24 Thread Christophe Leroy
Instead of returning -EPERM when patch_instruction() fails, just return what patch_instruction returns. That simplifies ftrace_modify_code(): 0: 94 21 ff c0 stwur1,-64(r1) 4: 93 e1 00 3c stw r31,60(r1) 8: 7c 7f 1b 79 mr. r31,r3

[PATCH v1 08/22] powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64

2022-03-24 Thread Christophe Leroy
Since c93d4f6ecf4b ("powerpc/ftrace: Add module_trampoline_target() for PPC32"), __ftrace_make_nop() for PPC32 is very similar to the one for PPC64. Same for __ftrace_make_call(). Make them common. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 108 +++

[PATCH v1 19/22] powerpc/inst: Remove PPC_INST_BRANCH

2022-03-24 Thread Christophe Leroy
Convert last users of PPC_INST_BRANCH to PPC_RAW_BRANCH() And remove PPC_INST_BRANCH. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/ppc-opcode.h | 3 +-- arch/powerpc/lib/feature-fixups.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/incl

[PATCH v1 00/22] powerpc: ftrace optimisation and cleanup and more [v1]

2022-03-24 Thread Christophe Leroy
This series provides optimisation and cleanup of ftrace on powerpc. With this series ftrace activation is about 20% faster on an 8xx. At the end of the series come additional cleanups around ppc-opcode, that would likely conflict with this series if posted separately. Christophe Leroy (22): po

[PATCH v1 20/22] powerpc/modules: Use PPC_INST_BRANCH_MASK instead of opencoding

2022-03-24 Thread Christophe Leroy
Use PPC_INST_BRANCH_MASK instead of opencoding. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/module_32.c | 13 ++--- arch/powerpc/kernel/module_64.c | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/

[PATCH v1 15/22] powerpc/ftrace: Simplify expected_nop_sequence()

2022-03-24 Thread Christophe Leroy
Avoid ifdefs around expected_nop_sequence(). While at it make it a bool. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 22 ++ 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/t

[PATCH v1 05/22] powerpc/code-patching: Inline create_branch()

2022-03-24 Thread Christophe Leroy
create_branch() is a good candidate for inlining because: - Flags can be folded in. - Range tests are likely to be already done. Hence reducing the create_branch() to only a set of instructions. So inline it. It improves ftrace activation by 10%. Signed-off-by: Christophe Leroy --- arch/power

[PATCH v1 04/22] powerpc/ftrace: Use is_offset_in_branch_range()

2022-03-24 Thread Christophe Leroy
Use is_offset_in_branch_range() instead of create_branch() to check if a target is within branch range. This patch together with the previous one improves ftrace activation time by 7% Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 8 ++-- 1 file changed, 2 insertio

[PATCH v1 22/22] powerpc/opcodes: Remove unused PPC_INST_XXX macros

2022-03-24 Thread Christophe Leroy
The following PPC_INST_XXX macros are not used anymore outside ppc-opcode.h: - PPC_INST_LD - PPC_INST_STD - PPC_INST_ADDIS - PPC_INST_ADD - PPC_INST_DIVD Remove them. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/ppc-opcode.h | 13 -

[PATCH v1 17/22] powerpc/inst: Add __copy_inst_from_kernel_nofault()

2022-03-24 Thread Christophe Leroy
On the same model as get_user() versus __get_user(), introduce __copy_inst_from_kernel_nofault() which doesn't check address. To be used by callers that have already checked that the adress is a kernel address. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/inst.h | 13 +--

[PATCH v1 12/22] powerpc/ftrace: Use BRANCH_SET_LINK instead of value 1

2022-03-24 Thread Christophe Leroy
To make it explicit, use BRANCH_SET_LINK instead of value 1 when calling create_branch(). Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftr

[PATCH v1 06/22] powerpc/ftrace: Inline ftrace_modify_code()

2022-03-24 Thread Christophe Leroy
Inlining ftrace_modify_code(), it increases a bit the size of ftrace code but brings 5% improvment on ftrace activation. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/trace/ftrace.c

[PATCH v1 01/22] powerpc/ftrace: Refactor prepare_ftrace_return()

2022-03-24 Thread Christophe Leroy
When we have CONFIG_DYNAMIC_FTRACE_WITH_ARGS, prepare_ftrace_return() is called by ftrace_graph_func() otherwise prepare_ftrace_return() is called from assembly. Refactor prepare_ftrace_return() into a static __prepare_ftrace_return() that will be called by both prepare_ftrace_return() and ftrace_

[PATCH v1 21/22] powerpc/inst: Remove PPC_INST_BL

2022-03-24 Thread Christophe Leroy
Convert last users of PPC_INST_BL to PPC_RAW_BL() And remove PPC_INST_BL. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/ppc-opcode.h | 1 - arch/powerpc/net/bpf_jit.h| 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/ppc-opc

[PATCH v1 13/22] powerpc/ftrace: Use PPC_RAW_xxx() macros instead of opencoding.

2022-03-24 Thread Christophe Leroy
PPC_RAW_xxx() macros are self explanatory and less error prone than open coding. Use them in ftrace.c Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/ppc-opcode.h | 3 +++ arch/powerpc/kernel/trace/ftrace.c| 32 +-- 2 files changed, 14 insertions(+), 21

[PATCH v1 16/22] powerpc/ftrace: Minimise number of #ifdefs

2022-03-24 Thread Christophe Leroy
A lot of #ifdefs can be replaced by IS_ENABLED() Do so. This requires to have kernel_toc_addr() defined at all time and PPC_INST_LD_TOC as well. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/code-patching.h | 2 - arch/powerpc/include/asm/module.h| 2 - arch/powerpc/

[PATCH v1 09/22] powerpc/ftrace: Don't include ftrace.o for CONFIG_FTRACE_SYSCALLS

2022-03-24 Thread Christophe Leroy
Since commit 7bea7ac0ca01 ("powerpc/syscalls: Fix syscall tracing") ftrace.o is not needed anymore for CONFIG_FTRACE_SYSCALLS. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/kernel/trace/Makefile b/arch/powe

[PATCH v1 10/22] powerpc/ftrace: Use CONFIG_FUNCTION_TRACER instead of CONFIG_DYNAMIC_FTRACE

2022-03-24 Thread Christophe Leroy
Since commit 0c0c52306f47 ("powerpc: Only support DYNAMIC_FTRACE not static"), CONFIG_DYNAMIC_FTRACE is always selected when CONFIG_FUNCTION_TRACER is selected. To avoid confusion and have the reader wonder what's happen when CONFIG_FUNCTION_TRACER is selected and CONFIG_DYNAMIC_FTRACE is not, use

[PATCH v1 03/22] powerpc/code-patching: Inline is_offset_in_{cond}_branch_range()

2022-03-24 Thread Christophe Leroy
Test in is_offset_in_branch_range() and is_offset_in_cond_branch_range() are simple tests that are worth inlining. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/code-patching.h | 29 ++-- arch/powerpc/lib/code-patching.c | 27 -- 2 f

[PATCH v1 11/22] powerpc/ftrace: Remove ftrace_plt_tramps[]

2022-03-24 Thread Christophe Leroy
ftrace_plt_tramps table is never filled so it is useless. Remove it. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 8 1 file changed, 8 deletions(-) diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index 188f59f4ee4a..b6c

[PATCH v1 18/22] powerpc/ftrace: Don't use copy_from_kernel_nofault() in module_trampoline_target()

2022-03-24 Thread Christophe Leroy
module_trampoline_target() is quite a hot path used when activating/deactivating function tracer. Avoid the heavy copy_from_kernel_nofault() by doing four calls to copy_inst_from_kernel_nofault(). Use __copy_inst_from_kernel_nofault() for the 3 last calls. First call is done to copy_from_kernel_n

[PATCH v1 14/22] powerpc/ftrace: Use size macro instead of opencoding

2022-03-24 Thread Christophe Leroy
0x8000 is SZ_2G. Use it. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index afb1d12838c9..15e0746806f8 100644 --- a/arch/powe

Re: [PATCH 1/2] powerpc: Reject probes on instructions that can't be single stepped

2022-03-24 Thread Murilo Opsfelder Araújo
Hi, Naveen. Some comments below. On 3/23/22 08:51, Naveen N. Rao wrote: Per the ISA, a Trace interrupt is not generated for: - [h|u]rfi[d] - rfscv - sc, scv, and Trap instructions that trap - Power-Saving Mode instructions - other instructions that cause interrupts (other than Trace interrupts)

[PATCH v1] ftrace: Make ftrace_graph_is_dead() static inline

2022-03-24 Thread Christophe Leroy
ftrace_graph_is_dead() is used on hot paths, it just reads a variable in memory and is not worth suffering function call constraints. For instance, at entry of prepare_ftrace_return(), inlining it avoids saving prepare_ftrace_return() parameters to stack and restoring them after calling ftrace_gra

[powerpc/merge] Possible stack corruption while running selftests

2022-03-24 Thread Sachin Sant
I am seeing random crashes(at least to me) with powerpc/selftests on P10 LPAR running powerpc/merge branch code. mitigation-patching.sh test was running in both the instances. In the latest instance it seems like a possible stack corruption ?? [ 711.005150] count-cache-flush: hardware flush ena