summaryrefslogtreecommitdiff
path: root/tools/lib
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2026-06-06 14:42:09 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2026-06-06 14:46:37 -0300
commitf54ce06049bf716f6b1e3a78e72360d583ea2acb (patch)
treee44d1a9af1352e4925eb871c584fb3136e9629f3 /tools/lib
parentc3e51ed45ffa7547495a851e33ce332f81ef3665 (diff)
libperf: Document struct perf_cpu int16_t ABI limitation
struct perf_cpu.cpu is int16_t, limiting perf to 32767 CPUs. This is part of the libperf ABI (returned by value from perf_cpu_map__cpu() and friends), so widening it requires an ABI bump. Add a comment on the struct definition noting this, and create a TODO file to collect future ABI changes so they can be batched into a single version bump. Cc: Ian Rogers <irogers@google.com> Cc: Namhyung Kim <namhyung@kernel.org> Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/perf/TODO22
-rw-r--r--tools/lib/perf/include/perf/cpumap.h8
2 files changed, 29 insertions, 1 deletions
diff --git a/tools/lib/perf/TODO b/tools/lib/perf/TODO
new file mode 100644
index 000000000000..486dd95dc572
--- /dev/null
+++ b/tools/lib/perf/TODO
@@ -0,0 +1,22 @@
+Future ABI changes
+==================
+
+This file collects items that require a libperf ABI bump. Each entry
+should describe the current limitation, the desired end state, and the
+scope of the change so that a future ABI revision can batch them
+together.
+
+1. Widen struct perf_cpu.cpu from int16_t to int
+ - Current limit: 32767 CPUs. No architecture exceeds this today
+ (x86_64 max is 8192, arm64 is 4096), but NR_CPUS limits keep
+ growing. perf clamps to INT16_MAX in set_max_cpu_num() as a
+ safety net.
+ - Scope: struct perf_cpu is embedded everywhere — perf_cpu_map__cpu(),
+ perf_cpu_map__min(), perf_cpu_map__max(), perf_cpu_map__has(), the
+ for_each_cpu macros, and all internal callers. The perf_cpu_map
+ internal array (RC_CHK_ACCESS(map)->map[]) stores struct perf_cpu
+ directly. Widening changes the struct layout and every function
+ that returns or accepts struct perf_cpu by value.
+ - Migration: bump LIBPERF version in libperf.map, audit all
+ sizeof(struct perf_cpu) assumptions, update perf.data
+ serialization if needed.
diff --git a/tools/lib/perf/include/perf/cpumap.h b/tools/lib/perf/include/perf/cpumap.h
index a1dd25db65b6..e1a0b0d27210 100644
--- a/tools/lib/perf/include/perf/cpumap.h
+++ b/tools/lib/perf/include/perf/cpumap.h
@@ -6,7 +6,13 @@
#include <stdbool.h>
#include <stdint.h>
-/** A wrapper around a CPU to avoid confusion with the perf_cpu_map's map's indices. */
+/**
+ * struct perf_cpu - wrapper around a CPU number.
+ * @cpu: CPU number, -1 for the "any CPU"/dummy value.
+ *
+ * int16_t limits this to 32767 CPUs. Widening to int requires a libperf
+ * ABI bump — see tools/lib/perf/TODO for the full scope.
+ */
struct perf_cpu {
int16_t cpu;
};