mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:09:29 +02:00
Merge tag 'probes-v7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull probes updates from Masami Hiramatsu:
"BTF typecasting and variable fetch enhancements:
- Typecast support across probe events: Extended BTF typecasting
syntax (e.g., (STRUCT)PARAM->MEMBER) to kprobes, uprobes, and
fprobes on function entry and return
- Nested typecasts: Added support for chaining and nesting typecasts
up to 3 levels, including casting registers and stack variables
- Field specifier option: Added (STRUCT,FIELD) syntax to emulate
container_of(), allowing retrieval of parent structures from member
pointers
- $current variable support: Introduced $current special variable to
access the running task_struct via BTF dereferencing
- Per-CPU variable access: Added this_cpu_read() and this_cpu_ptr()
fetcharg methods to trace CPU-local data safely
- Fetcharg bytecode dumper: Added CONFIG_PROBE_EVENTS_DUMP_FETCHARG
to dump the compiled fetcharg bytecode instructions as comments in
dynamic_events
- Extended symbol name handling: Removed the MAX_COMMON_HEAD_LEN
limit and extended MAX_ARGSTR_LEN to 256 bytes, enabling probing of
long symbols, mangled Rust symbols and complex BTF expressions
- eprobe variable syntax: Allowed eprobes to reference event fields
directly without requiring a '$' prefix
- Cleanup unused parameters, redundant codes, duplicate macros and
pointer arithmetic
- Use a ternary operator for simplifying fetch_type_from_btf_type()
Expanded boot time dynamic probe support:
- Add boot-time tracing configuration support for event probes
(eprobes), function probes (fprobes), and tracepoint probes
(tprobes)
- Allow comment lines ('#') in dynamic_events file
Optimization, robustness, and cleanups:
- Simplify fprobe_remove_ips() by reusing graph and ftrace helpers
- Remove __packed attribute from struct __fprobe_header to avoid
unaligned memory access penalties on RISC architectures
- Remove redundant memset() calls in perf event probe handlers
- Replace legacy __ASSEMBLY__ with __ASSEMBLER__ in header files
Selftests & refactoring:
- Refactor parse_probe_arg() and parse_probe_vars(), and eliminate
recursion in probe argument parsing to protect kernel stack depth
- Add selftests for BTF typecasts and module probing without module
prefixes
- Force LC_ALL=C in ftracetest to prevent test failures on localized
systems
- Refactor btf_type_skip_modifiers() to remove ignored id parameter
- Sort ERRORS list in trace_probe.h alphabetically
- Fix typo in fprobe docs, and trace_fprobe function name
- Rename FETCH_OP_DATA to FETCH_OP_IMMSTR
- Make file offset error message probe-agnostic"
* tag 'probes-v7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (37 commits)
fprobe: Simplify fprobe_remove_ips() by reusing existing helpers
tracing/boot: Add support for eprobe, fprobe, and tprobe events
selftests/ftrace: Force C locale in ftracetest
tracing/probes: Treating longer symbol name on event comparation
docs: trace: fprobe: fix 'thos' spelling
tracing/probes: Fix extra whitespace in trace_probe_kernel.h
tracing/kprobe: Remove redundant memset in kprobe_perf_func()
tracing/fprobe: Remove redundant memset in fentry_perf_func()
tracing/fprobe: Remove redundant snprintf in trace_fprobe_match_command_head()
tracing/probes: Simplify BTF_KIND_PTR case in fetch_type_from_btf_type()
tracing/probes: Cleanup pointer arithmetic in store_trace_entry_data()
tracing/probes: Remove unused parameter from parse_probe_var_retval()
tracing/probes: Remove redundant bounds check in trace_probe_compare_arg_type()
tracing/probes: Remove redundant boolean conversion in trace_probe_has_single_file()
tracing/probes: Remove duplicate MAX_ARRAY_LEN macro definition
selftests/ftrace: Add test case for a symbol in a module without module name
tracing/probes: Eliminate recursion in parse_probe_arg()
tracing/probes: Extend max length of argument string
tracing/probes: Sort ERRORS list in trace_probe.h alphabetically
tracing/probes: Refactor parse_probe_arg()
...
This commit is contained in:
@@ -94,6 +94,20 @@ static int simple_thread_fn(void *arg)
|
||||
static DEFINE_MUTEX(thread_mutex);
|
||||
static int simple_thread_cnt;
|
||||
|
||||
static struct foo_timer_data *foo_timer_data;
|
||||
|
||||
static void sample_timer_cb(struct timer_list *t)
|
||||
{
|
||||
struct foo_timer_data *data = container_of(t, struct foo_timer_data, timer);
|
||||
|
||||
get_cpu();
|
||||
trace_foo_timer_fn(data);
|
||||
(*this_cpu_ptr(data->counter))++;
|
||||
put_cpu();
|
||||
|
||||
mod_timer(t, jiffies + HZ);
|
||||
}
|
||||
|
||||
int foo_bar_reg(void)
|
||||
{
|
||||
mutex_lock(&thread_mutex);
|
||||
@@ -132,9 +146,27 @@ void foo_bar_unreg(void)
|
||||
|
||||
static int __init trace_event_init(void)
|
||||
{
|
||||
foo_timer_data = kzalloc_obj(*foo_timer_data, GFP_KERNEL);
|
||||
if (!foo_timer_data)
|
||||
return -ENOMEM;
|
||||
|
||||
foo_timer_data->name = "sample_timer_counter";
|
||||
foo_timer_data->counter = alloc_percpu(int);
|
||||
if (!foo_timer_data->counter) {
|
||||
kfree(foo_timer_data);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
timer_setup(&foo_timer_data->timer, sample_timer_cb, 0);
|
||||
mod_timer(&foo_timer_data->timer, jiffies + HZ);
|
||||
|
||||
simple_tsk = kthread_run(simple_thread, NULL, "event-sample");
|
||||
if (IS_ERR(simple_tsk))
|
||||
return -1;
|
||||
if (IS_ERR(simple_tsk)) {
|
||||
timer_shutdown_sync(&foo_timer_data->timer);
|
||||
free_percpu(foo_timer_data->counter);
|
||||
kfree(foo_timer_data);
|
||||
return PTR_ERR(simple_tsk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -147,6 +179,10 @@ static void __exit trace_event_exit(void)
|
||||
kthread_stop(simple_tsk_fn);
|
||||
simple_tsk_fn = NULL;
|
||||
mutex_unlock(&thread_mutex);
|
||||
|
||||
timer_shutdown_sync(&foo_timer_data->timer);
|
||||
free_percpu(foo_timer_data->counter);
|
||||
kfree(foo_timer_data);
|
||||
}
|
||||
|
||||
module_init(trace_event_init);
|
||||
|
||||
@@ -247,12 +247,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* It is OK to have helper functions in the file, but they need to be protected
|
||||
* from being defined more than once. Remember, this file gets included more
|
||||
* than once.
|
||||
* It is OK to have helper functions and data structures in the file, but they
|
||||
* need to be protected from being defined more than once. Remember, this file
|
||||
* gets included more than once.
|
||||
*/
|
||||
#ifndef __TRACE_EVENT_SAMPLE_HELPER_FUNCTIONS
|
||||
#define __TRACE_EVENT_SAMPLE_HELPER_FUNCTIONS
|
||||
#include <linux/timer.h>
|
||||
|
||||
static inline int __length_of(const int *list)
|
||||
{
|
||||
int i;
|
||||
@@ -270,6 +272,13 @@ enum {
|
||||
TRACE_SAMPLE_BAR = 4,
|
||||
TRACE_SAMPLE_ZOO = 8,
|
||||
};
|
||||
|
||||
struct foo_timer_data {
|
||||
const char *name;
|
||||
struct timer_list timer;
|
||||
int __percpu *counter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -595,6 +604,25 @@ TRACE_EVENT(foo_rel_loc,
|
||||
__get_rel_bitmask(bitmask),
|
||||
__get_rel_cpumask(cpumask))
|
||||
);
|
||||
|
||||
TRACE_EVENT(foo_timer_fn,
|
||||
|
||||
TP_PROTO(struct foo_timer_data *data),
|
||||
|
||||
TP_ARGS(data),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__string( name, data->name )
|
||||
__field( int, count )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__assign_str(name);
|
||||
__entry->count = *this_cpu_ptr(data->counter);
|
||||
),
|
||||
|
||||
TP_printk("name=%s count=%d", __get_str(name), __entry->count)
|
||||
);
|
||||
#endif
|
||||
|
||||
/***** NOTICE! The #if protection ends here. *****/
|
||||
|
||||
Reference in New Issue
Block a user