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

libperf: Add perf_thread_map__nr/perf_thread_map__pid functions



So it's part of libperf library as basic functions operating on
perf_thread_map objects.

Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@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/20190822111141.25823-6-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5e51b0bb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
	if (target__has_cpu(&ftrace->target))
		return 0;

	for (i = 0; i < thread_map__nr(ftrace->evlist->core.threads); i++) {
	for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
		scnprintf(buf, sizeof(buf), "%d",
			  ftrace->evlist->core.threads->map[i]);
		if (append_tracing_file("set_ftrace_pid", buf) < 0)
+2 −2
Original line number Diff line number Diff line
@@ -1906,7 +1906,7 @@ static struct scripting_ops *scripting_ops;

static void __process_stat(struct evsel *counter, u64 tstamp)
{
	int nthreads = thread_map__nr(counter->core.threads);
	int nthreads = perf_thread_map__nr(counter->core.threads);
	int ncpus = perf_evsel__nr_cpus(counter);
	int cpu, thread;
	static int header_printed;
@@ -1928,7 +1928,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp)

			printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n",
				counter->core.cpus->map[cpu],
				thread_map__pid(counter->core.threads, thread),
				perf_thread_map__pid(counter->core.threads, thread),
				counts->val,
				counts->ena,
				counts->run,
+2 −2
Original line number Diff line number Diff line
@@ -264,7 +264,7 @@ static int read_single_counter(struct evsel *counter, int cpu,
 */
static int read_counter(struct evsel *counter, struct timespec *rs)
{
	int nthreads = thread_map__nr(evsel_list->core.threads);
	int nthreads = perf_thread_map__nr(evsel_list->core.threads);
	int ncpus, cpu, thread;

	if (target__has_cpu(&target) && !target__has_per_thread(&target))
@@ -1893,7 +1893,7 @@ int cmd_stat(int argc, const char **argv)
		thread_map__read_comms(evsel_list->core.threads);
		if (target.system_wide) {
			if (runtime_stat_new(&stat_config,
				thread_map__nr(evsel_list->core.threads))) {
				perf_thread_map__nr(evsel_list->core.threads))) {
				goto out;
			}
		}
+2 −2
Original line number Diff line number Diff line
@@ -3188,7 +3188,7 @@ static int trace__set_filter_pids(struct trace *trace)
			err = bpf_map__set_filter_pids(trace->filter_pids.map, trace->filter_pids.nr,
						       trace->filter_pids.entries);
		}
	} else if (thread_map__pid(trace->evlist->core.threads, 0) == -1) {
	} else if (perf_thread_map__pid(trace->evlist->core.threads, 0) == -1) {
		err = trace__set_filter_loop_pids(trace);
	}

@@ -3417,7 +3417,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
		evlist__enable(evlist);
	}

	trace->multiple_threads = thread_map__pid(evlist->core.threads, 0) == -1 ||
	trace->multiple_threads = perf_thread_map__pid(evlist->core.threads, 0) == -1 ||
				  evlist->core.threads->nr > 1 ||
				  perf_evlist__first(evlist)->core.attr.inherit;

+2 −0
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ LIBPERF_API struct perf_thread_map *perf_thread_map__new_dummy(void);

LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
LIBPERF_API int perf_thread_map__nr(struct perf_thread_map *threads);
LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);

LIBPERF_API struct perf_thread_map *perf_thread_map__get(struct perf_thread_map *map);
LIBPERF_API void perf_thread_map__put(struct perf_thread_map *map);
Loading