Commit dfc66bef authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo
Browse files

perf cpumap: Move 'has' function to libperf



Make the cpu map argument const for consistency with the rest of the
API. Modify cpu_map__idx accordingly.

Reviewed-by: default avatarJames Clark <james.clark@arm.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Vineet Singh <vineet.singh@intel.com>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: zhengjun.xing@intel.com
Link: https://lore.kernel.org/r/20220105061351.120843-21-irogers@google.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 973aeb3c
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,7 @@ SYNOPSIS
  int perf_cpu_map__nr(const struct perf_cpu_map *cpus);
  int perf_cpu_map__nr(const struct perf_cpu_map *cpus);
  bool perf_cpu_map__empty(const struct perf_cpu_map *map);
  bool perf_cpu_map__empty(const struct perf_cpu_map *map);
  int perf_cpu_map__max(struct perf_cpu_map *map);
  int perf_cpu_map__max(struct perf_cpu_map *map);
  bool perf_cpu_map__has(const struct perf_cpu_map *map, int cpu);


  #define perf_cpu_map__for_each_cpu(cpu, idx, cpus)
  #define perf_cpu_map__for_each_cpu(cpu, idx, cpus)
--
--
+6 −1
Original line number Original line Diff line number Diff line
@@ -268,7 +268,7 @@ bool perf_cpu_map__empty(const struct perf_cpu_map *map)
	return map ? map->map[0] == -1 : true;
	return map ? map->map[0] == -1 : true;
}
}


int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu)
int perf_cpu_map__idx(const struct perf_cpu_map *cpus, int cpu)
{
{
	int low = 0, high = cpus->nr;
	int low = 0, high = cpus->nr;


@@ -288,6 +288,11 @@ int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu)
	return -1;
	return -1;
}
}


bool perf_cpu_map__has(const struct perf_cpu_map *cpus, int cpu)
{
	return perf_cpu_map__idx(cpus, cpu) != -1;
}

int perf_cpu_map__max(struct perf_cpu_map *map)
int perf_cpu_map__max(struct perf_cpu_map *map)
{
{
	// cpu_map__trim_new() qsort()s it, cpu_map__default_new() sorts it as well.
	// cpu_map__trim_new() qsort()s it, cpu_map__default_new() sorts it as well.
+1 −1
Original line number Original line Diff line number Diff line
@@ -23,6 +23,6 @@ struct perf_cpu_map {
#define MAX_NR_CPUS	2048
#define MAX_NR_CPUS	2048
#endif
#endif


int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu);
int perf_cpu_map__idx(const struct perf_cpu_map *cpus, int cpu);


#endif /* __LIBPERF_INTERNAL_CPUMAP_H */
#endif /* __LIBPERF_INTERNAL_CPUMAP_H */
+1 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ LIBPERF_API int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx);
LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus);
LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus);
LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map);
LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map);
LIBPERF_API int perf_cpu_map__max(struct perf_cpu_map *map);
LIBPERF_API int perf_cpu_map__max(struct perf_cpu_map *map);
LIBPERF_API bool perf_cpu_map__has(const struct perf_cpu_map *map, int cpu);


#define perf_cpu_map__for_each_cpu(cpu, idx, cpus)		\
#define perf_cpu_map__for_each_cpu(cpu, idx, cpus)		\
	for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx);	\
	for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx);	\
+1 −0
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@ LIBPERF_0.0.1 {
		perf_cpu_map__cpu;
		perf_cpu_map__cpu;
		perf_cpu_map__empty;
		perf_cpu_map__empty;
		perf_cpu_map__max;
		perf_cpu_map__max;
		perf_cpu_map__has;
		perf_thread_map__new_dummy;
		perf_thread_map__new_dummy;
		perf_thread_map__set_pid;
		perf_thread_map__set_pid;
		perf_thread_map__comm;
		perf_thread_map__comm;
Loading