Skip to content

uprobes/tracing: Don't pass addr=ip to perf_trace_buf_submit()

Oleg Nesterov lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1uprobes/tracing: Don't pass addr=ip to perf_trace_buf_submit()kernel/trace/trace_uprobe.c+3 -52 replies
1/1uprobes/perf: Avoid perf_trace_buf_prepare/submit if ->perf_events is emptykernel/trace/trace_uprobe.c+4 -10 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchMasami HiramatsuSrikar Dronamraju
1/1A-b A-b
1/1A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/1] uprobes/tracing: Don't pass addr=ip to perf_trace_buf_submit()
Quoted 11 lines · Masami Hiramatsu
Quoted 9 lines · Oleg Nesterov

Masami, perhaps you can also answer the question I asked in 0/4 marc.info/?l=linux-kernel&m=136458107403835 ?

	Off-topic question... Why uprobe_perf_func() passes "addr = ip" to
	perf_trace_buf_submit() ? This just sets perf_sample_data->addr for
	PERF_SAMPLE_ADDR, do we really need this? and we already have
	perf_sample_data->ip initialized by perf.
Quoted 6 lines
Quoted 2 lines

kprobe_perf_func() and kretprobe_perf_func() do the same.

Good catch! I guess that I might misunderstood that it was used for sampling execution address. It should be replaced with (u64)0, as perf_trace_##call() does.

Thanks!

How about this trivial cleanup then? If I have your ack I'll add this patch to other pending changes.

And... Cough, another question ;) To simplify, lets discuss kprobe_perf_func() only. Suppose that a task hits the kprobe but this task/cpu doesn't have a counter. Can't we avoid perf_trace_buf_prepare/submit in this case? IOW, what do you think about the change below?

Oleg.

kernel/trace/trace_kprobe.c +4 -1
@@ -985,6 +985,10 @@ static __kprobes void kprobe_perf_func(s
 	int size, __size, dsize;
 	int rctx;
 
+	head = this_cpu_ptr(call->perf_events);
+	if (hlist_empty(head))
+		return;
+
 	dsize = __get_data_size(tp, regs);
 	__size = sizeof(*entry) + tp->size + dsize;
 	size = ALIGN(__size + sizeof(u32), sizeof(u64));
@@ -1001,7 +1005,6 @@ static __kprobes void kprobe_perf_func(s
 	memset(&entry[1], 0, dsize);
 	store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
 
-	head = this_cpu_ptr(call->perf_events);
 	perf_trace_buf_submit(entry, size, rctx,
 					entry->ip, 1, regs, head, NULL);
 }