Commit 8cfcf155 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt (VMware)

tracing: kprobes: Output kprobe event to printk buffer

Since kprobe-events use event_trigger_unlock_commit_regs() directly,
that events doesn't show up in printk buffer if "tp_printk" is set.

Use trace_event_buffer_commit() in kprobe events so that it can
invoke output_printk() as same as other trace events.

Link: http://lkml.kernel.org/r/157867233085.17873.5210928676787339604.stgit@devnote2Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
[ Adjusted data var declaration placement in __kretprobe_trace_func() ]
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent d8d0c245
...@@ -216,6 +216,7 @@ struct trace_event_buffer { ...@@ -216,6 +216,7 @@ struct trace_event_buffer {
void *entry; void *entry;
unsigned long flags; unsigned long flags;
int pc; int pc;
struct pt_regs *regs;
}; };
void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer, void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer,
......
...@@ -2680,9 +2680,9 @@ void trace_event_buffer_commit(struct trace_event_buffer *fbuffer) ...@@ -2680,9 +2680,9 @@ void trace_event_buffer_commit(struct trace_event_buffer *fbuffer)
if (static_key_false(&tracepoint_printk_key.key)) if (static_key_false(&tracepoint_printk_key.key))
output_printk(fbuffer); output_printk(fbuffer);
event_trigger_unlock_commit(fbuffer->trace_file, fbuffer->buffer, event_trigger_unlock_commit_regs(fbuffer->trace_file, fbuffer->buffer,
fbuffer->event, fbuffer->entry, fbuffer->event, fbuffer->entry,
fbuffer->flags, fbuffer->pc); fbuffer->flags, fbuffer->pc, fbuffer->regs);
} }
EXPORT_SYMBOL_GPL(trace_event_buffer_commit); EXPORT_SYMBOL_GPL(trace_event_buffer_commit);
......
...@@ -272,6 +272,7 @@ void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer, ...@@ -272,6 +272,7 @@ void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer,
if (!fbuffer->event) if (!fbuffer->event)
return NULL; return NULL;
fbuffer->regs = NULL;
fbuffer->entry = ring_buffer_event_data(fbuffer->event); fbuffer->entry = ring_buffer_event_data(fbuffer->event);
return fbuffer->entry; return fbuffer->entry;
} }
......
...@@ -1175,35 +1175,35 @@ __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs, ...@@ -1175,35 +1175,35 @@ __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs,
struct trace_event_file *trace_file) struct trace_event_file *trace_file)
{ {
struct kprobe_trace_entry_head *entry; struct kprobe_trace_entry_head *entry;
struct trace_buffer *buffer;
struct ring_buffer_event *event;
int size, dsize, pc;
unsigned long irq_flags;
struct trace_event_call *call = trace_probe_event_call(&tk->tp); struct trace_event_call *call = trace_probe_event_call(&tk->tp);
struct trace_event_buffer fbuffer;
int dsize;
WARN_ON(call != trace_file->event_call); WARN_ON(call != trace_file->event_call);
if (trace_trigger_soft_disabled(trace_file)) if (trace_trigger_soft_disabled(trace_file))
return; return;
local_save_flags(irq_flags); local_save_flags(fbuffer.flags);
pc = preempt_count(); fbuffer.pc = preempt_count();
fbuffer.trace_file = trace_file;
dsize = __get_data_size(&tk->tp, regs); dsize = __get_data_size(&tk->tp, regs);
size = sizeof(*entry) + tk->tp.size + dsize;
event = trace_event_buffer_lock_reserve(&buffer, trace_file, fbuffer.event =
trace_event_buffer_lock_reserve(&fbuffer.buffer, trace_file,
call->event.type, call->event.type,
size, irq_flags, pc); sizeof(*entry) + tk->tp.size + dsize,
if (!event) fbuffer.flags, fbuffer.pc);
if (!fbuffer.event)
return; return;
entry = ring_buffer_event_data(event); fbuffer.regs = regs;
entry = fbuffer.entry = ring_buffer_event_data(fbuffer.event);
entry->ip = (unsigned long)tk->rp.kp.addr; entry->ip = (unsigned long)tk->rp.kp.addr;
store_trace_args(&entry[1], &tk->tp, regs, sizeof(*entry), dsize); store_trace_args(&entry[1], &tk->tp, regs, sizeof(*entry), dsize);
event_trigger_unlock_commit_regs(trace_file, buffer, event, trace_event_buffer_commit(&fbuffer);
entry, irq_flags, pc, regs);
} }
static void static void
...@@ -1223,36 +1223,35 @@ __kretprobe_trace_func(struct trace_kprobe *tk, struct kretprobe_instance *ri, ...@@ -1223,36 +1223,35 @@ __kretprobe_trace_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
struct trace_event_file *trace_file) struct trace_event_file *trace_file)
{ {
struct kretprobe_trace_entry_head *entry; struct kretprobe_trace_entry_head *entry;
struct trace_buffer *buffer; struct trace_event_buffer fbuffer;
struct ring_buffer_event *event;
int size, pc, dsize;
unsigned long irq_flags;
struct trace_event_call *call = trace_probe_event_call(&tk->tp); struct trace_event_call *call = trace_probe_event_call(&tk->tp);
int dsize;
WARN_ON(call != trace_file->event_call); WARN_ON(call != trace_file->event_call);
if (trace_trigger_soft_disabled(trace_file)) if (trace_trigger_soft_disabled(trace_file))
return; return;
local_save_flags(irq_flags); local_save_flags(fbuffer.flags);
pc = preempt_count(); fbuffer.pc = preempt_count();
fbuffer.trace_file = trace_file;
dsize = __get_data_size(&tk->tp, regs); dsize = __get_data_size(&tk->tp, regs);
size = sizeof(*entry) + tk->tp.size + dsize; fbuffer.event =
trace_event_buffer_lock_reserve(&fbuffer.buffer, trace_file,
event = trace_event_buffer_lock_reserve(&buffer, trace_file,
call->event.type, call->event.type,
size, irq_flags, pc); sizeof(*entry) + tk->tp.size + dsize,
if (!event) fbuffer.flags, fbuffer.pc);
if (!fbuffer.event)
return; return;
entry = ring_buffer_event_data(event); fbuffer.regs = regs;
entry = fbuffer.entry = ring_buffer_event_data(fbuffer.event);
entry->func = (unsigned long)tk->rp.kp.addr; entry->func = (unsigned long)tk->rp.kp.addr;
entry->ret_ip = (unsigned long)ri->ret_addr; entry->ret_ip = (unsigned long)ri->ret_addr;
store_trace_args(&entry[1], &tk->tp, regs, sizeof(*entry), dsize); store_trace_args(&entry[1], &tk->tp, regs, sizeof(*entry), dsize);
event_trigger_unlock_commit_regs(trace_file, buffer, event, trace_event_buffer_commit(&fbuffer);
entry, irq_flags, pc, regs);
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment