Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1431450

[RFC PATCH v2 25/26] perf bpf: Implement run_ubpf_program

From He Kuang <hekuang@huawei.com>
Newsgroups linux.kernel
Subject [RFC PATCH v2 25/26] perf bpf: Implement run_ubpf_program
Date 2016-06-26 13:30 +0200
Message-ID <rOgqe-2jQ-31@gated-at.bofh.it> (permalink)
References <rOgqd-2jQ-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Fill up the run_ubpf_program slot by fetching the ubpf entry and call
__bpf_prog_run().

Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
---
 tools/perf/util/ubpf-hooks.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/ubpf-hooks.c b/tools/perf/util/ubpf-hooks.c
index 6ffe344..da19fab 100644
--- a/tools/perf/util/ubpf-hooks.c
+++ b/tools/perf/util/ubpf-hooks.c
@@ -8,12 +8,25 @@
 #include <asm/bug.h>
 #include <ubpf.h>
 #include "ubpf-hooks.h"
+#include "bpf-vm.h"
 #include "debug.h"
 
-static int run_ubpf_program(struct bpf_program *prog __maybe_unused,
-			    void *mem __maybe_unused, size_t len __maybe_unused)
+static int
+run_ubpf_program(struct bpf_program *prog, void *mem, size_t len)
 {
-	return 0;
+	struct ubpf_entry *entry;
+	int ret;
+
+	entry = bpf_program__vm(prog);
+	if (!entry) {
+		WARN_ONCE(!entry, "Unable to fetch entry from UBPF program\n");
+		return -EINVAL;
+	}
+
+	ret = __bpf_prog_run(mem, entry->insns, len);
+	pr_debug("program %s returns %d\n",
+		 bpf_program__title(prog, false), ret);
+	return ret;
 }
 
 static int
-- 
1.8.5.2

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[RFC PATCH v2 25/26] perf bpf: Implement run_ubpf_program He Kuang <hekuang@huawei.com> - 2016-06-26 13:30 +0200

csiph-web