Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-08-03 Thread Peter Zijlstra
On Thu, Jul 23, 2015 at 09:42:40AM +, Kaixu Xia wrote: > +static struct perf_event *convert_map_with_perf_event(void *value) > +{ > + struct perf_event *event; > + u32 fd; > + > + fd = *(u32 *)value; > + > + event = perf_event_get(fd); > + if (IS_ERR(event)) > +

Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-08-03 Thread Peter Zijlstra
On Thu, Jul 23, 2015 at 09:42:40AM +, Kaixu Xia wrote: +static struct perf_event *convert_map_with_perf_event(void *value) +{ + struct perf_event *event; + u32 fd; + + fd = *(u32 *)value; + + event = perf_event_get(fd); + if (IS_ERR(event)) + return

Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-07-23 Thread Alexei Starovoitov
On 7/23/15 7:22 PM, xiakaixu wrote: +/* check if the value is already stored */ >>+if (array->events[index]) >>+return -EINVAL; >>+ >>+/* convert the fd to the pointer to struct perf_event */ >>+event = convert_map_with_perf_event(value); > >imo helper name is misleading

Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-07-23 Thread xiakaixu
于 2015/7/24 6:54, Alexei Starovoitov 写道: > On 7/23/15 2:42 AM, Kaixu Xia wrote: >> Introduce a new bpf map type 'BPF_MAP_TYPE_PERF_EVENT_ARRAY'. >> This map only stores the pointer to struct perf_event. The >> user space event FDs from perf_event_open() syscall are converted >> to the pointer to

Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-07-23 Thread Alexei Starovoitov
On 7/23/15 2:42 AM, Kaixu Xia wrote: Introduce a new bpf map type 'BPF_MAP_TYPE_PERF_EVENT_ARRAY'. This map only stores the pointer to struct perf_event. The user space event FDs from perf_event_open() syscall are converted to the pointer to struct perf_event and stored in map. ... +static

[PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-07-23 Thread Kaixu Xia
Introduce a new bpf map type 'BPF_MAP_TYPE_PERF_EVENT_ARRAY'. This map only stores the pointer to struct perf_event. The user space event FDs from perf_event_open() syscall are converted to the pointer to struct perf_event and stored in map. Signed-off-by: Kaixu Xia --- include/linux/bpf.h

Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-07-23 Thread Alexei Starovoitov
On 7/23/15 2:42 AM, Kaixu Xia wrote: Introduce a new bpf map type 'BPF_MAP_TYPE_PERF_EVENT_ARRAY'. This map only stores the pointer to struct perf_event. The user space event FDs from perf_event_open() syscall are converted to the pointer to struct perf_event and stored in map. ... +static

Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-07-23 Thread Alexei Starovoitov
On 7/23/15 7:22 PM, xiakaixu wrote: +/* check if the value is already stored */ +if (array-events[index]) +return -EINVAL; + +/* convert the fd to the pointer to struct perf_event */ +event = convert_map_with_perf_event(value); imo helper name is misleading and it's too

Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-07-23 Thread xiakaixu
于 2015/7/24 6:54, Alexei Starovoitov 写道: On 7/23/15 2:42 AM, Kaixu Xia wrote: Introduce a new bpf map type 'BPF_MAP_TYPE_PERF_EVENT_ARRAY'. This map only stores the pointer to struct perf_event. The user space event FDs from perf_event_open() syscall are converted to the pointer to struct

[PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-07-23 Thread Kaixu Xia
Introduce a new bpf map type 'BPF_MAP_TYPE_PERF_EVENT_ARRAY'. This map only stores the pointer to struct perf_event. The user space event FDs from perf_event_open() syscall are converted to the pointer to struct perf_event and stored in map. Signed-off-by: Kaixu Xia xiaka...@huawei.com ---