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

libperf: Add threads to struct perf_evlist



Move threads from tools/perf's evlist to libperf's perf_evlist struct.

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-56-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f72f901d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -156,9 +156,9 @@ 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->threads); i++) {
	for (i = 0; i < thread_map__nr(ftrace->evlist->core.threads); i++) {
		scnprintf(buf, sizeof(buf), "%d",
			  ftrace->evlist->threads->map[i]);
			  ftrace->evlist->core.threads->map[i]);
		if (append_tracing_file("set_ftrace_pid", buf) < 0)
			return -1;
	}
+1 −1
Original line number Diff line number Diff line
@@ -1450,7 +1450,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
	perf_session__set_id_hdr_size(kvm->session);
	ordered_events__set_copy_on_queue(&kvm->session->ordered_events, true);
	machine__synthesize_threads(&kvm->session->machines.host, &kvm->opts.target,
				    kvm->evlist->threads, false, 1);
				    kvm->evlist->core.threads, false, 1);
	err = kvm_live_open_events(kvm);
	if (err)
		goto out;
+2 −2
Original line number Diff line number Diff line
@@ -1275,7 +1275,7 @@ static int record__synthesize(struct record *rec, bool tail)
	if (err)
		goto out;

	err = perf_event__synthesize_thread_map2(&rec->tool, rec->evlist->threads,
	err = perf_event__synthesize_thread_map2(&rec->tool, rec->evlist->core.threads,
						 process_synthesized_event,
						NULL);
	if (err < 0) {
@@ -1295,7 +1295,7 @@ static int record__synthesize(struct record *rec, bool tail)
	if (err < 0)
		pr_warning("Couldn't synthesize bpf events.\n");

	err = __machine__synthesize_threads(machine, tool, &opts->target, rec->evlist->threads,
	err = __machine__synthesize_threads(machine, tool, &opts->target, rec->evlist->core.threads,
					    process_synthesized_event, opts->sample_address,
					    1);
out:
+9 −9
Original line number Diff line number Diff line
@@ -263,7 +263,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->threads);
	int nthreads = thread_map__nr(evsel_list->core.threads);
	int ncpus, cpu, thread;

	if (target__has_cpu(&target) && !target__has_per_thread(&target))
@@ -485,15 +485,15 @@ try_again:
                                        ui__warning("%s\n", msg);
                                goto try_again;
			} else if (target__has_per_thread(&target) &&
				   evsel_list->threads &&
				   evsel_list->threads->err_thread != -1) {
				   evsel_list->core.threads &&
				   evsel_list->core.threads->err_thread != -1) {
				/*
				 * For global --per-thread case, skip current
				 * error thread.
				 */
				if (!thread_map__remove(evsel_list->threads,
							evsel_list->threads->err_thread)) {
					evsel_list->threads->err_thread = -1;
				if (!thread_map__remove(evsel_list->core.threads,
							evsel_list->core.threads->err_thread)) {
					evsel_list->core.threads->err_thread = -1;
					goto try_again;
				}
			}
@@ -579,7 +579,7 @@ try_again:
		enable_counters();
		while (!done) {
			nanosleep(&ts, NULL);
			if (!is_target_alive(&target, evsel_list->threads))
			if (!is_target_alive(&target, evsel_list->core.threads))
				break;
			if (timeout)
				break;
@@ -1889,10 +1889,10 @@ int cmd_stat(int argc, const char **argv)
	 * so we could print it out on output.
	 */
	if (stat_config.aggr_mode == AGGR_THREAD) {
		thread_map__read_comms(evsel_list->threads);
		thread_map__read_comms(evsel_list->core.threads);
		if (target.system_wide) {
			if (runtime_stat_new(&stat_config,
				thread_map__nr(evsel_list->threads))) {
				thread_map__nr(evsel_list->core.threads))) {
				goto out;
			}
		}
+2 −2
Original line number Diff line number Diff line
@@ -990,7 +990,7 @@ static int perf_top__start_counters(struct perf_top *top)
	evlist__for_each_entry(evlist, counter) {
try_again:
		if (evsel__open(counter, top->evlist->core.cpus,
				     top->evlist->threads) < 0) {
				     top->evlist->core.threads) < 0) {

			/*
			 * Specially handle overwrite fall back.
@@ -1222,7 +1222,7 @@ static int __cmd_top(struct perf_top *top)
		pr_debug("Couldn't synthesize BPF events: Pre-existing BPF programs won't have symbols resolved.\n");

	machine__synthesize_threads(&top->session->machines.host, &opts->target,
				    top->evlist->threads, false,
				    top->evlist->core.threads, false,
				    top->nr_threads_synthesize);

	if (top->nr_threads_synthesize > 1)
Loading