LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Daniel Xu <dxu@dxuuu.xyz>
To: bpf@vger.kernel.org, yhs@fb.com, andriin@fb.com
Cc: Daniel Xu <dxu@dxuuu.xyz>,
kernel-team@fb.com, linux-kernel@vger.kernel.org
Subject: [PATCH bpf-next v2 3/5] bpf: Extend bpf_base_func_proto helpers with bpf_get_current_task_btf()
Date: Mon, 23 Aug 2021 19:43:48 -0700 [thread overview]
Message-ID: <f99870ed5f834c9803d73b3476f8272b1bb987c0.1629772842.git.dxu@dxuuu.xyz> (raw)
In-Reply-To: <cover.1629772842.git.dxu@dxuuu.xyz>
bpf_get_current_task() is already supported so it's natural to also
include the _btf() variant for btf-powered helpers.
This is required for non-tracing progs to use bpf_task_pt_regs() in the
next commit.
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
kernel/bpf/helpers.c | 3 +++
kernel/trace/bpf_trace.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 4e8540716187..609674f409ed 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -1322,6 +1322,7 @@ void bpf_timer_cancel_and_free(void *val)
}
const struct bpf_func_proto bpf_get_current_task_proto __weak;
+const struct bpf_func_proto bpf_get_current_task_btf_proto __weak;
const struct bpf_func_proto bpf_probe_read_user_proto __weak;
const struct bpf_func_proto bpf_probe_read_user_str_proto __weak;
const struct bpf_func_proto bpf_probe_read_kernel_proto __weak;
@@ -1407,6 +1408,8 @@ bpf_base_func_proto(enum bpf_func_id func_id)
return bpf_get_trace_printk_proto();
case BPF_FUNC_get_current_task:
return &bpf_get_current_task_proto;
+ case BPF_FUNC_get_current_task_btf:
+ return &bpf_get_current_task_btf_proto;
case BPF_FUNC_probe_read_user:
return &bpf_probe_read_user_proto;
case BPF_FUNC_probe_read_kernel:
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 50d055fc2327..4e54f3dc209f 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -716,7 +716,7 @@ BPF_CALL_0(bpf_get_current_task_btf)
BTF_ID_LIST_GLOBAL_SINGLE(btf_task_struct_ids, struct, task_struct)
-static const struct bpf_func_proto bpf_get_current_task_btf_proto = {
+const struct bpf_func_proto bpf_get_current_task_btf_proto = {
.func = bpf_get_current_task_btf,
.gpl_only = true,
.ret_type = RET_PTR_TO_BTF_ID,
--
2.33.0
next prev parent reply other threads:[~2021-08-24 2:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 2:43 [PATCH bpf-next v2 0/5] bpf: Add bpf_task_pt_regs() helper Daniel Xu
2021-08-24 2:43 ` [PATCH bpf-next v2 1/5] bpf: Add BTF_ID_LIST_GLOBAL_SINGLE macro Daniel Xu
2021-08-24 2:43 ` [PATCH bpf-next v2 2/5] bpf: Consolidate task_struct BTF_ID declarations Daniel Xu
2021-08-24 2:43 ` Daniel Xu [this message]
2021-08-24 2:43 ` [PATCH bpf-next v2 4/5] bpf: Add bpf_task_pt_regs() helper Daniel Xu
2021-08-24 2:43 ` [PATCH bpf-next v2 5/5] bpf: selftests: Add bpf_task_pt_regs() selftest Daniel Xu
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=f99870ed5f834c9803d73b3476f8272b1bb987c0.1629772842.git.dxu@dxuuu.xyz \
--to=dxu@dxuuu.xyz \
--cc=andriin@fb.com \
--cc=bpf@vger.kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yhs@fb.com \
--subject='Re: [PATCH bpf-next v2 3/5] bpf: Extend bpf_base_func_proto helpers with bpf_get_current_task_btf()' \
/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
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).