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

Commit 6632c4b4 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge tag 'perf-core-for-mingo' of...

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

 into perf/core

Pull perf/core improvements and fixes from  Arnaldo Carvalho de Melo:

New features:

  - Add option in 'perf sched' to merge like comms to lat output (Josef Bacik)

  - Improve 'perf probe' error messages when not finding a
    suitable vmlinux (Masami Hiramatsu)

Infrastructure changes:

  - Use atomic.h for various pre-existing reference counts (Arnaldo Carvalho de Melo)

  - Leg work for refcounting 'struct map' (Arnaldo Carvalho de Melo)

  - Assign default value for some pointers (Martin Liška)

  - Improve setting of gcc debug option (Martin Liška)

  - Separate the tests and tools in installation (Nam T. Nguyen)

  - Reduce number of arguments of hist_entry_iter__add() (Namhyung Kim)

  - DSO data cache fixes (Namhyung Kim)

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents a82d24ed dddc7ee3
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ check: $(OUTPUT)common-cmds.h

install-gtk:

install-bin: all install-gtk
install-tools: all install-gtk
	$(call QUIET_INSTALL, binaries) \
		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
		$(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
@@ -502,12 +502,16 @@ endif
	$(call QUIET_INSTALL, perf_completion-script) \
		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
		$(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'

install-tests: all install-gtk
	$(call QUIET_INSTALL, tests) \
		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
		$(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
		$(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'

install-bin: install-tools install-tests

install: install-bin try-install-man install-traceevent-plugins

install-python_ext:
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ const char *const mips_triplets[] = {
static bool lookup_path(char *name)
{
	bool found = false;
	char *path, *tmp;
	char *path, *tmp = NULL;
	char buf[PATH_MAX];
	char *env = getenv("PATH");

+5 −4
Original line number Diff line number Diff line
@@ -139,6 +139,8 @@ static int process_sample_event(struct perf_tool *tool,
	struct report *rep = container_of(tool, struct report, tool);
	struct addr_location al;
	struct hist_entry_iter iter = {
		.evsel 			= evsel,
		.sample 		= sample,
		.hide_unresolved 	= rep->hide_unresolved,
		.add_entry_cb 		= hist_iter__report_callback,
	};
@@ -168,8 +170,7 @@ static int process_sample_event(struct perf_tool *tool,
	if (al.map != NULL)
		al.map->dso->hit = 1;

	ret = hist_entry_iter__add(&iter, &al, evsel, sample, rep->max_stack,
				   rep);
	ret = hist_entry_iter__add(&iter, &al, rep->max_stack, rep);
	if (ret < 0)
		pr_debug("problem adding hist entry, skipping event\n");
out_put:
+72 −5
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ struct work_atoms {
	u64			total_lat;
	u64			nb_atoms;
	u64			total_runtime;
	int			num_merged;
};

typedef int (*sort_fn_t)(struct work_atoms *, struct work_atoms *);
@@ -168,9 +169,10 @@ struct perf_sched {
	u64		 all_runtime;
	u64		 all_count;
	u64		 cpu_last_switched[MAX_CPUS];
	struct rb_root	 atom_root, sorted_atom_root;
	struct rb_root	 atom_root, sorted_atom_root, merged_atom_root;
	struct list_head sort_list, cmp_pid;
	bool force;
	bool skip_merge;
};

static u64 get_nsecs(void)
@@ -1182,6 +1184,9 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_
	sched->all_runtime += work_list->total_runtime;
	sched->all_count   += work_list->nb_atoms;

	if (work_list->num_merged > 1)
		ret = printf("  %s:(%d) ", thread__comm_str(work_list->thread), work_list->num_merged);
	else
		ret = printf("  %s:%d ", thread__comm_str(work_list->thread), work_list->thread->tid);

	for (i = 0; i < 24 - ret; i++)
@@ -1302,17 +1307,22 @@ static int sort_dimension__add(const char *tok, struct list_head *list)
static void perf_sched__sort_lat(struct perf_sched *sched)
{
	struct rb_node *node;

	struct rb_root *root = &sched->atom_root;
again:
	for (;;) {
		struct work_atoms *data;
		node = rb_first(&sched->atom_root);
		node = rb_first(root);
		if (!node)
			break;

		rb_erase(node, &sched->atom_root);
		rb_erase(node, root);
		data = rb_entry(node, struct work_atoms, node);
		__thread_latency_insert(&sched->sorted_atom_root, data, &sched->sort_list);
	}
	if (root == &sched->atom_root) {
		root = &sched->merged_atom_root;
		goto again;
	}
}

static int process_sched_wakeup_event(struct perf_tool *tool,
@@ -1572,6 +1582,59 @@ static void print_bad_events(struct perf_sched *sched)
	}
}

static void __merge_work_atoms(struct rb_root *root, struct work_atoms *data)
{
	struct rb_node **new = &(root->rb_node), *parent = NULL;
	struct work_atoms *this;
	const char *comm = thread__comm_str(data->thread), *this_comm;

	while (*new) {
		int cmp;

		this = container_of(*new, struct work_atoms, node);
		parent = *new;

		this_comm = thread__comm_str(this->thread);
		cmp = strcmp(comm, this_comm);
		if (cmp > 0) {
			new = &((*new)->rb_left);
		} else if (cmp < 0) {
			new = &((*new)->rb_right);
		} else {
			this->num_merged++;
			this->total_runtime += data->total_runtime;
			this->nb_atoms += data->nb_atoms;
			this->total_lat += data->total_lat;
			list_splice(&data->work_list, &this->work_list);
			if (this->max_lat < data->max_lat) {
				this->max_lat = data->max_lat;
				this->max_lat_at = data->max_lat_at;
			}
			zfree(&data);
			return;
		}
	}

	data->num_merged++;
	rb_link_node(&data->node, parent, new);
	rb_insert_color(&data->node, root);
}

static void perf_sched__merge_lat(struct perf_sched *sched)
{
	struct work_atoms *data;
	struct rb_node *node;

	if (sched->skip_merge)
		return;

	while ((node = rb_first(&sched->atom_root))) {
		rb_erase(node, &sched->atom_root);
		data = rb_entry(node, struct work_atoms, node);
		__merge_work_atoms(&sched->merged_atom_root, data);
	}
}

static int perf_sched__lat(struct perf_sched *sched)
{
	struct rb_node *next;
@@ -1581,6 +1644,7 @@ static int perf_sched__lat(struct perf_sched *sched)
	if (perf_sched__read_events(sched))
		return -1;

	perf_sched__merge_lat(sched);
	perf_sched__sort_lat(sched);

	printf("\n -----------------------------------------------------------------------------------------------------------------\n");
@@ -1732,6 +1796,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
		.profile_cpu	      = -1,
		.next_shortname1      = 'A',
		.next_shortname2      = '0',
		.skip_merge           = 0,
	};
	const struct option latency_options[] = {
	OPT_STRING('s', "sort", &sched.sort_order, "key[,key2...]",
@@ -1742,6 +1807,8 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
		    "CPU to profile on"),
	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
		    "dump raw trace in ASCII"),
	OPT_BOOLEAN('p', "pids", &sched.skip_merge,
		    "latency stats per pid instead of per comm"),
	OPT_END()
	};
	const struct option replay_options[] = {
+4 −3
Original line number Diff line number Diff line
@@ -775,6 +775,8 @@ static void perf_event__process_sample(struct perf_tool *tool,
	if (al.sym == NULL || !al.sym->ignore) {
		struct hists *hists = evsel__hists(evsel);
		struct hist_entry_iter iter = {
			.evsel		= evsel,
			.sample 	= sample,
			.add_entry_cb 	= hist_iter__top_callback,
		};

@@ -785,8 +787,7 @@ static void perf_event__process_sample(struct perf_tool *tool,

		pthread_mutex_lock(&hists->lock);

		err = hist_entry_iter__add(&iter, &al, evsel, sample,
					   top->max_stack, top);
		err = hist_entry_iter__add(&iter, &al, top->max_stack, top);
		if (err < 0)
			pr_err("Problem incrementing symbol period, skipping event\n");

Loading