Skip to content

Add a new API libbpf_num_possible_cpus()

Hechao Li bpf netdev 4 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest3 patches 1 replyApplied
  2. v52 patches 0 repliesSuperseded
  3. v42 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v32 patches2 repliesSuperseded

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/3bpf: add a new API libbpf_num_possible_cpus()tools/lib/bpf/libbpf.c tools/lib/bpf/libbpf.h tools/lib/bpf/libbpf.map+74 -00 replies
2/3selftests/bpf: remove bpf_util.h from BPF C progstools/testing/selftests/bpf/bpf_endian.h tools/testing/selftests/bpf/progs/sockmap_parse_prog.c tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c +2 more+6 -40 replies
3/3bpf: use libbpf_num_possible_cpus internallytools/bpf/bpftool/common.c tools/testing/selftests/bpf/bpf_util.h+10 -800 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.

Read the v6 thread

Cover letter [PATCH v6 bpf-next 0/3] Add a new API libbpf_num_possible_cpus()

Getting number of possible CPUs is commonly used for per-CPU BPF maps and perf_event_maps. Add a new API libbpf_num_possible_cpus() that helps user with per-CPU related operations and remove duplicate implementations in bpftool and selftests.

v2: Save errno before calling pr_warning in case it is changed.
v3: Make sure libbpf_num_possible_cpus never returns 0 so that user only
has to check if ret value < 0.
v4: Fix error code when reading 0 bytes from possible CPU file.
v5: Fix selftests compliation issue.
v6: Split commit to reuse libbpf_num_possible_cpus() into two commits:
One commit to remove bpf_util.h from test BPF C programs. One commit to reuse libbpf_num_possible_cpus() in bpftools and bpf_util.h.

Hechao Li (3):
bpf: add a new API libbpf_num_possible_cpus() selftests/bpf: remove bpf_util.h from BPF C progs
bpf: use libbpf_num_possible_cpus internally

 tools/bpf/bpftool/common.c                    | 53 ++---------------
 tools/lib/bpf/libbpf.c                        | 57 +++++++++++++++++++
 tools/lib/bpf/libbpf.h                        | 16 ++++++
 tools/lib/bpf/libbpf.map                      |  1 +
 tools/testing/selftests/bpf/bpf_endian.h      |  1 +
 tools/testing/selftests/bpf/bpf_util.h        | 37 ++----------
 .../selftests/bpf/progs/sockmap_parse_prog.c  |  1 -
 .../bpf/progs/sockmap_tcp_msg_prog.c          |  2 +-
 .../bpf/progs/sockmap_verdict_prog.c          |  1 -
 .../selftests/bpf/progs/test_sysctl_prog.c    |  5 +-
 10 files changed, 90 insertions(+), 84 deletions(-)
Signature · 1 line
2.17.1