&my_cycles_map, 0, 3);
return 0;
}
SEC("exit=sys_write%return")
int bpf_prog_2(struct pt_regs *ctx)
{
bpf_perf_event_control(&my_cycles_map, 0, 2);
return 0;
}
Consider control sampling in function level, we have to set
a high sample frequency to du
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
---
include/linux/perf_event.h | 1 +
include/uapi/linux/bpf.h| 11
include/uapi/linux/perf_event.h | 3 +-
kernel/bpf/
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
---
include/linux/perf_event.h | 1 +
include/uapi/linux/bpf.h| 19 +++
include/uapi/linux/perf_event.h | 3 ++-
kernel/bpf/
f_event_control(&my_cycles_map, 0, 3);
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 stored in PERF_EVENT_ARRAY
p, 32, 0);
return 0;
}
SEC("exit=sys_write%return")
int bpf_prog_2(struct pt_regs *ctx)
{
bpf_perf_event_dump_control(&my_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
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
---
kernel/trace/bpf_trace.c | 20 ++--
1 file changed, 18 insertions(+), 2 deletion
perf_event on current cpu.
Signed-off-by: Kaixu Xia
---
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| 13
kernel/trace/bpf_trace.c
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
-
t;exit=sys_write%return")
int bpf_prog_2(struct pt_regs *ctx)
{
bpf_perf_event_sample_control(&my_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
perf_event on current cpu.
Signed-off-by: Kaixu Xia
---
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| 13 +
kernel/trace
le_enable(&my_cycles_map);
return 0;
}
SEC("exit=sys_write%return")
int bpf_prog_2(struct pt_regs *ctx)
{
bpf_perf_event_sample_disable(&my_cycles_map);
return 0;
}
Kaixu Xia (2):
perf: Add the flag sample_disable not to output data o
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
---
include/linux/bpf.h | 2 ++
include/uapi/linux/bpf.h | 2 ++
kernel/bpf/verifier.c| 4 +++-
kernel/trace/bpf_trace.c | 34
igned-off-by: Kaixu Xia
---
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..25e073d 100644
--- a/in
sshd-683 [000] d..1 131.429378: : CPU-0 222561024
...
Signed-off-by: Kaixu Xia
---
samples/bpf/tracex6_kern.c | 1 +
samples/bpf/tracex6_user.c | 22 +-
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/samples/bpf/tracex6_kern.c b
So this patch fixes it.
Fixes: 2a36f0b92eb6 ("bpf: Make the bpf_prog_array_map more generic")
Reported-by: Wu Fengguang
Signed-off-by: Kaixu Xia
---
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_c
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
---
arch/s390/net/bpf_jit_c
'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 stru
erf_event;
Patch 4/5 implements function bpf_perf_event_read() that get 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 sto
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
Signed-off-by: Peter Zijlstra
---
include/linux/perf_event.h | 10 ++
kernel/events/core.c | 78
of special code.
Signed-off-by: Wang Nan
Signed-off-by: Kaixu Xia
---
arch/x86/net/bpf_jit_comp.c | 6 ++--
include/linux/bpf.h | 8 +++--
kernel/bpf/arraymap.c | 80 +++--
kernel/bpf/core.c | 2 +-
kernel/bpf/syscall.c
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
---
samples/bpf/Makefile | 4 +++
samples/bpf/bpf_helpers.h | 2 ++
samples/bpf/tracex6_kern.c | 26 ++
samples/bpf/tracex6_user.c | 68
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
---
include/linux/bpf.h | 1 +
include/uapi/linux/bpf.h | 1
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/l
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/l
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
---
include/linux/bpf.h| 1 +
include/linux/perf_event.h | 2
h 2/4 introduces a new bpf map type. This map only stores the
pointer 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 st
of special code.
Signed-off-by: Wang Nan
Signed-off-by: Kaixu Xia
---
arch/x86/net/bpf_jit_comp.c | 6 ++--
include/linux/bpf.h | 8 +++--
kernel/bpf/arraymap.c | 80 +++--
kernel/bpf/core.c | 2 +-
kernel/bpf/syscall.c
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
---
samples/bpf/Makefile | 4 +++
samples/bpf/bpf_helpers.h | 2 ++
samples/bpf/tracex6_kern.c | 26 ++
samples/bpf/tracex6_user.c | 68
,
size=512)
dd-1051 [000] d...26.712704: : write(fd=1, buf=0078c010,
size=512)
...
Signed-off-by: Wang Nan
Signed-off-by: Kaixu Xia
---
arch/x86/net/bpf_jit_comp.c | 6 ++--
include/linux/bpf.h | 8 +++--
kernel/bpf/arraymap.c | 80
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
---
samples/bpf/Makefile | 4 +++
samples/bpf/bpf_helpers.h | 2 ++
samples/bpf/tracex6_kern.c | 26 ++
samples/bpf/tracex6_user.c | 68
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
---
include/linux/bpf.h| 1 +
include/linux/perf_event.h | 12
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/l
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 the sele
33 matches
Mail list logo