Skip to content

Commit 06afb0f

Browse files
committed
Merge tag 'trace-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing updates from Steven Rostedt: - Addition of faultable tracepoints There's a tracepoint attached to both a system call entry and exit. This location is known to allow page faults. The tracepoints are called under an rcu_read_lock() which does not allow faults that can sleep. This limits the ability of tracepoint handlers to page fault in user space system call parameters. Now these tracepoints have been made "faultable", allowing the callbacks to fault in user space parameters and record them. Note, only the infrastructure has been implemented. The consumers (perf, ftrace, BPF) now need to have their code modified to allow faults. - Fix up of BPF code for the tracepoint faultable logic - Update tracepoints to use the new static branch API - Remove trace_*_rcuidle() variants and the SRCU protection they used - Remove unused TRACE_EVENT_FL_FILTERED logic - Replace strncpy() with strscpy() and memcpy() - Use replace per_cpu_ptr(smp_processor_id()) with this_cpu_ptr() - Fix perf events to not duplicate samples when tracing is enabled - Replace atomic64_add_return(1, counter) with atomic64_inc_return(counter) - Make stack trace buffer 4K instead of PAGE_SIZE - Remove TRACE_FLAG_IRQS_NOSUPPORT flag as it was never used - Get the true return address for function tracer when function graph tracer is also running. When function_graph trace is running along with function tracer, the parent function of the function tracer sometimes is "return_to_handler", which is the function graph trampoline to record the exit of the function. Use existing logic that calls into the fgraph infrastructure to find the real return address. - Remove (un)regfunc pointers out of tracepoint structure - Added last minute bug fix for setting pending modules in stack function filter. echo "write*:mod:ext3" > /sys/kernel/tracing/stack_trace_filter Would cause a kernel NULL dereference. - Minor clean ups * tag 'trace-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (31 commits) ftrace: Fix regression with module command in stack_trace_filter tracing: Fix function name for trampoline ftrace: Get the true parent ip for function tracer tracing: Remove redundant check on field->field in histograms bpf: ensure RCU Tasks Trace GP for sleepable raw tracepoint BPF links bpf: decouple BPF link/attach hook and BPF program sleepable semantics bpf: put bpf_link's program when link is safe to be deallocated tracing: Replace strncpy() with strscpy() when copying comm tracing: Add might_fault() check in __DECLARE_TRACE_SYSCALL tracing: Fix syscall tracepoint use-after-free tracing: Introduce tracepoint_is_faultable() tracing: Introduce tracepoint extended structure tracing: Remove TRACE_FLAG_IRQS_NOSUPPORT tracing: Replace multiple deprecated strncpy with memcpy tracing: Make percpu stack trace buffer invariant to PAGE_SIZE tracing: Use atomic64_inc_return() in trace_clock_counter() trace/trace_event_perf: remove duplicate samples on the first tracepoint event tracing/bpf: Add might_fault check to syscall probes tracing/perf: Add might_fault check to syscall probes tracing/ftrace: Add might_fault check to syscall probes ...
2 parents 4b01712 + 45af52e commit 06afb0f

35 files changed

+452
-328
lines changed

Documentation/trace/ftrace.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,9 +1031,6 @@ explains which is which.
10311031
CPU#: The CPU which the process was running on.
10321032

10331033
irqs-off: 'd' interrupts are disabled. '.' otherwise.
1034-
.. caution:: If the architecture does not support a way to
1035-
read the irq flags variable, an 'X' will always
1036-
be printed here.
10371034

10381035
need-resched:
10391036
- 'N' both TIF_NEED_RESCHED and PREEMPT_NEED_RESCHED is set,

include/linux/bpf.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,11 @@ struct bpf_link {
16451645
enum bpf_link_type type;
16461646
const struct bpf_link_ops *ops;
16471647
struct bpf_prog *prog;
1648+
/* whether BPF link itself has "sleepable" semantics, which can differ
1649+
* from underlying BPF program having a "sleepable" semantics, as BPF
1650+
* link's semantics is determined by target attach hook
1651+
*/
1652+
bool sleepable;
16481653
/* rcu is used before freeing, work can be used to schedule that
16491654
* RCU-based freeing before that, so they never overlap
16501655
*/
@@ -1661,8 +1666,10 @@ struct bpf_link_ops {
16611666
*/
16621667
void (*dealloc)(struct bpf_link *link);
16631668
/* deallocate link resources callback, called after RCU grace period;
1664-
* if underlying BPF program is sleepable we go through tasks trace
1665-
* RCU GP and then "classic" RCU GP
1669+
* if either the underlying BPF program is sleepable or BPF link's
1670+
* target hook is sleepable, we'll go through tasks trace RCU GP and
1671+
* then "classic" RCU GP; this need for chaining tasks trace and
1672+
* classic RCU GPs is designated by setting bpf_link->sleepable flag
16661673
*/
16671674
void (*dealloc_deferred)(struct bpf_link *link);
16681675
int (*detach)(struct bpf_link *link);
@@ -2409,6 +2416,9 @@ int bpf_prog_new_fd(struct bpf_prog *prog);
24092416

24102417
void bpf_link_init(struct bpf_link *link, enum bpf_link_type type,
24112418
const struct bpf_link_ops *ops, struct bpf_prog *prog);
2419+
void bpf_link_init_sleepable(struct bpf_link *link, enum bpf_link_type type,
2420+
const struct bpf_link_ops *ops, struct bpf_prog *prog,
2421+
bool sleepable);
24122422
int bpf_link_prime(struct bpf_link *link, struct bpf_link_primer *primer);
24132423
int bpf_link_settle(struct bpf_link_primer *primer);
24142424
void bpf_link_cleanup(struct bpf_link_primer *primer);
@@ -2764,6 +2774,12 @@ static inline void bpf_link_init(struct bpf_link *link, enum bpf_link_type type,
27642774
{
27652775
}
27662776

2777+
static inline void bpf_link_init_sleepable(struct bpf_link *link, enum bpf_link_type type,
2778+
const struct bpf_link_ops *ops, struct bpf_prog *prog,
2779+
bool sleepable)
2780+
{
2781+
}
2782+
27672783
static inline int bpf_link_prime(struct bpf_link *link,
27682784
struct bpf_link_primer *primer)
27692785
{

include/linux/trace_events.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status);
184184

185185
enum trace_flag_type {
186186
TRACE_FLAG_IRQS_OFF = 0x01,
187-
TRACE_FLAG_IRQS_NOSUPPORT = 0x02,
188187
TRACE_FLAG_NEED_RESCHED = 0x04,
189188
TRACE_FLAG_HARDIRQ = 0x08,
190189
TRACE_FLAG_SOFTIRQ = 0x10,
@@ -193,7 +192,6 @@ enum trace_flag_type {
193192
TRACE_FLAG_BH_OFF = 0x80,
194193
};
195194

196-
#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
197195
static inline unsigned int tracing_gen_ctx_flags(unsigned long irqflags)
198196
{
199197
unsigned int irq_status = irqs_disabled_flags(irqflags) ?
@@ -207,17 +205,6 @@ static inline unsigned int tracing_gen_ctx(void)
207205
local_save_flags(irqflags);
208206
return tracing_gen_ctx_flags(irqflags);
209207
}
210-
#else
211-
212-
static inline unsigned int tracing_gen_ctx_flags(unsigned long irqflags)
213-
{
214-
return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
215-
}
216-
static inline unsigned int tracing_gen_ctx(void)
217-
{
218-
return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
219-
}
220-
#endif
221208

222209
static inline unsigned int tracing_gen_ctx_dec(void)
223210
{
@@ -326,7 +313,6 @@ void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer,
326313
void trace_event_buffer_commit(struct trace_event_buffer *fbuffer);
327314

328315
enum {
329-
TRACE_EVENT_FL_FILTERED_BIT,
330316
TRACE_EVENT_FL_CAP_ANY_BIT,
331317
TRACE_EVENT_FL_NO_SET_FILTER_BIT,
332318
TRACE_EVENT_FL_IGNORE_ENABLE_BIT,
@@ -341,7 +327,6 @@ enum {
341327

342328
/*
343329
* Event flags:
344-
* FILTERED - The event has a filter attached
345330
* CAP_ANY - Any user can enable for perf
346331
* NO_SET_FILTER - Set when filter has error and is to be ignored
347332
* IGNORE_ENABLE - For trace internal events, do not enable with debugfs file
@@ -356,7 +341,6 @@ enum {
356341
* to a tracepoint yet, then it is cleared when it is.
357342
*/
358343
enum {
359-
TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT),
360344
TRACE_EVENT_FL_CAP_ANY = (1 << TRACE_EVENT_FL_CAP_ANY_BIT),
361345
TRACE_EVENT_FL_NO_SET_FILTER = (1 << TRACE_EVENT_FL_NO_SET_FILTER_BIT),
362346
TRACE_EVENT_FL_IGNORE_ENABLE = (1 << TRACE_EVENT_FL_IGNORE_ENABLE_BIT),
@@ -381,7 +365,6 @@ struct trace_event_call {
381365
};
382366
struct trace_event event;
383367
char *print_fmt;
384-
struct event_filter *filter;
385368
/*
386369
* Static events can disappear with modules,
387370
* where as dynamic ones need their own ref count.

include/linux/tracepoint-defs.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,22 @@ struct tracepoint_func {
2929
int prio;
3030
};
3131

32+
struct tracepoint_ext {
33+
int (*regfunc)(void);
34+
void (*unregfunc)(void);
35+
/* Flags. */
36+
unsigned int faultable:1;
37+
};
38+
3239
struct tracepoint {
3340
const char *name; /* Tracepoint name */
34-
struct static_key key;
41+
struct static_key_false key;
3542
struct static_call_key *static_call_key;
3643
void *static_call_tramp;
3744
void *iterator;
3845
void *probestub;
39-
int (*regfunc)(void);
40-
void (*unregfunc)(void);
4146
struct tracepoint_func __rcu *funcs;
47+
struct tracepoint_ext *ext;
4248
};
4349

4450
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
@@ -83,7 +89,7 @@ struct bpf_raw_event_map {
8389

8490
#ifdef CONFIG_TRACEPOINTS
8591
# define tracepoint_enabled(tp) \
86-
static_key_false(&(__tracepoint_##tp).key)
92+
static_branch_unlikely(&(__tracepoint_##tp).key)
8793
#else
8894
# define tracepoint_enabled(tracepoint) false
8995
#endif

0 commit comments

Comments
 (0)