libperf: Add perf_cpu_map__new()/perf_cpu_map__read() functions

Moving the following functions from tools/perf:

  cpu_map__new()
  cpu_map__read()

to libperf with the following names:

  perf_cpu_map__new()
  perf_cpu_map__read()

Committer notes:

Fixed up this one:

  tools/perf/arch/arm/util/cs-etm.c

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-44-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Jiri Olsa
2019-07-21 13:24:30 +02:00
committed by Arnaldo Carvalho de Melo
parent 1fc632cef4
commit 9c3516d1b8
37 changed files with 265 additions and 227 deletions

View File

@@ -5,6 +5,7 @@
#include "event.h"
#include <string.h>
#include <linux/bitops.h>
#include <perf/cpumap.h>
#include "debug.h"
struct machine;
@@ -78,7 +79,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __may
struct perf_cpu_map *cpus;
/* This one is better stores in mask. */
cpus = cpu_map__new("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19");
cpus = perf_cpu_map__new("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19");
TEST_ASSERT_VAL("failed to synthesize map",
!perf_event__synthesize_cpu_map(NULL, cpus, process_event_mask, NULL));
@@ -86,7 +87,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __may
perf_cpu_map__put(cpus);
/* This one is better stores in cpu values. */
cpus = cpu_map__new("1,256");
cpus = perf_cpu_map__new("1,256");
TEST_ASSERT_VAL("failed to synthesize map",
!perf_event__synthesize_cpu_map(NULL, cpus, process_event_cpus, NULL));
@@ -97,7 +98,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __may
static int cpu_map_print(const char *str)
{
struct perf_cpu_map *map = cpu_map__new(str);
struct perf_cpu_map *map = perf_cpu_map__new(str);
char buf[100];
if (!map)