On 5/18/18 12:18 AM, Peter Zijlstra wrote:
On Thu, May 17, 2018 at 10:32:53PM -0700, Yonghong Song wrote:
A new extern function, perf_get_event(), is added to return a perf event
given a struct file. This function will be used in later patches.

Can't you do a narrower interface? Like return the prog. I'm not too
keen on random !perf code frobbing around inside the event.

Hi, Peter,

My initial implementation (not upstreamed) actually have the whole
function bpf_get_perf_event_info() in the events/core.c. In that
case, the "struct file *" pointer is passed. This way, the event pointer
does not need to go to kernel/bpf/syscall.c or kernel/trace/bpf_trace.c.

I dropped this mechanism since it added more codes in the events/core.c
file, and I felt that such query code might clutter events/core.c.
The function bpf_get_perf_event_info() is now placed in kernel/trace/bpf_trace.c.

Just getting bpf prog pointer is not enough as it does not provide
enough attachment information. Getting such information requires
poking into event/tp_event etc.

Currently we have this extern function exposed by events/core.c:
   extern struct perf_event *perf_get_event(struct file *file);
We could make the result value "const" like
   extern const struct perf_event *perf_get_event(struct file *file);
This will make it clear that we do not change "event" fields, and
merely poking at it.

Please let me know your preference.

Thanks!
Yonghong

Reply via email to