From: He Kuang <hekuang@huawei.com>
To: <wangnan0@huawei.com>, <paulus@samba.org>,
<a.p.zijlstra@chello.nl>, <mingo@redhat.com>, <acme@kernel.org>,
<namhyung@kernel.org>, <jolsa@kernel.org>, <ast@plumgrid.com>,
<masami.hiramatsu.pt@hitachi.com>, <dsahern@gmail.com>,
<brendan.d.gregg@gmail.com>, <daniel@iogearbox.net>
Cc: <lizefan@huawei.com>, <linux-kernel@vger.kernel.org>
Subject: [RFC PATCH v2 15/15] samples/bpf: Add sample for no-debuginfo case
Date: Sun, 24 May 2015 08:28:11 +0000 [thread overview]
Message-ID: <1432456091-73384-16-git-send-email-hekuang@huawei.com> (raw)
In-Reply-To: <1432456091-73384-1-git-send-email-hekuang@huawei.com>
Sample code for testing bpf fetch args without debuginfo.
Works as following steps:
$ perf bpf record --object /mnt/9p/sample_bpf_fetch_args_without_debug.o -- dd if=/dev/zero of=/mnt/data/test bs=4k count=3
show result in ringbuffer:
$ perf script
dd 1183 [000] 88000.240137: perf_bpf_probe:generic_perform_write: (ffffffff81130770) arg1=0xffff88007c36cb00 arg2=0xffff88007c167e70 arg3=0x0 arg4=0x0 arg5=0x55617215 arg6=0x1839010
dd 1183 [000] 88000.240137: perf_bpf_probe:generic_perform_write: (ffffffff81130770) arg1=0xffff88007c36cb00 arg2=0xffff88007c167e70 arg3=0x1000 arg4=0x0 arg5=0x55617215 arg6=0x1839010
dd 1183 [000] 88000.240137: perf_bpf_probe:generic_perform_write: (ffffffff81130770) arg1=0xffff88007c36cb00 arg2=0xffff88007c167e70 arg3=0x2000 arg4=0x0 arg5=0x55617215 arg6=0x1839010
dd 1183 [000] 88000.240137: perf_bpf_probe:submit_bio: (ffffffff81310ca0) arg1=0x1 arg2=0xffff88007c9d8000 arg3=0x8b9 arg4=0x8ba arg5=0x1b8e0 arg6=0xffff88007fc1b8e0
show result in bpf prog:
$ cat /sys/kernel/debug/tracing/trace | grep dd-
dd-1183 [000] d... 88072.038971: : generic_perform_write: file=ffff88007c36cb00, i=ffff88007c167e70, pos=0
dd-1183 [000] d... 88072.039625: : generic_perform_write: file=ffff88007c36cb00, i=ffff88007c167e70, pos=4096
dd-1183 [000] d... 88072.039833: : generic_perform_write: file=ffff88007c36cb00, i=ffff88007c167e70, pos=8192
dd-1183 [000] d... 88072.040533: : submit_bio rw=1, bio=ffff88007c9d8000
Signed-off-by: He Kuang <hekuang@huawei.com>
---
samples/bpf/Makefile | 1 +
samples/bpf/sample_bpf_fetch_args_without_debug.c | 49 +++++++++++++++++++++++
2 files changed, 50 insertions(+)
create mode 100644 samples/bpf/sample_bpf_fetch_args_without_debug.c
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index dc0b0e8..282c959 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -31,6 +31,7 @@ always += tracex3_kern.o
always += tracex4_kern.o
always += tcbpf1_kern.o
always += sample_bpf_fetch_args.o
+always += sample_bpf_fetch_args_without_debug.o
HOSTCFLAGS += -I$(objtree)/usr/include
diff --git a/samples/bpf/sample_bpf_fetch_args_without_debug.c b/samples/bpf/sample_bpf_fetch_args_without_debug.c
new file mode 100644
index 0000000..69519ed
--- /dev/null
+++ b/samples/bpf/sample_bpf_fetch_args_without_debug.c
@@ -0,0 +1,49 @@
+/*
+ Sample code for bpf_fetch_args() without debuginfo.
+*/
+
+#include <linux/writeback.h>
+#include <linux/blkdev.h>
+
+#include <uapi/linux/bpf.h>
+#include <linux/version.h>
+#include "bpf_helpers.h"
+
+/*
+ * Prototype:
+ * ssize_t generic_perform_write(struct file *file,
+ * struct iov_iter *i, loff_t pos)
+ */
+SEC("generic_perform_write=generic_perform_write $params")
+int NODE_generic_perform_write(struct pt_regs *ctx,
+ void *file,
+ void *i,
+ void *pos)
+{
+ char fmt[] = "generic_perform_write: file=%p, i=%p, pos=%lu\n";
+
+ bpf_trace_printk(fmt, sizeof(fmt),
+ file, i, (unsigned long)pos);
+
+ return 1;
+}
+
+/*
+ * Prototype:
+ * void submit_bio(int rw, struct bio *bio)
+ */
+SEC("submit_bio=submit_bio $params")
+int NODE_submit_bio(struct pt_regs *ctx,
+ void *rw,
+ void *bio)
+{
+ char fmt[] = "submit_bio rw=%d, bio=%p\n";
+
+ bpf_trace_printk(fmt, sizeof(fmt),
+ (int)rw, bio);
+
+ return 1;
+}
+
+char _license[] SEC("license") = "GPL";
+u32 _version SEC("version") = LINUX_VERSION_CODE;
--
1.8.5.2
next prev parent reply other threads:[~2015-05-24 8:29 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-24 8:27 [RFC PATCH v2 00/15] perf bpf: Probing with local variable He Kuang
2015-05-24 8:27 ` [RFC PATCH v2 01/15] perf tools: Add lib/bpf to cscope target list He Kuang
2015-05-24 8:27 ` [RFC PATCH v2 02/15] perf bpf: Support custom vmlinux path He Kuang
2015-05-24 8:27 ` [RFC PATCH v2 03/15] perf bpf: Save pt_regs info from debuginfo He Kuang
2015-05-24 13:31 ` Masami Hiramatsu
2015-05-25 7:38 ` He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 04/15] perf tools: Add functions to get calling regs He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 05/15] perf tools: Add pt_regs offsets and calling regs for x86 He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 06/15] bpf tools: Add headers for generating bpf bytecode He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 07/15] bpf tools: Convert arglist to bpf prologue He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 08/15] bpf tools: Fetch calling regs to bpf arglist He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 09/15] perf probe: Support $params without debuginfo He Kuang
2015-05-24 8:49 ` Masami Hiramatsu
2015-05-25 8:33 ` He Kuang
2015-05-25 12:22 ` Masami Hiramatsu
2015-05-25 12:46 ` Arnaldo Carvalho de Melo
2015-05-25 13:06 ` Masami Hiramatsu
2015-05-26 17:50 ` Alexei Starovoitov
2015-05-27 2:27 ` He Kuang
2015-05-27 11:43 ` Masami Hiramatsu
2015-05-27 15:30 ` Alexei Starovoitov
2015-05-28 13:01 ` He Kuang
2015-05-28 18:10 ` Alexei Starovoitov
2015-05-29 6:30 ` He Kuang
2015-05-29 23:55 ` Masami Hiramatsu
2015-05-30 1:27 ` Alexei Starovoitov
2015-05-30 7:01 ` Masami Hiramatsu
2015-05-24 8:28 ` [RFC PATCH v2 10/15] perf bpf: Process debuginfo for generating bpf prologue He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 11/15] perf bpf: Synthesize vars to generate " He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 12/15] perf bpf: Generate bpf prologue without debuginfo He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 13/15] perf bpf: Combine bpf prologue and bpf prog He Kuang
2015-05-24 8:28 ` [RFC PATCH v2 14/15] samples/bpf: Add sample for testing bpf fetch args He Kuang
2015-05-24 8:28 ` He Kuang [this message]
2015-05-26 17:53 ` [RFC PATCH v2 15/15] samples/bpf: Add sample for no-debuginfo case Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432456091-73384-16-git-send-email-hekuang@huawei.com \
--to=hekuang@huawei.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ast@plumgrid.com \
--cc=brendan.d.gregg@gmail.com \
--cc=daniel@iogearbox.net \
--cc=dsahern@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®