[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1466940078-65581-18-git-send-email-hekuang@huawei.com>
Date: Sun, 26 Jun 2016 11:21:09 +0000
From: He Kuang <hekuang@...wei.com>
To: <acme@...nel.org>, <peterz@...radead.org>, <mingo@...hat.com>,
<jolsa@...hat.com>, <brendan.d.gregg@...il.com>, <ast@...nel.org>,
<alexander.shishkin@...ux.intel.com>, <wangnan0@...wei.com>,
<hekuang@...wei.com>
CC: <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH v2 17/26] perf bpf: Add methods to set/check ubpf engine for bpf programs
Add methods to set ubpf engine for a bpf program and to check whether
a program's engine is ubpf.
Signed-off-by: He Kuang <hekuang@...wei.com>
Signed-off-by: Wang Nan <wangnan0@...wei.com>
---
tools/lib/bpf/engine-ubpf.c | 12 ++++++++++++
tools/lib/bpf/libbpf.h | 17 +++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/tools/lib/bpf/engine-ubpf.c b/tools/lib/bpf/engine-ubpf.c
index 0ab3310..9a0b425 100644
--- a/tools/lib/bpf/engine-ubpf.c
+++ b/tools/lib/bpf/engine-ubpf.c
@@ -95,3 +95,15 @@ struct bpf_engine uengine = {
.unload = engine__unload,
.get_nth = engine__get_nth,
};
+
+int bpf_program__set_ubpf(struct bpf_program *prog)
+{
+ prog->engine = &uengine;
+
+ return 0;
+}
+
+bool bpf_program__is_ubpf(struct bpf_program *prog)
+{
+ return prog->engine == &uengine;
+}
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index b0e6c68..e01ab8e 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -27,6 +27,7 @@ enum libbpf_errno {
LIBBPF_ERRNO__PROG2BIG, /* Program too big */
LIBBPF_ERRNO__KVER, /* Incorrect kernel version */
LIBBPF_ERRNO__LOADUBPF, /* Failed to load user space BPF program */
+ LIBBPF_ERRNO__NOUBPF,/* UBPF support is not compiled */
__LIBBPF_ERRNO__END,
};
@@ -192,4 +193,20 @@ struct ubpf_entry {
struct bpf_insn *insns;
};
+#ifdef HAVE_UBPF_SUPPORT
+int bpf_program__set_ubpf(struct bpf_program *prog);
+bool bpf_program__is_ubpf(struct bpf_program *prog);
+#else
+static inline int
+bpf_program__set_ubpf(struct bpf_program *prog __maybe_unused)
+{
+ return -LIBBPF_ERRNO__NOUBPF;
+}
+static inline bool
+bpf_program__is_ubpf(struct bpf_program *prog __maybe_unused)
+{
+ return false;
+}
+#endif
+
#endif
--
1.8.5.2
Powered by blists - more mailing lists