mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: He Kuang <hekuang@huawei.com>
To: <paulus@samba.org>, <a.p.zijlstra@chello.nl>, <mingo@redhat.com>,
	<acme@kernel.org>, <namhyung@kernel.org>, <jolsa@kernel.org>,
	<dsahern@gmail.com>, <ast@plumgrid.com>, <daniel@iogearbox.net>,
	<brendan.d.gregg@gmail.com>, <masami.hiramatsu.pt@hitachi.com>
Cc: <wangnan0@huawei.com>, <lizefan@huawei.com>,
	<linux-kernel@vger.kernel.org>, <pi3orama@163.com>
Subject: [RFC PATCH 2/5] bpf: Pass trace_probe to bpf_prog for variable fetching
Date: Mon, 18 May 2015 05:30:44 +0000	[thread overview]
Message-ID: <1431927047-35144-3-git-send-email-hekuang@huawei.com> (raw)
In-Reply-To: <1431927047-35144-1-git-send-email-hekuang@huawei.com>

Add new structure bpf_pt_regs, which contains both original
'ctx'(pt_regs) and trabe_probe pointer, and pass this new pointer to bpf
prog for variable fetching.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 kernel/trace/trace_kprobe.c | 11 +++++++++--
 kernel/trace/trace_probe.h  |  5 +++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index d0ce590..cee0b28 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1141,8 +1141,15 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
 	int size, __size, dsize;
 	int rctx;
 
-	if (prog && !trace_call_bpf(prog, regs))
-		return;
+	if (prog) {
+		struct bpf_pt_regs bpf_pt_regs;
+
+		bpf_pt_regs.pt_regs = *regs;
+		bpf_pt_regs.tp = &tk->tp;
+
+		if (!trace_call_bpf(prog, &bpf_pt_regs))
+			return;
+	}
 
 	head = this_cpu_ptr(call->perf_events);
 	if (hlist_empty(head))
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
index ab283e1..5b1f12c 100644
--- a/kernel/trace/trace_probe.h
+++ b/kernel/trace/trace_probe.h
@@ -391,4 +391,9 @@ store_trace_args(int ent_size, struct trace_probe *tp, struct pt_regs *regs,
 	}
 }
 
+struct bpf_pt_regs {
+	struct pt_regs pt_regs;
+	struct trace_probe *tp;
+};
+
 extern int set_print_fmt(struct trace_probe *tp, bool is_return);
-- 
1.8.5.2


  parent reply	other threads:[~2015-05-18  5:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18  5:30 [RFC PATCH 0/5] Fetching local variables for bpf prog He Kuang
2015-05-18  5:30 ` [RFC PATCH 1/5] perf bpf: Add -k option for testing convenience He Kuang
2015-05-18  5:30 ` He Kuang [this message]
2015-05-18 19:43   ` [RFC PATCH 2/5] bpf: Pass trace_probe to bpf_prog for variable fetching Alexei Starovoitov
2015-05-18  5:30 ` [RFC PATCH 3/5] bpf: Add helper function for fetching variables at probe point He Kuang
2015-05-18 19:53   ` Alexei Starovoitov
2015-05-18  5:30 ` [RFC PATCH 4/5] samples/bpf: Add proper prefix to objects in Makefile He Kuang
2015-05-18 19:59   ` Alexei Starovoitov
2015-05-18  5:30 ` [RFC PATCH 5/5] samples/bpf: Add sample for testing bpf fetch args He Kuang
2015-05-18 23:08 ` [RFC PATCH 0/5] Fetching local variables for bpf prog Masami Hiramatsu

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=1431927047-35144-3-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=pi3orama@163.com \
    --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®