tracing: Last minute updates for v6.13
Subsystems (5)
Steven Rostedt
maintainercover tracing: Last minute updates for v6.13
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/for-next
Head SHA1: ef0d4186083127d2f99ed04e051fd94ba061d253
Mathieu Desnoyers (5):
tracing: Move it_func[0] comment to the relevant context
tracing: Remove __idx variable from __DO_TRACE
rcupdate_trace: Define rcu_tasks_trace lock guard
tracing: Remove conditional locking from __DO_TRACE()
tracing: Remove cond argument from __DECLARE_TRACE_SYSCALL
Thomas Gleixner (1):
tracing: Record task flag NEED_RESCHED_LAZY.
----
Documentation/trace/ftrace.rst | 4 +++ include/linux/rcupdate_trace.h | 5 +++ include/linux/trace_events.h | 1 + include/linux/tracepoint.h | 70 +++++++++++++++--------------------------- kernel/trace/trace.c | 2 ++ kernel/trace/trace_output.c | 14 ++++++++- 6 files changed, 49 insertions(+), 47 deletions(-)
Steven Rostedt
maintainerPATCH 1/6 tracing: Record task flag NEED_RESCHED_LAZY.
From: Thomas Gleixner <[email protected]>
The scheduler added NEED_RESCHED_LAZY scheduling. Record this state as part of trace flags and expose it in the need_resched field.
Record and expose NEED_RESCHED_LAZY.
[bigeasy: Commit description, documentation bits.]
--- Documentation/trace/ftrace.rst | 4 ++++ include/linux/trace_events.h | 1 + kernel/trace/trace.c | 2 ++ kernel/trace/trace_output.c | 14 +++++++++++++- 4 files changed, 20 insertions(+), 1 deletion(-)
Documentation/trace/ftrace.rst +4 -0
@@ -1033,9 +1033,13 @@ explains which is which. irqs-off: 'd' interrupts are disabled. '.' otherwise. need-resched: + - 'B' all, TIF_NEED_RESCHED, PREEMPT_NEED_RESCHED and TIF_RESCHED_LAZY is set, - 'N' both TIF_NEED_RESCHED and PREEMPT_NEED_RESCHED is set, - 'n' only TIF_NEED_RESCHED is set, - 'p' only PREEMPT_NEED_RESCHED is set, + - 'L' both PREEMPT_NEED_RESCHED and TIF_RESCHED_LAZY is set, + - 'b' both TIF_NEED_RESCHED and TIF_RESCHED_LAZY is set, + - 'l' only TIF_RESCHED_LAZY is set - '.' otherwise. hardirq/softirq:
include/linux/trace_events.h +1 -0
@@ -184,6 +184,7 @@ unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status);enum trace_flag_type {TRACE_FLAG_IRQS_OFF =0x01 , +TRACE_FLAG_NEED_RESCHED_LAZY =0x02 ,TRACE_FLAG_NEED_RESCHED =0x04 ,TRACE_FLAG_HARDIRQ =0x08 ,TRACE_FLAG_SOFTIRQ =0x10 ,
kernel/trace/trace.c +2 -0
@@ -2552,6 +2552,8 @@ unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status) trace_flags |=TRACE_FLAG_NEED_RESCHED ;if (test_preempt_need_resched ()) trace_flags |=TRACE_FLAG_PREEMPT_RESCHED ; +if (IS_ENABLED (CONFIG_ARCH_HAS_PREEMPT_LAZY ) &&tif_test_bit (TIF_NEED_RESCHED_LAZY )) + trace_flags |=TRACE_FLAG_NEED_RESCHED_LAZY ; return (trace_flags << 16) | (min_t(unsigned int, pc & 0xff, 0xf)) | (min_t(unsigned int, migration_disable_value(), 0xf)) << 4; }
kernel/trace/trace_output.c +13 -1
@@ -462,17 +462,29 @@ int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry) bh_off ?'b' :'.' ; -switch (entry->flags & (TRACE_FLAG_NEED_RESCHED | +switch (entry->flags & (TRACE_FLAG_NEED_RESCHED |TRACE_FLAG_NEED_RESCHED_LAZY |TRACE_FLAG_PREEMPT_RESCHED )) { +case TRACE_FLAG_NEED_RESCHED |TRACE_FLAG_NEED_RESCHED_LAZY |TRACE_FLAG_PREEMPT_RESCHED : + need_resched ='B' ; +break ;case TRACE_FLAG_NEED_RESCHED |TRACE_FLAG_PREEMPT_RESCHED : need_resched ='N' ;break ; +case TRACE_FLAG_NEED_RESCHED_LAZY |TRACE_FLAG_PREEMPT_RESCHED : + need_resched ='L' ; +break ; +case TRACE_FLAG_NEED_RESCHED |TRACE_FLAG_NEED_RESCHED_LAZY : + need_resched ='b' ; +break ;case TRACE_FLAG_NEED_RESCHED : need_resched ='n' ;break ;case TRACE_FLAG_PREEMPT_RESCHED : need_resched ='p' ;break ; +case TRACE_FLAG_NEED_RESCHED_LAZY : + need_resched ='l' ; +break ;default : need_resched ='.' ;break ;
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 2/6 tracing: Move it_func[0] comment to the relevant context
In reply to Steven RostedtFrom: Mathieu Desnoyers <[email protected]>
When introducing __DO_TRACE_CALL(), the iteration over it_func moved from __DO_TRACE() to __tracepoint_iter_##_name(), but the comment relevant for this iterator was left in its original location.
Move the comment to the relevant context.
--- include/linux/tracepoint.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/tracepoint.h +3 -3
@@ -210,9 +210,6 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)#endif /* CONFIG_HAVE_STATIC_CALL */ /* -* it_func[0] is never NULL because there is at least one element in the array -* when the array itself is non NULL. -* * With @syscall=0, the tracepoint callback array dereference is * protected by disabling preemption. * With @syscall=1, the tracepoint callback array dereference is
@@ -316,6 +313,9 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)* We have no guarantee that gcc and the linker won't up-align the tracepoint * structures, so we create an array of pointers that will be used for iteration * on the tracepoints. +* +* it_func[0] is never NULL because there is at least one element in the array +* when the array itself is non NULL. */ #define __DEFINE_TRACE_EXT (_name, _ext, proto, args) \ static const char __tpstrtab_##_name[] \
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 3/6 tracing: Remove __idx variable from __DO_TRACE
In reply to Steven RostedtFrom: Mathieu Desnoyers <[email protected]>
Since the removal of SRCU-protected tracepoints, the __idx variable in __DO_TRACE is unused. Remove this variable.
--- include/linux/tracepoint.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/tracepoint.h +0 -2
@@ -218,8 +218,6 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)*/ #define __DO_TRACE (name, args, cond, syscall) \ do { \ - int __maybe_unused __idx = 0; \ - \ if (!(cond)) \ return; \ \
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 4/6 rcupdate_trace: Define rcu_tasks_trace lock guard
In reply to Steven RostedtFrom: Mathieu Desnoyers <[email protected]>
Define a rcu_tasks_trace lock guard for use by the syscall enter/exit tracepoints.
--- include/linux/rcupdate_trace.h | 5 +++++ 1 file changed, 5 insertions(+)
include/linux/rcupdate_trace.h +5 -0
@@ -10,6 +10,7 @@#include <linux/sched.h> #include <linux/rcupdate.h> +#include <linux/cleanup.h> extern struct lockdep_map rcu_trace_lock_map;
@@ -98,4 +99,8 @@ static inline void rcu_read_lock_trace(void) { BUG(); }static inline void rcu_read_unlock_trace (void ) {BUG (); }#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */ +DEFINE_LOCK_GUARD_0 (rcu_tasks_trace, +rcu_read_lock_trace (), + rcu_read_unlock_trace()) +#endif /* __LINUX_RCUPDATE_TRACE_H */
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 5/6 tracing: Remove conditional locking from __DO_TRACE()
In reply to Steven RostedtFrom: Mathieu Desnoyers <[email protected]>
Remove conditional locking by moving the __DO_TRACE() code into trace_##name().
When the faultable syscall tracepoints were implemented, __DO_TRACE() had a rcuidle argument which selected between SRCU and preempt disable. Therefore, the RCU tasks trace protection for faultable syscall tracepoints was introduced using the same pattern.
At that point, it did not appear obvious that this feedback from Linus [1] applied here as well, because the __DO_TRACE() modification was extending a pre-existing pattern.
Shortly before pulling the faultable syscall tracepoints modifications, Steven removed the rcuidle argument and SRCU protection scheme entirely from tracepoint.h:
commit 48bcda684823 ("tracing: Remove definition of trace_*_rcuidle()")
This required a rebase of the faultable syscall tracepoints series, which missed a perfect opportunity to integrate the prior recommendation from Linus.
In response to the pull request, Linus pointed out [2] that he was not pleased by the implementation, expecting this to be fixed in a follow up patch series.
Move __DO_TRACE() code into trace_##name() within each of __DECLARE_TRACE() and __DECLARE_TRACE_SYSCALL(). Use a scoped guard to guard the preempt disable notrace and RCU tasks trace critical sections.
--- include/linux/tracepoint.h | 45 ++++++++++---------------------------- 1 file changed, 12 insertions(+), 33 deletions(-)
include/linux/tracepoint.h +12 -33
@@ -209,31 +209,6 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)#define __DO_TRACE_CALL (name, args) __traceiter_##name(NULL, args)#endif /* CONFIG_HAVE_STATIC_CALL */ -/* -* With @syscall=0, the tracepoint callback array dereference is -* protected by disabling preemption. -* With @syscall=1, the tracepoint callback array dereference is -* protected by Tasks Trace RCU, which allows probes to handle page -* faults. -*/ -#define __DO_TRACE (name, args, cond, syscall) \ - do { \ - if (!(cond)) \ - return; \ - \ - if (syscall) \ - rcu_read_lock_trace(); \ - else \ - preempt_disable_notrace(); \ - \ - __DO_TRACE_CALL(name, TP_ARGS(args)); \ - \ - if (syscall) \ - rcu_read_unlock_trace(); \ - else \ - preempt_enable_notrace(); \ - } while (0) -/* * Make sure the alignment of the structure in the __tracepoints section will * not add unwanted padding between the beginning of the section and the
@@ -282,10 +257,12 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), cond, PARAMS(data_proto)) \ static inline void trace_##name(proto) \ { \ - if (static_branch_unlikely(&__tracepoint_##name.key)) \ - __DO_TRACE(name, \ - TP_ARGS(args), \ - TP_CONDITION(cond), 0); \ + if (static_branch_unlikely(&__tracepoint_##name.key)) { \ + if (cond) { \ + scoped_guard(preempt_notrace) \ + __DO_TRACE_CALL(name, TP_ARGS(args)); \ + } \ + } \ if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ WARN_ONCE(!rcu_is_watching(), \ "RCU not watching for tracepoint"); \
@@ -297,10 +274,12 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) static inline void trace_##name(proto) \ { \ might_fault(); \ - if (static_branch_unlikely(&__tracepoint_##name.key)) \ - __DO_TRACE(name, \ - TP_ARGS(args), \ - TP_CONDITION(cond), 1); \ + if (static_branch_unlikely(&__tracepoint_##name.key)) { \ + if (cond) { \ + scoped_guard(rcu_tasks_trace) \ + __DO_TRACE_CALL(name, TP_ARGS(args)); \ + } \ + } \ if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ WARN_ONCE(!rcu_is_watching(), \ "RCU not watching for tracepoint"); \
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 6/6 tracing: Remove cond argument from __DECLARE_TRACE_SYSCALL
In reply to Steven RostedtFrom: Mathieu Desnoyers <[email protected]>
Syscall tracepoints do not require a "cond" argument, because they are meant to be used only for sys_enter and sys_exit instrumentation, which don't require condition evaluation.
--- include/linux/tracepoint.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
include/linux/tracepoint.h +13 -12
@@ -220,7 +220,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)* site if it is not watching, as it will need to be active when the * tracepoint is enabled. */ -#define __DECLARE_TRACE_COMMON (name, proto, args, cond, data_proto) \ +#define __DECLARE_TRACE_COMMON (name, proto, args, data_proto) \ extern int __traceiter_##name(data_proto); \ DECLARE_STATIC_CALL(tp_func_##name, __traceiter_##name); \ extern struct tracepoint __tracepoint_##name; \
@@ -254,7 +254,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) }#define __DECLARE_TRACE (name, proto, args, cond, data_proto) \ - __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), cond, PARAMS(data_proto)) \ + __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \ static inline void trace_##name(proto) \ { \ if (static_branch_unlikely(&__tracepoint_##name.key)) { \
@@ -269,18 +269,16 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) } \ } -#define __DECLARE_TRACE_SYSCALL (name, proto, args, cond, data_proto) \ - __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), cond, PARAMS(data_proto)) \ +#define __DECLARE_TRACE_SYSCALL (name, proto, args, data_proto) \ + __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \ static inline void trace_##name(proto) \ { \ might_fault(); \ if (static_branch_unlikely(&__tracepoint_##name.key)) { \ - if (cond) { \ - scoped_guard(rcu_tasks_trace) \ - __DO_TRACE_CALL(name, TP_ARGS(args)); \ - } \ + scoped_guard(rcu_tasks_trace) \ + __DO_TRACE_CALL(name, TP_ARGS(args)); \ } \ - if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ + if (IS_ENABLED(CONFIG_LOCKDEP)) { \ WARN_ONCE(!rcu_is_watching(), \ "RCU not watching for tracepoint"); \ } \
@@ -363,7 +361,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)#else /* !TRACEPOINTS_ENABLED */ -#define __DECLARE_TRACE (name, proto, args, cond, data_proto) \ +#define __DECLARE_TRACE_COMMON (name, proto, args, data_proto) \ static inline void trace_##name(proto) \ { } \ static inline int \
@@ -387,7 +385,11 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)return false; \ } -#define __DECLARE_TRACE_SYSCALL __DECLARE_TRACE +#define __DECLARE_TRACE (name, proto, args, cond, data_proto) \ + __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) + +#define __DECLARE_TRACE_SYSCALL (name, proto, args, data_proto) \ + __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto))#define DEFINE_TRACE_FN (name, reg, unreg, proto, args)#define DEFINE_TRACE_SYSCALL (name, reg, unreg, proto, args)
@@ -453,7 +455,6 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)#define DECLARE_TRACE_SYSCALL (name, proto, args) \ __DECLARE_TRACE_SYSCALL(name, PARAMS(proto), PARAMS(args), \ - cpu_online(raw_smp_processor_id()), \ PARAMS(void *__data, proto))#define TRACE_EVENT_FLAGS (event, flag)
Signature · 1 line
2.45.2
Re: [for-next][PATCH 4/6] rcupdate_trace: Define rcu_tasks_trace lock guard
In reply to Steven RostedtQuoted 18 lines · Steven Rostedt
From: Mathieu Desnoyers <[email protected]>
Define a
rcu_tasks_tracelock guard for use by the syscall enter/exit tracepoints.Cc Linus Torvalds <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Michael Jeanson <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Yonghong Song <[email protected]>Cc Paul E. McKenney <[email protected]>Cc Ingo Molnar <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Mark Rutland <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Namhyung Kim <[email protected]>
Quoted 8 lines
Cc Andrii Nakryiko <[email protected]>Cc Joel Fernandes <[email protected]>Cc Jordan Rife <[email protected]>Signed-off-by Mathieu Desnoyers <[email protected]>Signed-off-by Steven Rostedt (Google) <[email protected]>
Quoted 29 lines
--- include/linux/rcupdate_trace.h | 5 +++++ 1 file changed, 5 insertions(+)include/linux/rcupdate_trace.h +5
-0@@ -10,6 +10,7 @@#include <linux/sched.h> #include <linux/rcupdate.h> +#include <linux/cleanup.h> extern struct lockdep_map rcu_trace_lock_map;@@ -98,4 +99,8 @@ static inline void rcu_read_lock_trace(void) { BUG(); }static inline void rcu_read_unlock_trace (void ) {BUG (); }#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */ +DEFINE_LOCK_GUARD_0 (rcu_tasks_trace, +rcu_read_lock_trace (), + rcu_read_unlock_trace()) +#endif /* __LINUX_RCUPDATE_TRACE_H */ Signature · 1 line
2.45.2