Skip to content

Commit b047602

Browse files
committed
Merge tag 'trace-v5.19-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "Fixes and minor clean ups for tracing: - Fix memory leak by reverting what was thought to be a double free. A static tool had gave a false positive that a double free was possible in the error path, but it was actually a different location that confused the static analyzer (and those of us that reviewed it). - Move use of static buffers by ftrace_dump() to a location that can be used by kgdb's ftdump(), as it needs it for the same reasons. - Clarify in the Kconfig description that function tracing has negligible impact on x86, but may have a bit bigger impact on other architectures. - Remove unnecessary extra semicolon in trace event. - Make a local variable static that is used in the fprobes sample - Use KSYM_NAME_LEN for length of function in kprobe sample and get rid of unneeded macro for the same purpose" * tag 'trace-v5.19-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: samples: Use KSYM_NAME_LEN for kprobes fprobe/samples: Make sample_probe static blk-iocost: tracing: atomic64_read(&ioc->vtime_rate) is assigned an extra semicolon ftrace: Be more specific about arch impact when function tracer is enabled tracing: Fix sleeping while atomic in kdb ftdump tracing/histograms: Fix memory leak problem
2 parents 72a8e05 + 1e1fb42 commit b047602

File tree

7 files changed

+16
-14
lines changed

7 files changed

+16
-14
lines changed

include/trace/events/iocost.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ TRACE_EVENT(iocost_ioc_vrate_adj,
160160

161161
TP_fast_assign(
162162
__assign_str(devname, ioc_name(ioc));
163-
__entry->old_vrate = atomic64_read(&ioc->vtime_rate);;
163+
__entry->old_vrate = atomic64_read(&ioc->vtime_rate);
164164
__entry->new_vrate = new_vrate;
165165
__entry->busy_level = ioc->busy_level;
166166
__entry->read_missed_ppm = missed_ppm[READ];

kernel/trace/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ config FUNCTION_TRACER
194194
sequence is then dynamically patched into a tracer call when
195195
tracing is enabled by the administrator. If it's runtime disabled
196196
(the bootup default), then the overhead of the instructions is very
197-
small and not measurable even in micro-benchmarks.
197+
small and not measurable even in micro-benchmarks (at least on
198+
x86, but may have impact on other architectures).
198199

199200
config FUNCTION_GRAPH_TRACER
200201
bool "Kernel Function Graph Tracer"

kernel/trace/trace.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9864,6 +9864,12 @@ void trace_init_global_iter(struct trace_iterator *iter)
98649864
/* Output in nanoseconds only if we are using a clock in nanoseconds. */
98659865
if (trace_clocks[iter->tr->clock_id].in_ns)
98669866
iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
9867+
9868+
/* Can not use kmalloc for iter.temp and iter.fmt */
9869+
iter->temp = static_temp_buf;
9870+
iter->temp_size = STATIC_TEMP_BUF_SIZE;
9871+
iter->fmt = static_fmt_buf;
9872+
iter->fmt_size = STATIC_FMT_BUF_SIZE;
98679873
}
98689874

98699875
void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
@@ -9896,11 +9902,6 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
98969902

98979903
/* Simulate the iterator */
98989904
trace_init_global_iter(&iter);
9899-
/* Can not use kmalloc for iter.temp and iter.fmt */
9900-
iter.temp = static_temp_buf;
9901-
iter.temp_size = STATIC_TEMP_BUF_SIZE;
9902-
iter.fmt = static_fmt_buf;
9903-
iter.fmt_size = STATIC_FMT_BUF_SIZE;
99049905

99059906
for_each_tracing_cpu(cpu) {
99069907
atomic_inc(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled);

kernel/trace/trace_events_hist.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4430,6 +4430,8 @@ static int parse_var_defs(struct hist_trigger_data *hist_data)
44304430

44314431
s = kstrdup(field_str, GFP_KERNEL);
44324432
if (!s) {
4433+
kfree(hist_data->attrs->var_defs.name[n_vars]);
4434+
hist_data->attrs->var_defs.name[n_vars] = NULL;
44334435
ret = -ENOMEM;
44344436
goto free;
44354437
}

samples/fprobe/fprobe_example.c

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

2121
#define BACKTRACE_DEPTH 16
2222
#define MAX_SYMBOL_LEN 4096
23-
struct fprobe sample_probe;
23+
static struct fprobe sample_probe;
2424
static unsigned long nhit;
2525

2626
static char symbol[MAX_SYMBOL_LEN] = "kernel_clone";

samples/kprobes/kprobe_example.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
#include <linux/module.h>
1717
#include <linux/kprobes.h>
1818

19-
#define MAX_SYMBOL_LEN 64
20-
static char symbol[MAX_SYMBOL_LEN] = "kernel_clone";
21-
module_param_string(symbol, symbol, sizeof(symbol), 0644);
19+
static char symbol[KSYM_NAME_LEN] = "kernel_clone";
20+
module_param_string(symbol, symbol, KSYM_NAME_LEN, 0644);
2221

2322
/* For each probe you need to allocate a kprobe structure */
2423
static struct kprobe kp = {

samples/kprobes/kretprobe_example.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
#include <linux/module.h>
2424
#include <linux/kprobes.h>
2525
#include <linux/ktime.h>
26-
#include <linux/limits.h>
2726
#include <linux/sched.h>
2827

29-
static char func_name[NAME_MAX] = "kernel_clone";
30-
module_param_string(func, func_name, NAME_MAX, S_IRUGO);
28+
static char func_name[KSYM_NAME_LEN] = "kernel_clone";
29+
module_param_string(func, func_name, KSYM_NAME_LEN, 0644);
3130
MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the"
3231
" function's execution time");
3332

0 commit comments

Comments
 (0)