Re: [PATCH 1/3] tracing/kprobes: Avoid perf_trace_buf_*() if->perf_events is empty

From: Oleg Nesterov
Date: Mon Jun 17 2013 - 09:52:39 EST


On 06/17, zhangwei(Jovi) wrote:
>
> On 2013/6/17 1:21, Oleg Nesterov wrote:
> > perf_trace_buf_prepare() + perf_trace_buf_submit() make no sense
> > if this task/CPU has no active counters. Change kprobe_perf_func()
> > and kretprobe_perf_func() to check call->perf_events beforehand
> > and return if this list is empty.
> >
> > For example, "perf record -e some_probe -p1". Only /sbin/init will
> > report, all other threads which hit the same probe will do
> > perf_trace_buf_prepare/perf_trace_buf_submit just to realize that
> > nobody wants perf_swevent_event().
> >
> > Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>
>
> Good point, I think we also need to change other places in below patch.
>
> After applied the patch, perf_tp_event() function call reduced a lots
> when using task based perf tracing.

Yes, I was going to do this, but this is not that simple.

> --- a/include/trace/ftrace.h
> +++ b/include/trace/ftrace.h
> @@ -659,6 +659,10 @@ perf_trace_##call(void *__data, proto) \
> int __data_size; \
> int rctx; \
> \
> + head = this_cpu_ptr(event_call->perf_events); \
> + if (hlist_empty(head)) \
> + return; \
> + \

This is not right. Please note __perf_task() and
"if (task && task != current)" in perf_tp_event().

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/