Re: [PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread xiakaixu
于 2015/7/23 10:22, Alexei Starovoitov 写道: > On 7/22/15 7:12 PM, xiakaixu wrote: >> So you mean like this? >> >> u64 bpf_perf_event_read(u64 r1, u64 index,...) >> { >>struct bpf_perf_event_array *array = (void *) (long) r1; >>struct perf_event *event; >>... >>event =

Re: [PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread Alexei Starovoitov
On 7/22/15 7:12 PM, xiakaixu wrote: So you mean like this? u64 bpf_perf_event_read(u64 r1, u64 index,...) { struct bpf_perf_event_array *array = (void *) (long) r1; struct perf_event *event; ... event = array->events[index]; ... } yes. the only thing needed is to add: if (index

Re: [PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread xiakaixu
于 2015/7/23 9:14, Alexei Starovoitov 写道: > On 7/22/15 1:09 AM, Kaixu Xia wrote: >> According to the perf_event_map_fd and key, the function >> bpf_perf_event_read() can convert the corresponding map >> value to the pointer to struct perf_event and return the >> Hardware PMU counter value. >> >>

Re: [PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread Alexei Starovoitov
On 7/22/15 1:09 AM, Kaixu Xia wrote: According to the perf_event_map_fd and key, the function bpf_perf_event_read() can convert the corresponding map value to the pointer to struct perf_event and return the Hardware PMU counter value. The key can't be passed to bpf_perf_event_read() directly

[PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread Kaixu Xia
According to the perf_event_map_fd and key, the function bpf_perf_event_read() can convert the corresponding map value to the pointer to struct perf_event and return the Hardware PMU counter value. The key can't be passed to bpf_perf_event_read() directly because the function argument constraint

[PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread Kaixu Xia
According to the perf_event_map_fd and key, the function bpf_perf_event_read() can convert the corresponding map value to the pointer to struct perf_event and return the Hardware PMU counter value. The key can't be passed to bpf_perf_event_read() directly because the function argument constraint

Re: [PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread Alexei Starovoitov
On 7/22/15 1:09 AM, Kaixu Xia wrote: According to the perf_event_map_fd and key, the function bpf_perf_event_read() can convert the corresponding map value to the pointer to struct perf_event and return the Hardware PMU counter value. The key can't be passed to bpf_perf_event_read() directly

Re: [PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread xiakaixu
于 2015/7/23 9:14, Alexei Starovoitov 写道: On 7/22/15 1:09 AM, Kaixu Xia wrote: According to the perf_event_map_fd and key, the function bpf_perf_event_read() can convert the corresponding map value to the pointer to struct perf_event and return the Hardware PMU counter value. The key can't

Re: [PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread Alexei Starovoitov
On 7/22/15 7:12 PM, xiakaixu wrote: So you mean like this? u64 bpf_perf_event_read(u64 r1, u64 index,...) { struct bpf_perf_event_array *array = (void *) (long) r1; struct perf_event *event; ... event = array-events[index]; ... } yes. the only thing needed is to add: if (index

Re: [PATCH v2 4/5] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

2015-07-22 Thread xiakaixu
于 2015/7/23 10:22, Alexei Starovoitov 写道: On 7/22/15 7:12 PM, xiakaixu wrote: So you mean like this? u64 bpf_perf_event_read(u64 r1, u64 index,...) { struct bpf_perf_event_array *array = (void *) (long) r1; struct perf_event *event; ... event = array-events[index]; ... }