Skip to content

Commit 70a6632

Browse files
committed
Merge tag 'probes-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull probes updates from Masami Hiramatsu: - tracing/probes: Add new pseudo-types %pd and %pD support for dumping dentry name from 'struct dentry *' and file name from 'struct file *' - uprobes performance optimizations: - Speed up the BPF uprobe event by delaying the fetching of the uprobe event arguments that are not used in BPF - Avoid locking by speculatively checking whether uprobe event is valid - Reduce lock contention by using read/write_lock instead of spinlock for uprobe list operation. This improved BPF uprobe benchmark result 43% on average - rethook: Remove non-fatal warning messages when tracing stack from BPF and skip rcu_is_watching() validation in rethook if possible - objpool: Optimize objpool (which is used by kretprobes and fprobe as rethook backend storage) by inlining functions and avoid caching nr_cpu_ids because it is a const value - fprobe: Add entry/exit callbacks types (code cleanup) - kprobes: Check ftrace was killed in kprobes if it uses ftrace * tag 'probes-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: kprobe/ftrace: bail out if ftrace was killed selftests/ftrace: Fix required features for VFS type test case objpool: cache nr_possible_cpus() and avoid caching nr_cpu_ids objpool: enable inlining objpool_push() and objpool_pop() operations rethook: honor CONFIG_FTRACE_VALIDATE_RCU_IS_WATCHING in rethook_try_get() ftrace: make extra rcu_is_watching() validation check optional uprobes: reduce contention on uprobes_tree access rethook: Remove warning messages printed for finding return address of a frame. fprobe: Add entry/exit callbacks types selftests/ftrace: add fprobe test cases for VFS type "%pd" and "%pD" selftests/ftrace: add kprobe test cases for VFS type "%pd" and "%pD" Documentation: tracing: add new type '%pd' and '%pD' for kprobe tracing/probes: support '%pD' type for print struct file's name tracing/probes: support '%pd' type for print struct dentry's name uprobes: add speculative lockless system-wide uprobe filter check uprobes: prepare uprobe args buffer lazily uprobes: encapsulate preparation of uprobe args buffer
2 parents e9d6825 + 1a7d089 commit 70a6632

File tree

26 files changed

+406
-176
lines changed

26 files changed

+406
-176
lines changed

Documentation/trace/kprobetrace.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ Synopsis of kprobe_events
5858
NAME=FETCHARG : Set NAME as the argument name of FETCHARG.
5959
FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types
6060
(u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types
61-
(x8/x16/x32/x64), "char", "string", "ustring", "symbol", "symstr"
62-
and bitfield are supported.
61+
(x8/x16/x32/x64), VFS layer common type(%pd/%pD), "char",
62+
"string", "ustring", "symbol", "symstr" and bitfield are
63+
supported.
6364

6465
(\*1) only for the probe on function entry (offs == 0). Note, this argument access
6566
is best effort, because depending on the argument type, it may be passed on
@@ -122,6 +123,9 @@ With 'symstr' type, you can filter the event with wildcard pattern of the
122123
symbols, and you don't need to solve symbol name by yourself.
123124
For $comm, the default type is "string"; any other type is invalid.
124125

126+
VFS layer common type(%pd/%pD) is a special type, which fetches dentry's or
127+
file's name from struct dentry's address or struct file's address.
128+
125129
.. _user_mem_access:
126130

127131
User Memory Access

arch/csky/kernel/probes/ftrace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
1212
struct kprobe_ctlblk *kcb;
1313
struct pt_regs *regs;
1414

15+
if (unlikely(kprobe_ftrace_disabled))
16+
return;
17+
1518
bit = ftrace_test_recursion_trylock(ip, parent_ip);
1619
if (bit < 0)
1720
return;

arch/loongarch/kernel/ftrace_dyn.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
287287
struct kprobe *p;
288288
struct kprobe_ctlblk *kcb;
289289

290+
if (unlikely(kprobe_ftrace_disabled))
291+
return;
292+
290293
bit = ftrace_test_recursion_trylock(ip, parent_ip);
291294
if (bit < 0)
292295
return;

arch/parisc/kernel/ftrace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
206206
struct kprobe *p;
207207
int bit;
208208

209+
if (unlikely(kprobe_ftrace_disabled))
210+
return;
211+
209212
bit = ftrace_test_recursion_trylock(ip, parent_ip);
210213
if (bit < 0)
211214
return;

arch/powerpc/kernel/kprobes-ftrace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ void kprobe_ftrace_handler(unsigned long nip, unsigned long parent_nip,
2121
struct pt_regs *regs;
2222
int bit;
2323

24+
if (unlikely(kprobe_ftrace_disabled))
25+
return;
26+
2427
bit = ftrace_test_recursion_trylock(nip, parent_nip);
2528
if (bit < 0)
2629
return;

arch/riscv/kernel/probes/ftrace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
1111
struct kprobe_ctlblk *kcb;
1212
int bit;
1313

14+
if (unlikely(kprobe_ftrace_disabled))
15+
return;
16+
1417
bit = ftrace_test_recursion_trylock(ip, parent_ip);
1518
if (bit < 0)
1619
return;

arch/s390/kernel/ftrace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
296296
struct kprobe *p;
297297
int bit;
298298

299+
if (unlikely(kprobe_ftrace_disabled))
300+
return;
301+
299302
bit = ftrace_test_recursion_trylock(ip, parent_ip);
300303
if (bit < 0)
301304
return;

arch/x86/kernel/kprobes/ftrace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
2121
struct kprobe_ctlblk *kcb;
2222
int bit;
2323

24+
if (unlikely(kprobe_ftrace_disabled))
25+
return;
26+
2427
bit = ftrace_test_recursion_trylock(ip, parent_ip);
2528
if (bit < 0)
2629
return;

include/linux/fprobe.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
#include <linux/ftrace.h>
88
#include <linux/rethook.h>
99

10+
struct fprobe;
11+
12+
typedef int (*fprobe_entry_cb)(struct fprobe *fp, unsigned long entry_ip,
13+
unsigned long ret_ip, struct pt_regs *regs,
14+
void *entry_data);
15+
16+
typedef void (*fprobe_exit_cb)(struct fprobe *fp, unsigned long entry_ip,
17+
unsigned long ret_ip, struct pt_regs *regs,
18+
void *entry_data);
19+
1020
/**
1121
* struct fprobe - ftrace based probe.
1222
* @ops: The ftrace_ops.
@@ -34,12 +44,8 @@ struct fprobe {
3444
size_t entry_data_size;
3545
int nr_maxactive;
3646

37-
int (*entry_handler)(struct fprobe *fp, unsigned long entry_ip,
38-
unsigned long ret_ip, struct pt_regs *regs,
39-
void *entry_data);
40-
void (*exit_handler)(struct fprobe *fp, unsigned long entry_ip,
41-
unsigned long ret_ip, struct pt_regs *regs,
42-
void *entry_data);
47+
fprobe_entry_cb entry_handler;
48+
fprobe_exit_cb exit_handler;
4349
};
4450

4551
/* This fprobe is soft-disabled. */

include/linux/kprobes.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,15 @@ static inline void wait_for_kprobe_optimizer(void) { }
378378
extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
379379
struct ftrace_ops *ops, struct ftrace_regs *fregs);
380380
extern int arch_prepare_kprobe_ftrace(struct kprobe *p);
381+
/* Set when ftrace has been killed: kprobes on ftrace must be disabled for safety */
382+
extern bool kprobe_ftrace_disabled __read_mostly;
383+
extern void kprobe_ftrace_kill(void);
381384
#else
382385
static inline int arch_prepare_kprobe_ftrace(struct kprobe *p)
383386
{
384387
return -EINVAL;
385388
}
389+
static inline void kprobe_ftrace_kill(void) {}
386390
#endif /* CONFIG_KPROBES_ON_FTRACE */
387391

388392
/* Get the kprobe at this addr (if any) - called with preemption disabled */
@@ -495,6 +499,9 @@ static inline void kprobe_flush_task(struct task_struct *tk)
495499
static inline void kprobe_free_init_mem(void)
496500
{
497501
}
502+
static inline void kprobe_ftrace_kill(void)
503+
{
504+
}
498505
static inline int disable_kprobe(struct kprobe *kp)
499506
{
500507
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)