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

Commit f373da34 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/probe fixes and improvements from Arnaldo Carvalho de Melo:

User visible changes:

  * Do not show +/- callchain expansion when there are no childs (top/report) (Namhyung Kim)

  * Fix -z and add respective 'z' hotkey to zero samples before refresh
    in 'perf top' (Namhyung Kim)

  * Capability probing fixes, improving the detection of
    kernel features for non-priviledged users (Adrian Hunter)

  * Add beautifier for mremap flags param in 'trace' (Alex Snast)

  * Fix --list and --del options to show events when just uprobes is
    enabled (Masami Hiramatsu)

  * perf script: Allow callchains if any event samples them

  * Don't look for kernel idle symbols in all DSOs in 'perf top' (Arnaldo Carvalho de Melo)

  * Add cpu_startup_entry to the list of kernel idle symbols (Arnaldo Carvalho de Melo)

  * 'perf top' terminal output fixes (Jiri Olsa)

  * Fix stdin handling for 'perf kvm stat live' (Jiri Olsa)

  * Fix missing label symbols (Adrian Hunter)

  * Don't demangle C++ parameters and such by default, only in
    --verbose mode (Namhyung Kim)

  * Set proper sort__mode for the branch option (Naohiro Aota)

  * Check recorded kernel version when finding vmlinux (Namhyung Kim)

Infrastructure changes:

  * More prep work for intel PT (Adrian Hunter)

  * Fix possible memory leaks (Namhyung Kim)

  * Fix a memory leak in vmlinux_path__init() (Namhyung Kim)

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents ddcd0973 1c65056c
Loading
Loading
Loading
Loading
+40 −35
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@

struct perf_annotate {
	struct perf_tool tool;
	bool	   force, use_tui, use_stdio, use_gtk;
	struct perf_session *session;
	bool	   use_tui, use_stdio, use_gtk;
	bool	   full_paths;
	bool	   print_line;
	bool	   skip_missing;
@@ -188,18 +189,9 @@ static void hists__find_annotations(struct hists *hists,
static int __cmd_annotate(struct perf_annotate *ann)
{
	int ret;
	struct perf_session *session;
	struct perf_session *session = ann->session;
	struct perf_evsel *pos;
	u64 total_nr_samples;
	struct perf_data_file file = {
		.path  = input_name,
		.mode  = PERF_DATA_MODE_READ,
		.force = ann->force,
	};

	session = perf_session__new(&file, false, &ann->tool);
	if (session == NULL)
		return -ENOMEM;

	machines__set_symbol_filter(&session->machines, symbol__annotate_init);

@@ -207,22 +199,22 @@ static int __cmd_annotate(struct perf_annotate *ann)
		ret = perf_session__cpu_bitmap(session, ann->cpu_list,
					       ann->cpu_bitmap);
		if (ret)
			goto out_delete;
			goto out;
	}

	if (!objdump_path) {
		ret = perf_session_env__lookup_objdump(&session->header.env);
		if (ret)
			goto out_delete;
			goto out;
	}

	ret = perf_session__process_events(session, &ann->tool);
	if (ret)
		goto out_delete;
		goto out;

	if (dump_trace) {
		perf_session__fprintf_nr_events(session, stdout);
		goto out_delete;
		goto out;
	}

	if (verbose > 3)
@@ -250,8 +242,8 @@ static int __cmd_annotate(struct perf_annotate *ann)
	}

	if (total_nr_samples == 0) {
		ui__error("The %s file has no samples!\n", file.path);
		goto out_delete;
		ui__error("The %s file has no samples!\n", session->file->path);
		goto out;
	}

	if (use_browser == 2) {
@@ -261,24 +253,12 @@ static int __cmd_annotate(struct perf_annotate *ann)
					 "perf_gtk__show_annotations");
		if (show_annotations == NULL) {
			ui__error("GTK browser not found!\n");
			goto out_delete;
			goto out;
		}
		show_annotations();
	}

out_delete:
	/*
	 * Speed up the exit process, for large files this can
	 * take quite a while.
	 *
	 * XXX Enable this when using valgrind or if we ever
	 * librarize this command.
	 *
	 * Also experiment with obstacks to see how much speed
	 * up we'll get here.
	 *
	 * perf_session__delete(session);
	 */
out:
	return ret;
}

@@ -301,6 +281,10 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
			.ordering_requires_timestamps = true,
		},
	};
	struct perf_data_file file = {
		.path  = input_name,
		.mode  = PERF_DATA_MODE_READ,
	};
	const struct option options[] = {
	OPT_STRING('i', "input", &input_name, "file",
		    "input file name"),
@@ -308,7 +292,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
		   "only consider symbols in these dsos"),
	OPT_STRING('s', "symbol", &annotate.sym_hist_filter, "symbol",
		    "symbol to annotate"),
	OPT_BOOLEAN('f', "force", &annotate.force, "don't complain, do it"),
	OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
	OPT_INCR('v', "verbose", &verbose,
		    "be more verbose (show symbol address, etc)"),
	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
@@ -341,6 +325,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
		    "Show event group information together"),
	OPT_END()
	};
	int ret;

	argc = parse_options(argc, argv, options, annotate_usage, 0);

@@ -353,11 +338,16 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)

	setup_browser(true);

	annotate.session = perf_session__new(&file, false, &annotate.tool);
	if (annotate.session == NULL)
		return -ENOMEM;

	symbol_conf.priv_size = sizeof(struct annotation);
	symbol_conf.try_vmlinux_path = true;

	if (symbol__init() < 0)
		return -1;
	ret = symbol__init(&annotate.session->header.env);
	if (ret < 0)
		goto out_delete;

	if (setup_sorting() < 0)
		usage_with_options(annotate_usage, options);
@@ -373,5 +363,20 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
		annotate.sym_hist_filter = argv[0];
	}

	return __cmd_annotate(&annotate);
	ret = __cmd_annotate(&annotate);

out_delete:
	/*
	 * Speed up the exit process, for large files this can
	 * take quite a while.
	 *
	 * XXX Enable this when using valgrind or if we ever
	 * librarize this command.
	 *
	 * Also experiment with obstacks to see how much speed
	 * up we'll get here.
	 *
	 * perf_session__delete(session);
	 */
	return ret;
}
+22 −15
Original line number Diff line number Diff line
@@ -246,20 +246,9 @@ static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused)
	return true;
}

static int build_id_cache__fprintf_missing(const char *filename, bool force, FILE *fp)
static int build_id_cache__fprintf_missing(struct perf_session *session, FILE *fp)
{
	struct perf_data_file file = {
		.path  = filename,
		.mode  = PERF_DATA_MODE_READ,
		.force = force,
	};
	struct perf_session *session = perf_session__new(&file, false, NULL);
	if (session == NULL)
		return -1;

	perf_session__fprintf_dsos_buildid(session, fp, dso__missing_buildid_cache, 0);
	perf_session__delete(session);

	return 0;
}

@@ -303,6 +292,11 @@ int cmd_buildid_cache(int argc, const char **argv,
		   *update_name_list_str = NULL,
		   *kcore_filename;

	struct perf_data_file file = {
		.mode  = PERF_DATA_MODE_READ,
	};
	struct perf_session *session = NULL;

	const struct option buildid_cache_options[] = {
	OPT_STRING('a', "add", &add_name_list_str,
		   "file list", "file(s) to add"),
@@ -326,8 +320,17 @@ int cmd_buildid_cache(int argc, const char **argv,
	argc = parse_options(argc, argv, buildid_cache_options,
			     buildid_cache_usage, 0);

	if (symbol__init() < 0)
	if (missing_filename) {
		file.path = missing_filename;
		file.force = force;

		session = perf_session__new(&file, false, NULL);
		if (session == NULL)
			return -1;
	}

	if (symbol__init(session ? &session->header.env : NULL) < 0)
		goto out;

	setup_pager();

@@ -370,7 +373,7 @@ int cmd_buildid_cache(int argc, const char **argv,
	}

	if (missing_filename)
		ret = build_id_cache__fprintf_missing(missing_filename, force, stdout);
		ret = build_id_cache__fprintf_missing(session, stdout);

	if (update_name_list_str) {
		list = strlist__new(true, update_name_list_str);
@@ -394,5 +397,9 @@ int cmd_buildid_cache(int argc, const char **argv,
	    build_id_cache__add_kcore(kcore_filename, debugdir, force))
		pr_warning("Couldn't add %s\n", kcore_filename);

out:
	if (session)
		perf_session__delete(session);

	return ret;
}
+1 −1
Original line number Diff line number Diff line
@@ -1143,7 +1143,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)

	argc = parse_options(argc, argv, options, diff_usage, 0);

	if (symbol__init() < 0)
	if (symbol__init(NULL) < 0)
		return -1;

	if (data_init(argc, argv) < 0)
+18 −13
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

struct perf_inject {
	struct perf_tool	tool;
	struct perf_session	*session;
	bool			build_ids;
	bool			sched_stat;
	const char		*input_name;
@@ -340,12 +341,8 @@ static int perf_evsel__check_stype(struct perf_evsel *evsel,

static int __cmd_inject(struct perf_inject *inject)
{
	struct perf_session *session;
	int ret = -EINVAL;
	struct perf_data_file file = {
		.path = inject->input_name,
		.mode = PERF_DATA_MODE_READ,
	};
	struct perf_session *session = inject->session;
	struct perf_data_file *file_out = &inject->output;

	signal(SIGINT, sig_handler);
@@ -357,10 +354,6 @@ static int __cmd_inject(struct perf_inject *inject)
		inject->tool.tracing_data = perf_event__repipe_tracing_data;
	}

	session = perf_session__new(&file, true, &inject->tool);
	if (session == NULL)
		return -ENOMEM;

	if (inject->build_ids) {
		inject->tool.sample = perf_event__inject_buildid;
	} else if (inject->sched_stat) {
@@ -396,8 +389,6 @@ static int __cmd_inject(struct perf_inject *inject)
		perf_session__write_header(session, session->evlist, file_out->fd, true);
	}

	perf_session__delete(session);

	return ret;
}

@@ -427,6 +418,11 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
			.mode = PERF_DATA_MODE_WRITE,
		},
	};
	struct perf_data_file file = {
		.mode = PERF_DATA_MODE_READ,
	};
	int ret;

	const struct option options[] = {
		OPT_BOOLEAN('b', "build-ids", &inject.build_ids,
			    "Inject build-ids into the output stream"),
@@ -461,8 +457,17 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
		return -1;
	}

	if (symbol__init() < 0)
	file.path = inject.input_name;
	inject.session = perf_session__new(&file, true, &inject.tool);
	if (inject.session == NULL)
		return -ENOMEM;

	if (symbol__init(&inject.session->header.env) < 0)
		return -1;

	return __cmd_inject(&inject);
	ret = __cmd_inject(&inject);

	perf_session__delete(inject.session);

	return ret;
}
+28 −21
Original line number Diff line number Diff line
@@ -405,10 +405,9 @@ static void sort_result(void)
	__sort_result(&root_caller_stat, &root_caller_sorted, &caller_sort);
}

static int __cmd_kmem(void)
static int __cmd_kmem(struct perf_session *session)
{
	int err = -EINVAL;
	struct perf_session *session;
	const struct perf_evsel_str_handler kmem_tracepoints[] = {
		{ "kmem:kmalloc",		perf_evsel__process_alloc_event, },
    		{ "kmem:kmem_cache_alloc",	perf_evsel__process_alloc_event, },
@@ -417,31 +416,22 @@ static int __cmd_kmem(void)
		{ "kmem:kfree",			perf_evsel__process_free_event, },
    		{ "kmem:kmem_cache_free",	perf_evsel__process_free_event, },
	};
	struct perf_data_file file = {
		.path = input_name,
		.mode = PERF_DATA_MODE_READ,
	};

	session = perf_session__new(&file, false, &perf_kmem);
	if (session == NULL)
		return -ENOMEM;

	if (!perf_session__has_traces(session, "kmem record"))
		goto out_delete;
		goto out;

	if (perf_session__set_tracepoints_handlers(session, kmem_tracepoints)) {
		pr_err("Initializing perf session tracepoint handlers failed\n");
		return -1;
		goto out;
	}

	setup_pager();
	err = perf_session__process_events(session, &perf_kmem);
	if (err != 0)
		goto out_delete;
		goto out;
	sort_result();
	print_result(session);
out_delete:
	perf_session__delete(session);
out:
	return err;
}

@@ -688,29 +678,46 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
		NULL,
		NULL
	};
	struct perf_session *session;
	struct perf_data_file file = {
		.path = input_name,
		.mode = PERF_DATA_MODE_READ,
	};
	int ret = -1;

	argc = parse_options_subcommand(argc, argv, kmem_options,
					kmem_subcommands, kmem_usage, 0);

	if (!argc)
		usage_with_options(kmem_usage, kmem_options);

	symbol__init();

	if (!strncmp(argv[0], "rec", 3)) {
		symbol__init(NULL);
		return __cmd_record(argc, argv);
	} else if (!strcmp(argv[0], "stat")) {
	}

	session = perf_session__new(&file, false, &perf_kmem);
	if (session == NULL)
		return -ENOMEM;

	symbol__init(&session->header.env);

	if (!strcmp(argv[0], "stat")) {
		if (cpu__setup_cpunode_map())
			return -1;
			goto out_delete;

		if (list_empty(&caller_sort))
			setup_sorting(&caller_sort, default_sort_order);
		if (list_empty(&alloc_sort))
			setup_sorting(&alloc_sort, default_sort_order);

		return __cmd_kmem();
		ret = __cmd_kmem(session);
	} else
		usage_with_options(kmem_usage, kmem_options);

	return 0;
out_delete:
	perf_session__delete(session);

	return ret;
}
Loading