* [PATCH 0/3] ftrace fixes for PA-RISC
@ 2021-10-19 18:31 Sven Schnelle
2021-10-19 18:31 ` [PATCH 1/3] parisc: don't use dereference_function_descriptor() in trace stub Sven Schnelle
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sven Schnelle @ 2021-10-19 18:31 UTC (permalink / raw)
To: Helge Deller; +Cc: linux-parisc
I tried to enable ftrace, but it didn't work. These are the required
fixes to make it work again.
Sven Schnelle (3):
parisc: don't use dereference_function_descriptor() in trace stub
parisc/ftrace: use static key to enable function graph
parisc: mark xchg functions notrace
arch/parisc/kernel/ftrace.c | 13 ++++++-------
arch/parisc/lib/bitops.c | 12 ++++++------
2 files changed, 12 insertions(+), 13 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] parisc: don't use dereference_function_descriptor() in trace stub
2021-10-19 18:31 [PATCH 0/3] ftrace fixes for PA-RISC Sven Schnelle
@ 2021-10-19 18:31 ` Sven Schnelle
2021-10-19 18:31 ` [PATCH 2/3] parisc/ftrace: use static key to enable function graph Sven Schnelle
2021-10-19 18:31 ` [PATCH 3/3] parisc: mark xchg functions notrace Sven Schnelle
2 siblings, 0 replies; 4+ messages in thread
From: Sven Schnelle @ 2021-10-19 18:31 UTC (permalink / raw)
To: Helge Deller; +Cc: linux-parisc
dereference_function_descriptor() calls get_kernel_nofault(),
which itself might call into tracing. This leads to a deadlock.
Instead of reverting back to casts to compare whether there's
a trace function set, just always call the appropriate trace function.
With dynamic ftrace this function shouldn't be called at all
when ftrace is disabled. It adds a function call for the non-dynamic
case, but people concerned about the costs of ftrace should use
dynamic ftrace anyways.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
arch/parisc/kernel/ftrace.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
index 0a1e75af5382..f5f467ebf94c 100644
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -58,10 +58,7 @@ void notrace __hot ftrace_function_trampoline(unsigned long parent,
#endif
extern struct ftrace_ops *function_trace_op;
- if (function_trace_op->flags & FTRACE_OPS_FL_ENABLED &&
- ftrace_trace_function != ftrace_stub)
- ftrace_trace_function(self_addr, parent,
- function_trace_op, fregs);
+ ftrace_trace_function(self_addr, parent, function_trace_op, fregs);
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
if (dereference_function_descriptor(ftrace_graph_return) !=
@@ -101,6 +98,7 @@ int __init ftrace_dyn_arch_init(void)
}
int ftrace_update_ftrace_func(ftrace_func_t func)
{
+ ftrace_trace_function = func;
return 0;
}
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] parisc/ftrace: use static key to enable function graph
2021-10-19 18:31 [PATCH 0/3] ftrace fixes for PA-RISC Sven Schnelle
2021-10-19 18:31 ` [PATCH 1/3] parisc: don't use dereference_function_descriptor() in trace stub Sven Schnelle
@ 2021-10-19 18:31 ` Sven Schnelle
2021-10-19 18:31 ` [PATCH 3/3] parisc: mark xchg functions notrace Sven Schnelle
2 siblings, 0 replies; 4+ messages in thread
From: Sven Schnelle @ 2021-10-19 18:31 UTC (permalink / raw)
To: Helge Deller; +Cc: linux-parisc
Instead of comparing function descriptors add a static branch
so the condition gets patched during runtime.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
arch/parisc/kernel/ftrace.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
index f5f467ebf94c..7a2de664242a 100644
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -23,6 +23,7 @@
#define __hot __section(".text.hot")
+static DEFINE_STATIC_KEY_FALSE(ftrace_graph_enabled);
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
/*
* Hook the return address and push it in the stack of return addrs
@@ -61,9 +62,7 @@ void notrace __hot ftrace_function_trampoline(unsigned long parent,
ftrace_trace_function(self_addr, parent, function_trace_op, fregs);
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
- if (dereference_function_descriptor(ftrace_graph_return) !=
- dereference_function_descriptor(ftrace_stub) ||
- ftrace_graph_entry != ftrace_graph_entry_stub) {
+ if (static_branch_unlikely(&ftrace_graph_enabled)) {
unsigned long *parent_rp;
/* calculate pointer to %rp in stack */
@@ -81,11 +80,13 @@ void notrace __hot ftrace_function_trampoline(unsigned long parent,
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
int ftrace_enable_ftrace_graph_caller(void)
{
+ static_key_enable(&ftrace_graph_enabled.key);
return 0;
}
int ftrace_disable_ftrace_graph_caller(void)
{
+ static_key_disable(&ftrace_graph_enabled.key);
return 0;
}
#endif
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] parisc: mark xchg functions notrace
2021-10-19 18:31 [PATCH 0/3] ftrace fixes for PA-RISC Sven Schnelle
2021-10-19 18:31 ` [PATCH 1/3] parisc: don't use dereference_function_descriptor() in trace stub Sven Schnelle
2021-10-19 18:31 ` [PATCH 2/3] parisc/ftrace: use static key to enable function graph Sven Schnelle
@ 2021-10-19 18:31 ` Sven Schnelle
2 siblings, 0 replies; 4+ messages in thread
From: Sven Schnelle @ 2021-10-19 18:31 UTC (permalink / raw)
To: Helge Deller; +Cc: linux-parisc
tracing the xchg functions leads to recursion in various
places. Therefore mark the function as notrace.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
arch/parisc/lib/bitops.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/parisc/lib/bitops.c b/arch/parisc/lib/bitops.c
index 9ac683bf6ae7..36a314199074 100644
--- a/arch/parisc/lib/bitops.c
+++ b/arch/parisc/lib/bitops.c
@@ -18,7 +18,7 @@ arch_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned = {
#endif
#ifdef CONFIG_64BIT
-unsigned long __xchg64(unsigned long x, volatile unsigned long *ptr)
+unsigned long notrace __xchg64(unsigned long x, volatile unsigned long *ptr)
{
unsigned long temp, flags;
@@ -30,7 +30,7 @@ unsigned long __xchg64(unsigned long x, volatile unsigned long *ptr)
}
#endif
-unsigned long __xchg32(int x, volatile int *ptr)
+unsigned long notrace __xchg32(int x, volatile int *ptr)
{
unsigned long flags;
long temp;
@@ -43,7 +43,7 @@ unsigned long __xchg32(int x, volatile int *ptr)
}
-unsigned long __xchg8(char x, volatile char *ptr)
+unsigned long notrace __xchg8(char x, volatile char *ptr)
{
unsigned long flags;
long temp;
@@ -56,7 +56,7 @@ unsigned long __xchg8(char x, volatile char *ptr)
}
-u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new)
+u64 notrace __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new)
{
unsigned long flags;
u64 prev;
@@ -68,7 +68,7 @@ u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new)
return prev;
}
-unsigned long __cmpxchg_u32(volatile unsigned int *ptr, unsigned int old, unsigned int new)
+unsigned long notrace __cmpxchg_u32(volatile unsigned int *ptr, unsigned int old, unsigned int new)
{
unsigned long flags;
unsigned int prev;
@@ -80,7 +80,7 @@ unsigned long __cmpxchg_u32(volatile unsigned int *ptr, unsigned int old, unsign
return (unsigned long)prev;
}
-u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new)
+u8 notrace __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new)
{
unsigned long flags;
u8 prev;
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-19 19:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-19 18:31 [PATCH 0/3] ftrace fixes for PA-RISC Sven Schnelle
2021-10-19 18:31 ` [PATCH 1/3] parisc: don't use dereference_function_descriptor() in trace stub Sven Schnelle
2021-10-19 18:31 ` [PATCH 2/3] parisc/ftrace: use static key to enable function graph Sven Schnelle
2021-10-19 18:31 ` [PATCH 3/3] parisc: mark xchg functions notrace Sven Schnelle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.