[PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

2015-10-20 Thread Kaixu Xia
the perf event on current cpu or all the perf events stored in the maps by checking the third parameter 'flags'. Signed-off-by: Kaixu Xia <xiaka...@huawei.com> --- include/linux/perf_event.h | 1 + include/uapi/linux/bpf.h| 11 include/uapi/linux/perf_event.h | 3 +- kern

[PATCH V5 0/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

2015-10-20 Thread Kaixu Xia
int bpf_prog_2(struct pt_regs *ctx) { bpf_perf_event_control(_cycles_map, 0, 2); return 0; } Consider control sampling in function level, we have to set a high sample frequency to dump trace data when enable/disable the perf event on current cpu. Kaixu Xia (1): bpf: control events s

[PATCH V4 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

2015-10-19 Thread Kaixu Xia
the perf event on current cpu or all the perf events stored in the maps by checking the third parameter 'flag'. Signed-off-by: Kaixu Xia <xiaka...@huawei.com> --- include/linux/perf_event.h | 1 + include/uapi/linux/bpf.h| 19 +++ include/uapi/linux/perf_event.

[PATCH V4 0/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

2015-10-19 Thread Kaixu Xia
ng in function level, we have to set a high sample frequency to dump trace data when enable/disable the perf event on current cpu. Kaixu Xia (1): bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling include/linux/perf_event.h | 1 +

[PATCH V3 2/2] bpf: control all the perf events stored in PERF_EVENT_ARRAY maps

2015-10-16 Thread Kaixu Xia
This patch implements the function that controlling all the perf events stored in PERF_EVENT_ARRAY maps by setting the parameter 'index' to maps max_entries. Signed-off-by: Kaixu Xia <xiaka...@huawei.com> --- kernel/trace/bpf_trace.c | 20 ++-- 1 file changed, 18 insertions

[PATCH V3 0/2] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

2015-10-16 Thread Kaixu Xia
bpf_prog_2(struct pt_regs *ctx) { bpf_perf_event_dump_control(_cycles_map, 32, 1); return 0; } Consider control sampling in function level, we have to set a high sample frequency to dump trace data when enable/disable the perf event on current cpu. Kaixu Xia (2): bpf: control the trace data output on curren

[PATCH V3 1/2] bpf: control the trace data output on current cpu when perf sampling

2015-10-16 Thread Kaixu Xia
the perf_event on current cpu. Signed-off-by: Kaixu Xia <xiaka...@huawei.com> --- include/linux/perf_event.h | 1 + include/uapi/linux/bpf.h| 5 + include/uapi/linux/perf_event.h | 3 ++- kernel/bpf/verifier.c | 3 ++- kernel/events/core.c

[PATCH V2 2/2] bpf: control a set of perf events by creating a new ioctl PERF_EVENT_IOC_SET_ENABLER

2015-10-14 Thread Kaixu Xia
This patch creates a new ioctl PERF_EVENT_IOC_SET_ENABLER to let perf to select an event as 'enabler'. So we can set this 'enabler' event to enable/disable a set of events. The event on CPU 0 is treated as the 'enabler' event by default. Signed-off-by: Kaixu Xia <xiaka...@huawei.com> --- i

[PATCH V2 1/2] bpf: control the trace data output on current cpu when perf sampling

2015-10-14 Thread Kaixu Xia
the perf_event on current cpu. Signed-off-by: Kaixu Xia <xiaka...@huawei.com> --- include/linux/perf_event.h | 1 + include/uapi/linux/bpf.h| 5 + include/uapi/linux/perf_event.h | 3 ++- kernel/bpf/verifier.c | 3 ++- kernel/events/core.c

[PATCH V2 0/2] bpf: enable/disable events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

2015-10-14 Thread Kaixu Xia
quot;) int bpf_prog_2(struct pt_regs *ctx) { bpf_perf_event_sample_control(_cycles_map, 32, 1); return 0; } Consider control sampling in function level, if we don't use the PERF_EVENT_IOC_SET_ENABLER ioctl in perf user side, we must set a high sample frequency to dump tra

[RFC PATCH 0/2] bpf: enable/disable events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

2015-10-12 Thread Kaixu Xia
; return 0; } SEC("exit=sys_write%return") int bpf_prog_2(struct pt_regs *ctx) { bpf_perf_event_sample_disable(_cycles_map); return 0; } Kaixu Xia (2): perf: Add the flag sample_disable not to output data on samples bpf: Implement bpf_pe

[RFC PATCH 1/2] perf: Add the flag sample_disable not to output data on samples

2015-10-12 Thread Kaixu Xia
-off-by: Kaixu Xia <xiaka...@huawei.com> --- include/linux/bpf.h| 1 + include/linux/perf_event.h | 2 ++ kernel/bpf/arraymap.c | 5 + kernel/events/core.c | 3 +++ 4 files changed, 11 insertions(+) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index f57d7fe..2

[RFC PATCH 2/2] bpf: Implement bpf_perf_event_sample_enable/disable() helpers

2015-10-12 Thread Kaixu Xia
The functions bpf_perf_event_sample_enable/disable() can set the flag sample_disable to enable/disable output trace data on samples. Signed-off-by: Kaixu Xia <xiaka...@huawei.com> --- include/linux/bpf.h | 2 ++ include/uapi/linux/bpf.h | 2 ++ kernel/bpf/verifier.c| 4 +++-

[PATCH net-next] bpf: fix build warnings and add function read_trace_pipe()

2015-08-12 Thread Kaixu Xia
sshd-683 [000] d..1 131.429378: : CPU-0 222561024 ... Signed-off-by: Kaixu Xia xiaka...@huawei.com --- samples/bpf/tracex6_kern.c | 1 + samples/bpf/tracex6_user.c | 22 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/samples/bpf

[PATCH v2 net-next] bpf: s390: Fix build error caused by the struct bpf_array member name changed

2015-08-11 Thread Kaixu Xia
There is a build error that 'struct bpf_array' has no member named 'prog' on s390. In commit 2a36f0b, the member 'prog' of struct bpf_array is replaced by 'ptrs'. So this patch fixes it. Signed-off-by: Kaixu Xia xiaka...@huawei.com --- arch/s390/net/bpf_jit_comp.c | 4 ++-- 1 file changed, 2

[PATCH v3 net-next] bpf: s390: Fix build error caused by the struct bpf_array member name changed

2015-08-11 Thread Kaixu Xia
more generic) Reported-by: Wu Fengguang fengguang...@intel.com Signed-off-by: Kaixu Xia xiaka...@huawei.com --- arch/s390/net/bpf_jit_comp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index 9f4bbc0..eeda051 100644

[PATCH net-next] bpf: fix the bug 'struct bpf_array' has no member named 'prog' in s390 architecture

2015-08-10 Thread Kaixu Xia
'Kbuild test robot' sent me an email about a build error 'struct bpf_array' has no member named 'prog' in s390 architecture. This error is caused by commit: 2a36f0b92eb 638dd023870574eb471b1c56be9ad [656/692] bpf: Make the bpf _prog_array_map more generic. In this patch, the member 'prog' of

[PATCH v7 2/5] bpf: Make the bpf_prog_array_map more generic

2015-08-06 Thread Kaixu Xia
and add fewer lines of special code. Signed-off-by: Wang Nan wangn...@huawei.com Signed-off-by: Kaixu Xia xiaka...@huawei.com --- arch/x86/net/bpf_jit_comp.c | 6 ++-- include/linux/bpf.h | 8 +++-- kernel/bpf/arraymap.c | 80 +++-- kernel/bpf

[PATCH v7 5/5] samples/bpf: example of get selected PMU counter value

2015-08-06 Thread Kaixu Xia
This is a simple example and shows how to use the new ability to get the selected Hardware PMU counter value. Signed-off-by: Kaixu Xia xiaka...@huawei.com --- samples/bpf/Makefile | 4 +++ samples/bpf/bpf_helpers.h | 2 ++ samples/bpf/tracex6_kern.c | 26 ++ samples/bpf

[PATCH v7 1/5] perf: add the necessary core perf APIs when accessing events counters in eBPF programs

2015-08-06 Thread Kaixu Xia
accessing events counters in eBPF programs. The API perf_event_read_local() comes from Peter and I add the corresponding SOB. Signed-off-by: Kaixu Xia xiaka...@huawei.com Signed-off-by: Peter Zijlstra a.p.zijls...@chello.nl --- include/linux/perf_event.h | 10 ++ kernel/events/core.c

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

2015-08-06 Thread Kaixu Xia
According to the perf_event_map_fd and index, 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. Signed-off-by: Kaixu Xia xiaka...@huawei.com --- include/linux/bpf.h | 1 + include/uapi

[PATCH v7 0/5] bpf: Introduce the new ability of eBPF programs to access hardware PMU counter

2015-08-06 Thread Kaixu Xia
the selected hardware PMU conuter; Patch 5/5 gives a simple example. Kaixu Xia (4): perf: add the necessary core perf APIs when accessing events counters in eBPF programs bpf: Add new bpf map type to store the pointer to struct perf_event bpf: Implement function bpf_perf_event_read() that get

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

2015-08-06 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

[PATCH v6 2/4] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-08-04 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

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

2015-08-04 Thread Kaixu Xia
According to the perf_event_map_fd and index, 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. Signed-off-by: Kaixu Xia xiaka...@huawei.com --- include/linux/bpf.h| 1 + include

[PATCH v6 0/4] bpf: Introduce the new ability of eBPF programs to access hardware PMU counter

2015-08-04 Thread Kaixu Xia
to struct perf_event; Patch 3/4 implements function bpf_perf_event_read() that get the selected hardware PMU conuter; Patch 4/4 gives a simple example. Kaixu Xia (3): bpf: Add new bpf map type to store the pointer to struct perf_event bpf: Implement function bpf_perf_event_read() that get

[PATCH v6 4/4] samples/bpf: example of get selected PMU counter value

2015-08-04 Thread Kaixu Xia
This is a simple example and shows how to use the new ability to get the selected Hardware PMU counter value. Signed-off-by: Kaixu Xia xiaka...@huawei.com --- samples/bpf/Makefile | 4 +++ samples/bpf/bpf_helpers.h | 2 ++ samples/bpf/tracex6_kern.c | 26 ++ samples/bpf

[PATCH v6 1/4] bpf: Make the bpf_prog_array_map more generic

2015-08-04 Thread Kaixu Xia
and add fewer lines of special code. Signed-off-by: Wang Nan wangn...@huawei.com Signed-off-by: Kaixu Xia xiaka...@huawei.com --- arch/x86/net/bpf_jit_comp.c | 6 ++-- include/linux/bpf.h | 8 +++-- kernel/bpf/arraymap.c | 80 +++-- kernel/bpf

[PATCH v5 0/4] bpf: Introduce the new ability of eBPF programs to access hardware PMU counter

2015-07-31 Thread Kaixu Xia
() that get the selected hardware PMU conuter; Patch 4/4 gives a simple example. Kaixu Xia (3): bpf: Add new bpf map type to store the pointer to struct perf_event bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter samples/bpf: example of get

[PATCH v5 2/4] bpf: Add new bpf map type to store the pointer to struct perf_event

2015-07-31 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

[PATCH v5 4/4] samples/bpf: example of get selected PMU counter value

2015-07-31 Thread Kaixu Xia
This is a simple example and shows how to use the new ability to get the selected Hardware PMU counter value. Signed-off-by: Kaixu Xia xiaka...@huawei.com --- samples/bpf/Makefile | 4 +++ samples/bpf/bpf_helpers.h | 2 ++ samples/bpf/tracex6_kern.c | 26 ++ samples/bpf

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

2015-07-31 Thread Kaixu Xia
According to the perf_event_map_fd and index, 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. Signed-off-by: Kaixu Xia xiaka...@huawei.com --- include/linux/bpf.h| 1 + include

[PATCH v5 1/4] bpf: Make the bpf_prog_array_map more generic

2015-07-31 Thread Kaixu Xia
, buf=0078c010, size=512) dd-1051 [000] d...26.712704: : write(fd=1, buf=0078c010, size=512) ... Signed-off-by: Wang Nan wangn...@huawei.com Signed-off-by: Kaixu Xia xiaka...@huawei.com --- arch/x86/net/bpf_jit_comp.c | 6 ++-- include/linux/bpf.h | 8