From: Jiri Olsa <jolsa@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Cc: lkml <linux-kernel@vger.kernel.org>,
netdev@vger.kernel.org, linux-kbuild@vger.kernel.org,
Quentin Monnet <quentin.monnet@netronome.com>,
Eugene Syromiatnikov <esyr@redhat.com>,
Jiri Benc <jbenc@redhat.com>,
Stanislav Kozina <skozina@redhat.com>,
Jerome Marchand <jmarchan@redhat.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
Michal Marek <michal.lkml@markovi.net>,
Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH 9/9] perf tools: The buildid usage in example eBPF program
Date: Thu, 5 Apr 2018 17:16:45 +0200 [thread overview]
Message-ID: <20180405151645.19130-10-jolsa@kernel.org> (raw)
In-Reply-To: <20180405151645.19130-1-jolsa@kernel.org>
The bpf-samples/bpf-stdout-example.c demonstrates how to put the
buildid data into eBPF program.
Link: http://lkml.kernel.org/n/tip-dq97ddil7h3qbvphbbo8p08c@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/bpf-samples/bpf-stdout-example.c | 42 +++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 tools/perf/bpf-samples/bpf-stdout-example.c
diff --git a/tools/perf/bpf-samples/bpf-stdout-example.c b/tools/perf/bpf-samples/bpf-stdout-example.c
new file mode 100644
index 000000000000..60783442bd5c
--- /dev/null
+++ b/tools/perf/bpf-samples/bpf-stdout-example.c
@@ -0,0 +1,42 @@
+#include <uapi/linux/bpf.h>
+#include <linux/buildid.h>
+
+#define SEC(NAME) __attribute__((section(NAME), used))
+
+char _license[] SEC("license") = "GPL";
+int _version SEC("version") = LINUX_VERSION_CODE;
+char _buildid[] SEC("buildid") = LINUX_BUILDID_DATA;
+
+static unsigned long long (*bpf_get_smp_processor_id)(void) =
+ (void *) BPF_FUNC_get_smp_processor_id;
+static int (*bpf_perf_event_output)(void *ctx, void *map,
+ unsigned long long flags, void *data,
+ int size) =
+ (void *) BPF_FUNC_perf_event_output;
+
+struct bpf_map_def {
+ unsigned int type;
+ unsigned int key_size;
+ unsigned int value_size;
+ unsigned int max_entries;
+ unsigned int map_flags;
+ unsigned int inner_map_idx;
+ unsigned int numa_node;
+};
+
+struct bpf_map_def SEC("maps") __bpf_stdout__ = {
+ .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
+ .key_size = sizeof(int),
+ .value_size = sizeof(u32),
+ .max_entries = __NR_CPUS__,
+};
+
+SEC("probe=sys_read")
+int func(void *ctx)
+{
+ char output_str[] = "Raise a BPF event!";
+
+ bpf_perf_event_output(ctx, &__bpf_stdout__, bpf_get_smp_processor_id(),
+ &output_str, sizeof(output_str));
+ return 0;
+}
--
2.13.6
next prev parent reply other threads:[~2018-04-05 15:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-05 15:16 [RFC 0/9] bpf: Add buildid check support Jiri Olsa
2018-04-05 15:16 ` [PATCH 1/9] perf tools: Make read_build_id function public Jiri Olsa
2018-04-05 15:16 ` [PATCH 2/9] perf tools: Add fetch_kernel_buildid function Jiri Olsa
2018-04-05 15:16 ` [PATCH 3/9] kbuild: Do not pass arguments to link-vmlinux.sh Jiri Olsa
2018-04-05 15:50 ` Masahiro Yamada
2018-04-05 18:59 ` Jiri Olsa
2018-04-06 0:59 ` Masahiro Yamada
2018-04-06 16:54 ` Jiri Olsa
2018-04-05 15:16 ` [PATCH 4/9] kbuild: Add filechk2 function Jiri Olsa
2018-04-05 15:16 ` [PATCH 5/9] bpf: Add CONFIG_BUILDID_H option Jiri Olsa
2018-04-05 15:16 ` [PATCH 6/9] bpf: Add CONFIG_BPF_BUILDID_CHECK option Jiri Olsa
2018-04-05 15:16 ` [PATCH 7/9] libbpf: Synchronize uapi bpf.h header Jiri Olsa
2018-04-05 15:16 ` [PATCH 8/9] libbpf: Add support to attach buildid to program load Jiri Olsa
2018-04-05 15:16 ` Jiri Olsa [this message]
2018-04-06 1:37 ` [RFC 0/9] bpf: Add buildid check support Alexei Starovoitov
2018-04-06 15:07 ` Jiri Olsa
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=20180405151645.19130-10-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=acme@redhat.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=esyr@redhat.com \
--cc=jbenc@redhat.com \
--cc=jkosina@suse.cz \
--cc=jmarchan@redhat.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=netdev@vger.kernel.org \
--cc=quentin.monnet@netronome.com \
--cc=skozina@redhat.com \
--cc=yamada.masahiro@socionext.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;
as well as URLs for NNTP newsgroup(s).