Skip to content

Commit

Permalink
Merge tag 'trace-v5.5-rc5' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt:
 "Various tracing fixes:

   - kbuild found missing define of MCOUNT_INSN_SIZE for various build
     configs

   - Initialize variable to zero as gcc thinks it is used undefined (it
     really isn't but the code is subtle enough that this doesn't hurt)

   - Convert from do_div() to div64_ull() to prevent potential divide by
     zero

   - Unregister a trace point on error path in sched_wakeup tracer

   - Use signed offset for archs that can have stext not be first

   - A simple indentation fix (whitespace error)"

* tag 'trace-v5.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  tracing: Fix indentation issue
  kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail
  tracing: Change offset type to s32 in preempt/irq tracepoints
  ftrace: Avoid potential division by zero in function profiler
  tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined
  tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls
  tracing: Initialize val to zero in parse_entry of inject code
  • Loading branch information
Linus Torvalds committed Jan 6, 2020
2 parents 7ae5641 + 72879ee commit ae60882
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
8 changes: 4 additions & 4 deletions include/trace/events/preemptirq.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ DECLARE_EVENT_CLASS(preemptirq_template,
TP_ARGS(ip, parent_ip),

TP_STRUCT__entry(
__field(u32, caller_offs)
__field(u32, parent_offs)
__field(s32, caller_offs)
__field(s32, parent_offs)
),

TP_fast_assign(
__entry->caller_offs = (u32)(ip - (unsigned long)_stext);
__entry->parent_offs = (u32)(parent_ip - (unsigned long)_stext);
__entry->caller_offs = (s32)(ip - (unsigned long)_stext);
__entry->parent_offs = (s32)(parent_ip - (unsigned long)_stext);
),

TP_printk("caller=%pS parent=%pS",
Expand Down
14 changes: 14 additions & 0 deletions kernel/trace/fgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func,
return 0;
}

/*
* Not all archs define MCOUNT_INSN_SIZE which is used to look for direct
* functions. But those archs currently don't support direct functions
* anyway, and ftrace_find_rec_direct() is just a stub for them.
* Define MCOUNT_INSN_SIZE to keep those archs compiling.
*/
#ifndef MCOUNT_INSN_SIZE
/* Make sure this only works without direct calls */
# ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
# error MCOUNT_INSN_SIZE not defined with direct calls enabled
# endif
# define MCOUNT_INSN_SIZE 0
#endif

int function_graph_enter(unsigned long ret, unsigned long func,
unsigned long frame_pointer, unsigned long *retp)
{
Expand Down
6 changes: 3 additions & 3 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,7 @@ static int function_stat_show(struct seq_file *m, void *v)
}

#ifdef CONFIG_FUNCTION_GRAPH_TRACER
avg = rec->time;
do_div(avg, rec->counter);
avg = div64_ul(rec->time, rec->counter);
if (tracing_thresh && (avg < tracing_thresh))
goto out;
#endif
Expand All @@ -553,7 +552,8 @@ static int function_stat_show(struct seq_file *m, void *v)
* Divide only 1000 for ns^2 -> us^2 conversion.
* trace_print_graph_duration will divide 1000 again.
*/
do_div(stddev, rec->counter * (rec->counter - 1) * 1000);
stddev = div64_ul(stddev,
rec->counter * (rec->counter - 1) * 1000);
}

trace_seq_init(&s);
Expand Down
2 changes: 1 addition & 1 deletion kernel/trace/trace_events_inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static int parse_entry(char *str, struct trace_event_call *call, void **pentry)
unsigned long irq_flags;
void *entry = NULL;
int entry_size;
u64 val;
u64 val = 0;
int len;

entry = trace_alloc_entry(call, &entry_size);
Expand Down
4 changes: 3 additions & 1 deletion kernel/trace/trace_sched_wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ static void start_wakeup_tracer(struct trace_array *tr)
if (ret) {
pr_info("wakeup trace: Couldn't activate tracepoint"
" probe to kernel_sched_migrate_task\n");
return;
goto fail_deprobe_sched_switch;
}

wakeup_reset(tr);
Expand All @@ -648,6 +648,8 @@ static void start_wakeup_tracer(struct trace_array *tr)
printk(KERN_ERR "failed to start wakeup tracer\n");

return;
fail_deprobe_sched_switch:
unregister_trace_sched_switch(probe_wakeup_sched_switch, NULL);
fail_deprobe_wake_new:
unregister_trace_sched_wakeup_new(probe_wakeup, NULL);
fail_deprobe:
Expand Down
2 changes: 1 addition & 1 deletion kernel/trace/trace_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str,
int prefix_type, int rowsize, int groupsize,
const void *buf, size_t len, bool ascii)
{
unsigned int save_len = s->seq.len;
unsigned int save_len = s->seq.len;

if (s->full)
return 0;
Expand Down
5 changes: 5 additions & 0 deletions kernel/trace/trace_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ static void check_stack(unsigned long ip, unsigned long *stack)
local_irq_restore(flags);
}

/* Some archs may not define MCOUNT_INSN_SIZE */
#ifndef MCOUNT_INSN_SIZE
# define MCOUNT_INSN_SIZE 0
#endif

static void
stack_trace_call(unsigned long ip, unsigned long parent_ip,
struct ftrace_ops *op, struct pt_regs *pt_regs)
Expand Down

0 comments on commit ae60882

Please sign in to comment.