From: Hui Su <sh_def@163.com>
To: bpf@vger.kernel.org
Cc: qmo@kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
linux-kernel@vger.kernel.org, Hui Su <sh_def@163.com>
Subject: [PATCH bpf-next v3 0/2] bpftool: Fix sparse CPU IDs
Date: Wed, 23 Sep 2026 09:42:41 +0900 [thread overview]
Message-ID: <20260923004243.969919-1-sh_def@163.com> (raw)
bpftool currently assumes that possible CPU IDs are dense. This is not
true when the possible CPU mask itself is sparse, such as 0,2-3. In that
case, per-CPU map output labels and prog profile event-array keys can
refer to the wrong logical CPUs.
The first patch keeps dense per-CPU buffer slots separate from logical CPU
IDs when printing per-CPU map values. The parsed CPU count is passed
together with the logical CPU IDs so that output labels and loop bounds use
the same possible-CPU mask.
The second patch applies the same distinction to prog profile. Userspace
keeps a compact CPU count for per-CPU result buffers, while perf events are
created for the actual logical CPU IDs and PERF_EVENT_ARRAY keys use the
logical CPU ID span. The current per-CPU perf event grouping in bpf-next is
preserved.
Changes in v3:
- Rebase the series onto bpf-next/master as requested by Andrii.
- Adapt the prog profile fix to current bpf-next while preserving its
per-CPU perf event grouping and scaled-value accounting.
- Pass the parsed CPU count through the per-CPU map output helpers.
- Match the existing bpftool memory-allocation error style.
- Pass profile_cpu_ids directly to get_possible_cpu_ids().
- Move testing details from individual patches to the cover letter.
Previous versions:
v2: https://lore.kernel.org/lkml/20260918102052.1247819-1-sh_def@163.com/
Testing:
- PASS: Host and ARM64 bpftool builds, bpftool Documentation build, bash
syntax, and diff checks.
- PASS: ARM64 QEMU with a synthetic possible/present/online mask of 0,2-3;
plain, JSON, and BTF per-CPU map output reported CPUs 0,2,3, and prog
profile reached perf_event_open for CPUs 0,2,3. QEMU did not provide
usable PMU counts.
Hui Su (2):
bpftool: Fix CPU IDs in per-CPU map output
bpftool: Fix sparse CPU IDs in prog profile
tools/bpf/bpftool/common.c | 40 ++++++++++
tools/bpf/bpftool/main.h | 1 +
tools/bpf/bpftool/map.c | 95 +++++++++++++++--------
tools/bpf/bpftool/prog.c | 51 +++++++-----
tools/bpf/bpftool/skeleton/profiler.bpf.c | 8 +-
5 files changed, 140 insertions(+), 55 deletions(-)
base-commit: 79dc258c9392051420a26f1504c647bd3d27c66a
--
2.55.0
next reply other threads:[~2026-09-23 0:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 0:42 Hui Su [this message]
2026-09-23 0:42 ` [PATCH bpf-next v3 1/2] bpftool: Fix CPU IDs in per-CPU map output Hui Su
2026-09-23 0:42 ` [PATCH bpf-next v3 2/2] bpftool: Fix sparse CPU IDs in prog profile Hui Su
2026-09-23 1:27 ` bot+bpf-ci
2026-09-24 10:20 ` [PATCH bpf-next v3 0/2] bpftool: Fix sparse CPU IDs patchwork-bot+netdevbpf
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=20260923004243.969919-1-sh_def@163.com \
--to=sh_def@163.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=qmo@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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®