Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1205811 > unrolled thread
| Started by | Kaixu Xia <xiakaixu@huawei.com> |
|---|---|
| First post | 2015-08-12 11:40 +0200 |
| Last post | 2015-08-13 01:40 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH net-next] bpf: fix build warnings and add function read_trace_pipe() Kaixu Xia <xiakaixu@huawei.com> - 2015-08-12 11:40 +0200
Re: [PATCH net-next] bpf: fix build warnings and add function read_trace_pipe() Alexei Starovoitov <ast@plumgrid.com> - 2015-08-12 18:30 +0200
Re: [PATCH net-next] bpf: fix build warnings and add function read_trace_pipe() David Miller <davem@davemloft.net> - 2015-08-13 01:40 +0200
| From | Kaixu Xia <xiakaixu@huawei.com> |
|---|---|
| Date | 2015-08-12 11:40 +0200 |
| Subject | [PATCH net-next] bpf: fix build warnings and add function read_trace_pipe() |
| Message-ID | <pWAFQ-px-1@gated-at.bofh.it> |
There are two improvements in this patch:
1. Fix the build warnings;
2. Add function read_trace_pipe() to print the result on
the screen;
Before this patch, we can get the result through /sys/kernel/de
bug/tracing/trace_pipe and get nothing on the screen.
By applying this patch, the result can be printed on the screen.
$ ./tracex6
...
tracex6-705 [003] d..1 131.428593: : CPU-3 19981414
sshd-683 [000] d..1 131.428727: : CPU-0 221682321
sshd-683 [000] d..1 131.428821: : CPU-0 221808766
sshd-683 [000] d..1 131.428950: : CPU-0 221982984
sshd-683 [000] d..1 131.429045: : CPU-0 222111851
tracex6-705 [003] d..1 131.429168: : CPU-3 20757551
sshd-683 [000] d..1 131.429170: : CPU-0 222281240
sshd-683 [000] d..1 131.429261: : CPU-0 222403340
sshd-683 [000] d..1 131.429378: : CPU-0 222561024
...
Signed-off-by: Kaixu Xia <xiakaixu@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/tracex6_kern.c b/samples/bpf/tracex6_kern.c
index 23d1cff..be479c4 100644
--- a/samples/bpf/tracex6_kern.c
+++ b/samples/bpf/tracex6_kern.c
@@ -1,3 +1,4 @@
+#include <linux/ptrace.h>
#include <linux/version.h>
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
diff --git a/samples/bpf/tracex6_user.c b/samples/bpf/tracex6_user.c
index 928f05e..8ea4976 100644
--- a/samples/bpf/tracex6_user.c
+++ b/samples/bpf/tracex6_user.c
@@ -17,8 +17,7 @@ static void test_bpf_perf_event(void)
{
int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
int *pmu_fd = malloc(nr_cpus * sizeof(int));
- unsigned long value;
- int i;
+ int status, i;
struct perf_event_attr attr_insn_pmu = {
.freq = 0,
@@ -32,22 +31,26 @@ static void test_bpf_perf_event(void)
for (i = 0; i < nr_cpus; i++) {
pmu_fd[i] = perf_event_open(&attr_insn_pmu, -1/*pid*/, i/*cpu*/, -1/*group_fd*/, 0);
- if (pmu_fd[i] < 0)
+ if (pmu_fd[i] < 0) {
printf("event syscall failed\n");
+ goto exit;
+ }
bpf_update_elem(map_fd[0], &i, &pmu_fd[i], BPF_ANY);
ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE, 0);
}
- system("ls");
- system("pwd");
- system("sleep 2");
+ status = system("ls > /dev/null");
+ if (status)
+ goto exit;
+ status = system("sleep 2");
+ if (status)
+ goto exit;
+exit:
for (i = 0; i < nr_cpus; i++)
close(pmu_fd[i]);
-
- close(map_fd);
-
+ close(map_fd[0]);
free(pmu_fd);
}
@@ -63,6 +66,7 @@ int main(int argc, char **argv)
}
test_bpf_perf_event();
+ read_trace_pipe();
return 0;
}
--
1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Alexei Starovoitov <ast@plumgrid.com> |
|---|---|
| Date | 2015-08-12 18:30 +0200 |
| Subject | Re: [PATCH net-next] bpf: fix build warnings and add function read_trace_pipe() |
| Message-ID | <pWH4B-1gT-13@gated-at.bofh.it> |
| In reply to | #1205811 |
On 8/12/15 2:37 AM, Kaixu Xia wrote: > There are two improvements in this patch: > 1. Fix the build warnings; > 2. Add function read_trace_pipe() to print the result on > the screen; > > Before this patch, we can get the result through /sys/kernel/de > bug/tracing/trace_pipe and get nothing on the screen. > By applying this patch, the result can be printed on the screen. > $ ./tracex6 > ... > tracex6-705 [003] d..1 131.428593: : CPU-3 19981414 > sshd-683 [000] d..1 131.428727: : CPU-0 221682321 > sshd-683 [000] d..1 131.428821: : CPU-0 221808766 > sshd-683 [000] d..1 131.428950: : CPU-0 221982984 > sshd-683 [000] d..1 131.429045: : CPU-0 222111851 > tracex6-705 [003] d..1 131.429168: : CPU-3 20757551 > sshd-683 [000] d..1 131.429170: : CPU-0 222281240 > sshd-683 [000] d..1 131.429261: : CPU-0 222403340 > sshd-683 [000] d..1 131.429378: : CPU-0 222561024 > ... > > Signed-off-by: Kaixu Xia<xiakaixu@huawei.com> thanks! Acked-by: Alexei Starovoitov <ast@plumgrid.com> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2015-08-13 01:40 +0200 |
| Subject | Re: [PATCH net-next] bpf: fix build warnings and add function read_trace_pipe() |
| Message-ID | <pWNMK-2tG-13@gated-at.bofh.it> |
| In reply to | #1205811 |
From: Kaixu Xia <xiakaixu@huawei.com> Date: Wed, 12 Aug 2015 09:37:53 +0000 > There are two improvements in this patch: > 1. Fix the build warnings; > 2. Add function read_trace_pipe() to print the result on > the screen; > > Before this patch, we can get the result through /sys/kernel/de > bug/tracing/trace_pipe and get nothing on the screen. > By applying this patch, the result can be printed on the screen. > $ ./tracex6 > ... > tracex6-705 [003] d..1 131.428593: : CPU-3 19981414 > sshd-683 [000] d..1 131.428727: : CPU-0 221682321 > sshd-683 [000] d..1 131.428821: : CPU-0 221808766 > sshd-683 [000] d..1 131.428950: : CPU-0 221982984 > sshd-683 [000] d..1 131.429045: : CPU-0 222111851 > tracex6-705 [003] d..1 131.429168: : CPU-3 20757551 > sshd-683 [000] d..1 131.429170: : CPU-0 222281240 > sshd-683 [000] d..1 131.429261: : CPU-0 222403340 > sshd-683 [000] d..1 131.429378: : CPU-0 222561024 > ... > > Signed-off-by: Kaixu Xia <xiakaixu@huawei.com> Applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web