Skip to content

Commit 54663cf

Browse files
committed
Merge tag 'trace-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "Functional fixes: - Fix big endian conversion for arm64 in recordmcount processing - Fix timestamp corruption in ring buffer on discarding events - Fix memory leak in __create_synth_event() - Skip selftests if tracing is disabled as it will cause them to fail. Non-functional fixes: - Fix help text in Kconfig - Remove duplicate prototype for trace_empty() - Fix stale comment about the trace_event_call flags. Self test update: - Add more information to the validation output of when a corrupt timestamp is found in the ring buffer, and also trigger a warning to make sure that tests catch it" * tag 'trace-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Fix comment about the trace_event_call flags tracing: Skip selftests if tracing is disabled tracing: Fix memory leak in __create_synth_event() ring-buffer: Add a little more information and a WARN when time stamp going backwards is detected ring-buffer: Force before_stamp and write_stamp to be different on discard tracing: Fix help text of TRACEPOINT_BENCHMARK in Kconfig tracing: Remove duplicate declaration from trace.h ftrace: Have recordmcount use w8 to read relp->r_info in arm64_is_fake_mcount
2 parents 280d542 + f9f3444 commit 54663cf

7 files changed

Lines changed: 31 additions & 16 deletions

File tree

include/linux/trace_events.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,8 @@ struct trace_event_call {
349349
struct event_filter *filter;
350350
void *mod;
351351
void *data;
352-
/*
353-
* bit 0: filter_active
354-
* bit 1: allow trace by non root (cap any)
355-
* bit 2: failed to apply filter
356-
* bit 3: trace internal event (do not enable)
357-
* bit 4: Event was enabled by module
358-
* bit 5: use call filter rather than file filter
359-
* bit 6: Event is a tracepoint
360-
*/
352+
353+
/* See the TRACE_EVENT_FL_* flags above */
361354
int flags; /* static flags of different events */
362355

363356
#ifdef CONFIG_PERF_EVENTS

kernel/trace/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ config TRACEPOINT_BENCHMARK
694694
help
695695
This option creates the tracepoint "benchmark:benchmark_event".
696696
When the tracepoint is enabled, it kicks off a kernel thread that
697-
goes into an infinite loop (calling cond_sched() to let other tasks
697+
goes into an infinite loop (calling cond_resched() to let other tasks
698698
run), and calls the tracepoint. Each iteration will record the time
699699
it took to write to the tracepoint and the next iteration that
700700
data will be passed to the tracepoint itself. That is, the tracepoint

kernel/trace/ring_buffer.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,6 +2814,17 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
28142814
write_stamp, write_stamp - delta))
28152815
return 0;
28162816

2817+
/*
2818+
* It's possible that the event time delta is zero
2819+
* (has the same time stamp as the previous event)
2820+
* in which case write_stamp and before_stamp could
2821+
* be the same. In such a case, force before_stamp
2822+
* to be different than write_stamp. It doesn't
2823+
* matter what it is, as long as its different.
2824+
*/
2825+
if (!delta)
2826+
rb_time_set(&cpu_buffer->before_stamp, 0);
2827+
28172828
/*
28182829
* If an event were to come in now, it would see that the
28192830
* write_stamp and the before_stamp are different, and assume
@@ -3307,9 +3318,13 @@ static void check_buffer(struct ring_buffer_per_cpu *cpu_buffer,
33073318
goto out;
33083319
}
33093320
atomic_inc(&cpu_buffer->record_disabled);
3310-
pr_warn("[CPU: %d]TIME DOES NOT MATCH expected:%lld actual:%lld delta:%lld after:%lld\n",
3311-
cpu_buffer->cpu,
3312-
ts + info->delta, info->ts, info->delta, info->after);
3321+
/* There's some cases in boot up that this can happen */
3322+
WARN_ON_ONCE(system_state != SYSTEM_BOOTING);
3323+
pr_warn("[CPU: %d]TIME DOES NOT MATCH expected:%lld actual:%lld delta:%lld before:%lld after:%lld%s\n",
3324+
cpu_buffer->cpu,
3325+
ts + info->delta, info->ts, info->delta,
3326+
info->before, info->after,
3327+
full ? " (full)" : "");
33133328
dump_buffer_page(bpage, info, tail);
33143329
atomic_dec(&ts_dump);
33153330
/* Do not re-enable checking */

kernel/trace/trace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,12 @@ static int run_tracer_selftest(struct tracer *type)
19291929
if (!selftests_can_run)
19301930
return save_selftest(type);
19311931

1932+
if (!tracing_is_on()) {
1933+
pr_warn("Selftest for tracer %s skipped due to tracing disabled\n",
1934+
type->name);
1935+
return 0;
1936+
}
1937+
19321938
/*
19331939
* Run a selftest on this tracer.
19341940
* Here we reset the trace buffer, and set the current

kernel/trace/trace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ void trace_graph_function(struct trace_array *tr,
605605
void trace_latency_header(struct seq_file *m);
606606
void trace_default_header(struct seq_file *m);
607607
void print_trace_header(struct seq_file *m, struct trace_iterator *iter);
608-
int trace_empty(struct trace_iterator *iter);
609608

610609
void trace_graph_return(struct ftrace_graph_ret *trace);
611610
int trace_graph_entry(struct ftrace_graph_ent *trace);

kernel/trace/trace_events_synth.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,8 +1225,10 @@ static int __create_synth_event(const char *name, const char *raw_fields)
12251225
goto err;
12261226
}
12271227

1228-
if (!argc)
1228+
if (!argc) {
1229+
argv_free(argv);
12291230
continue;
1231+
}
12301232

12311233
n_fields_this_loop = 0;
12321234
consumed = 0;

scripts/recordmcount.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static int arm_is_fake_mcount(Elf32_Rel const *rp)
438438

439439
static int arm64_is_fake_mcount(Elf64_Rel const *rp)
440440
{
441-
return ELF64_R_TYPE(w(rp->r_info)) != R_AARCH64_CALL26;
441+
return ELF64_R_TYPE(w8(rp->r_info)) != R_AARCH64_CALL26;
442442
}
443443

444444
/* 64-bit EM_MIPS has weird ELF64_Rela.r_info.

0 commit comments

Comments
 (0)