Skip to content

Commit 654ced4

Browse files
compudjrostedt
authored andcommitted
tracing: Introduce tracepoint_is_faultable()
Introduce a "faultable" flag within the extended structure to know whether a tracepoint needs rcu tasks trace grace period before reclaim. This can be queried using tracepoint_is_faultable(). Acked-by: Andrii Nakryiko <andrii@kernel.org> Tested-by: Jordan Rife <jrife@google.com> Cc: Michael Jeanson <mjeanson@efficios.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Yonghong Song <yhs@fb.com> Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: bpf@vger.kernel.org Cc: Joel Fernandes <joel@joelfernandes.org> Cc: Jordan Rife <jrife@google.com> Cc: linux-trace-kernel@vger.kernel.org Link: https://lore.kernel.org/20241031152056.744137-3-mathieu.desnoyers@efficios.com Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent a9cfb87 commit 654ced4

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

include/linux/tracepoint-defs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ struct tracepoint_func {
3232
struct tracepoint_ext {
3333
int (*regfunc)(void);
3434
void (*unregfunc)(void);
35+
/* Flags. */
36+
unsigned int faultable:1;
3537
};
3638

3739
struct tracepoint {

include/linux/tracepoint.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,30 @@ void for_each_tracepoint_in_module(struct module *mod,
104104
* tracepoint_synchronize_unregister must be called between the last tracepoint
105105
* probe unregistration and the end of module exit to make sure there is no
106106
* caller executing a probe when it is freed.
107+
*
108+
* An alternative is to use the following for batch reclaim associated
109+
* with a given tracepoint:
110+
*
111+
* - tracepoint_is_faultable() == false: call_rcu()
112+
* - tracepoint_is_faultable() == true: call_rcu_tasks_trace()
107113
*/
108114
#ifdef CONFIG_TRACEPOINTS
109115
static inline void tracepoint_synchronize_unregister(void)
110116
{
111117
synchronize_rcu_tasks_trace();
112118
synchronize_rcu();
113119
}
120+
static inline bool tracepoint_is_faultable(struct tracepoint *tp)
121+
{
122+
return tp->ext && tp->ext->faultable;
123+
}
114124
#else
115125
static inline void tracepoint_synchronize_unregister(void)
116126
{ }
127+
static inline bool tracepoint_is_faultable(struct tracepoint *tp)
128+
{
129+
return false;
130+
}
117131
#endif
118132

119133
#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
@@ -345,6 +359,15 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
345359
static struct tracepoint_ext __tracepoint_ext_##_name = { \
346360
.regfunc = _reg, \
347361
.unregfunc = _unreg, \
362+
.faultable = false, \
363+
}; \
364+
__DEFINE_TRACE_EXT(_name, &__tracepoint_ext_##_name, PARAMS(_proto), PARAMS(_args));
365+
366+
#define DEFINE_TRACE_SYSCALL(_name, _reg, _unreg, _proto, _args) \
367+
static struct tracepoint_ext __tracepoint_ext_##_name = { \
368+
.regfunc = _reg, \
369+
.unregfunc = _unreg, \
370+
.faultable = true, \
348371
}; \
349372
__DEFINE_TRACE_EXT(_name, &__tracepoint_ext_##_name, PARAMS(_proto), PARAMS(_args));
350373

@@ -389,6 +412,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
389412
#define __DECLARE_TRACE_SYSCALL __DECLARE_TRACE
390413

391414
#define DEFINE_TRACE_FN(name, reg, unreg, proto, args)
415+
#define DEFINE_TRACE_SYSCALL(name, reg, unreg, proto, args)
392416
#define DEFINE_TRACE(name, proto, args)
393417
#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
394418
#define EXPORT_TRACEPOINT_SYMBOL(name)

include/trace/define_trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
#undef TRACE_EVENT_SYSCALL
5050
#define TRACE_EVENT_SYSCALL(name, proto, args, struct, assign, print, reg, unreg) \
51-
DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args))
51+
DEFINE_TRACE_SYSCALL(name, reg, unreg, PARAMS(proto), PARAMS(args))
5252

5353
#undef TRACE_EVENT_NOP
5454
#define TRACE_EVENT_NOP(name, proto, args, struct, assign, print)

0 commit comments

Comments
 (0)