]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
libperf cpumap: Add ability to create CPU from a single CPU number
authorIan Rogers <irogers@google.com>
Thu, 3 Apr 2025 19:43:34 +0000 (12:43 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 12 May 2025 17:18:16 +0000 (14:18 -0300)
Add perf_cpu_map__new_int() so that a CPU map can be created from a
single integer.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/20250403194337.40202-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/perf/cpumap.c
tools/lib/perf/include/perf/cpumap.h

index 4454a5987570cfbc690e5fd0052f5c86797584a4..b20a5280f2b333d46db72821d2ef30e9e97787bb 100644 (file)
@@ -242,6 +242,16 @@ out:
        return cpus;
 }
 
+struct perf_cpu_map *perf_cpu_map__new_int(int cpu)
+{
+       struct perf_cpu_map *cpus = perf_cpu_map__alloc(1);
+
+       if (cpus)
+               RC_CHK_ACCESS(cpus)->map[0].cpu = cpu;
+
+       return cpus;
+}
+
 static int __perf_cpu_map__nr(const struct perf_cpu_map *cpus)
 {
        return RC_CHK_ACCESS(cpus)->nr;
index 8c1ab0f9194e0708cae10abdfdd035cd4dcfce27..58cc5c5fa47c5f2608a85719da4d35bb2078b00f 100644 (file)
@@ -37,6 +37,8 @@ LIBPERF_API struct perf_cpu_map *perf_cpu_map__new_online_cpus(void);
  *                     perf_cpu_map__new_online_cpus is returned.
  */
 LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list);
+/** perf_cpu_map__new_int - create a map with the one given cpu. */
+LIBPERF_API struct perf_cpu_map *perf_cpu_map__new_int(int cpu);
 LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map);
 LIBPERF_API int perf_cpu_map__merge(struct perf_cpu_map **orig,
                                    struct perf_cpu_map *other);