Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 397721e0 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

libperf: Add perf_cpu_map__dummy_new() function



Move cpu_map__dummy_new() to libperf as perf_cpu_map__dummy_new() function.

Signed-off-by: default avatarJiri 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-30-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 959b83c7
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -3,3 +3,16 @@
#include <stdlib.h>
#include <linux/refcount.h>
#include <internal/cpumap.h>

struct perf_cpu_map *perf_cpu_map__dummy_new(void)
{
	struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));

	if (cpus != NULL) {
		cpus->nr = 1;
		cpus->map[0] = -1;
		refcount_set(&cpus->refcnt, 1);
	}

	return cpus;
}
+4 −0
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@
#ifndef __LIBPERF_CPUMAP_H
#define __LIBPERF_CPUMAP_H

#include <perf/core.h>

struct perf_cpu_map;

LIBPERF_API struct perf_cpu_map *perf_cpu_map__dummy_new(void);

#endif /* __LIBPERF_CPUMAP_H */
+1 −0
Original line number Diff line number Diff line
LIBPERF_0.0.1 {
	global:
		libperf_set_print;
		perf_cpu_map__dummy_new;
	local:
		*;
};
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
	}
	evlist__add(evlist, evsel);

	cpus = cpu_map__dummy_new();
	cpus = perf_cpu_map__dummy_new();
	threads = thread_map__new_by_tid(getpid());
	if (!cpus || !threads) {
		err = -ENOMEM;
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
	 * perf_evlist__prepare_workload we'll fill in the only thread
	 * we're monitoring, the one forked there.
	 */
	cpus = cpu_map__dummy_new();
	cpus = perf_cpu_map__dummy_new();
	threads = thread_map__new_by_tid(-1);
	if (!cpus || !threads) {
		err = -ENOMEM;
Loading