Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752191AbbERFcG (ORCPT ); Mon, 18 May 2015 01:32:06 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:34900 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751946AbbERFbi (ORCPT ); Mon, 18 May 2015 01:31:38 -0400 From: He Kuang To: , , , , , , , , , , CC: , , , Subject: [RFC PATCH 2/5] bpf: Pass trace_probe to bpf_prog for variable fetching Date: Mon, 18 May 2015 05:30:44 +0000 Message-ID: <1431927047-35144-3-git-send-email-hekuang@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1431927047-35144-1-git-send-email-hekuang@huawei.com> References: <1431927047-35144-1-git-send-email-hekuang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.210] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1619 Lines: 54 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/