From: Feng zhou <zhoufeng.zf@bytedance.com>
To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
john.fastabend@gmail.com, kpsingh@kernel.org,
rostedt@goodmis.org, mingo@redhat.com, jolsa@kernel.org,
davemarchevsky@fb.com, joannekoong@fb.com, geliang.tang@suse.com
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com,
songmuchun@bytedance.com, wangdongdong.6@bytedance.com,
cong.wang@bytedance.com, zhouchengming@bytedance.com,
zhoufeng.zf@bytedance.com, yosryahmed@google.com
Subject: [PATCH bpf-next v3 0/2] Introduce access remote cpu elem support in BPF percpu map
Date: Fri, 13 May 2022 14:39:50 +0800 [thread overview]
Message-ID: <20220513063952.41794-1-zhoufeng.zf@bytedance.com> (raw)
From: Feng Zhou <zhoufeng.zf@bytedance.com>
Trace some functions, such as enqueue_task_fair, need to access the
corresponding cpu, not the current cpu, and bpf_map_lookup_elem percpu map
cannot do it. So add bpf_map_lookup_percpu_elem to accomplish it for
percpu_array_map, percpu_hash_map, lru_percpu_hash_map.
Changelog:
----------
v2->v3: Addressed comments from Andrii Nakryiko.
- use /* */ instead of //
- use libbpf_num_possible_cpus() instead of sysconf(_SC_NPROCESSORS_ONLN)
- use 8 bytes for value size
- fix memory leak
- use ASSERT_EQ instead of ASSERT_OK
- add bpf_loop to fetch values on each possible CPU
some details in here:
https://lore.kernel.org/lkml/20220511093854.411-1-zhoufeng.zf@bytedance.com/T/
v1->v2: Addressed comments from Alexei Starovoitov.
- add a selftest for bpf_map_lookup_percpu_elem.
Feng Zhou (2):
bpf: add bpf_map_lookup_percpu_elem for percpu map
selftests/bpf: add test case for bpf_map_lookup_percpu_elem
include/linux/bpf.h | 2 +
include/uapi/linux/bpf.h | 9 +++
kernel/bpf/arraymap.c | 15 ++++
kernel/bpf/core.c | 1 +
kernel/bpf/hashtab.c | 32 +++++++++
kernel/bpf/helpers.c | 18 +++++
kernel/bpf/verifier.c | 17 ++++-
kernel/trace/bpf_trace.c | 2 +
tools/include/uapi/linux/bpf.h | 9 +++
.../bpf/prog_tests/map_lookup_percpu_elem.c | 59 +++++++++++++++
.../bpf/progs/test_map_lookup_percpu_elem.c | 71 +++++++++++++++++++
11 files changed, 233 insertions(+), 2 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/map_lookup_percpu_elem.c
create mode 100644 tools/testing/selftests/bpf/progs/test_map_lookup_percpu_elem.c
--
2.20.1
next reply other threads:[~2022-05-13 6:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 6:39 Feng zhou [this message]
2022-05-13 6:39 ` [PATCH bpf-next v3 1/2] bpf: add bpf_map_lookup_percpu_elem for " Feng zhou
2022-05-13 6:39 ` [PATCH bpf-next v3 2/2] selftests/bpf: add test case for bpf_map_lookup_percpu_elem Feng zhou
2022-05-13 15:01 ` [PATCH bpf-next v3 0/2] Introduce access remote cpu elem support in BPF percpu map Daniel Borkmann
2022-05-16 1:55 ` [External] " Feng Zhou
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=20220513063952.41794-1-zhoufeng.zf@bytedance.com \
--to=zhoufeng.zf@bytedance.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=daniel@iogearbox.net \
--cc=davemarchevsky@fb.com \
--cc=duanxiongchun@bytedance.com \
--cc=geliang.tang@suse.com \
--cc=joannekoong@fb.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=songmuchun@bytedance.com \
--cc=wangdongdong.6@bytedance.com \
--cc=yhs@fb.com \
--cc=yosryahmed@google.com \
--cc=zhouchengming@bytedance.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®