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

perf record: Disable debuginfod by default

Fedora 35 sets DEBUGINFOD_URLS by default, which might lead to
unexpected stalls in perf record exit path, when we try to cache
profiled binaries.

  # DEBUGINFOD_PROGRESS=1 ./perf record -a
  ^C[ perf record: Woken up 1 times to write data ]
  Downloading from https://debuginfod.fedoraproject.org/ 447069
  Downloading from https://debuginfod.fedoraproject.org/ 1502175
  Downloading \^Z

Disabling DEBUGINFOD_URLS by default in perf record and adding
debuginfod option and .perfconfig variable support to enable id.

  Default without debuginfo processing:
  # perf record -a

  Using system debuginfod setup:
  # perf record -a --debuginfod

  Using custom debuginfd url:
  # perf record -a --debuginfod='https://evenbetterdebuginfodserver.krava

'

Adding single perf_debuginfod_setup function and using
it also in perf buildid-cache command.

Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20211209200425.303561-1-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2eea0b56
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -74,12 +74,15 @@ OPTIONS
	used when creating a uprobe for a process that resides in a
	used when creating a uprobe for a process that resides in a
	different mount namespace from the perf(1) utility.
	different mount namespace from the perf(1) utility.


--debuginfod=URLs::
--debuginfod[=URLs]::
	Specify debuginfod URL to be used when retrieving perf.data binaries,
	Specify debuginfod URL to be used when retrieving perf.data binaries,
	it follows the same syntax as the DEBUGINFOD_URLS variable, like:
	it follows the same syntax as the DEBUGINFOD_URLS variable, like:


	  buildid-cache.debuginfod=http://192.168.122.174:8002
	  buildid-cache.debuginfod=http://192.168.122.174:8002


	If the URLs is not specified, the value of DEBUGINFOD_URLS
	system environment variable is used.

SEE ALSO
SEE ALSO
--------
--------
linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-buildid-list[1]
linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-buildid-list[1]
+9 −0
Original line number Original line Diff line number Diff line
@@ -587,6 +587,15 @@ record.*::
		Use 'n' control blocks in asynchronous (Posix AIO) trace writing
		Use 'n' control blocks in asynchronous (Posix AIO) trace writing
		mode ('n' default: 1, max: 4).
		mode ('n' default: 1, max: 4).


	record.debuginfod::
		Specify debuginfod URL to be used when cacheing perf.data binaries,
		it follows the same syntax as the DEBUGINFOD_URLS variable, like:

		  http://192.168.122.174:8002

		If the URLs is 'system', the value of DEBUGINFOD_URLS system environment
		variable is used.

diff.*::
diff.*::
	diff.order::
	diff.order::
		This option sets the number of columns to sort the result.
		This option sets the number of columns to sort the result.
+9 −0
Original line number Original line Diff line number Diff line
@@ -715,6 +715,15 @@ measurements:


include::intel-hybrid.txt[]
include::intel-hybrid.txt[]


--debuginfod[=URLs]::
	Specify debuginfod URL to be used when cacheing perf.data binaries,
	it follows the same syntax as the DEBUGINFOD_URLS variable, like:

	  http://192.168.122.174:8002

	If the URLs is not specified, the value of DEBUGINFOD_URLS
	system environment variable is used.

SEE ALSO
SEE ALSO
--------
--------
linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-intel-pt[1]
linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-intel-pt[1]
+14 −11
Original line number Original line Diff line number Diff line
@@ -351,10 +351,14 @@ static int build_id_cache__show_all(void)


static int perf_buildid_cache_config(const char *var, const char *value, void *cb)
static int perf_buildid_cache_config(const char *var, const char *value, void *cb)
{
{
	const char **debuginfod = cb;
	struct perf_debuginfod *di = cb;


	if (!strcmp(var, "buildid-cache.debuginfod"))
	if (!strcmp(var, "buildid-cache.debuginfod")) {
		*debuginfod = strdup(value);
		di->urls = strdup(value);
		if (!di->urls)
			return -ENOMEM;
		di->set = true;
	}


	return 0;
	return 0;
}
}
@@ -373,8 +377,8 @@ int cmd_buildid_cache(int argc, const char **argv)
		   *purge_name_list_str = NULL,
		   *purge_name_list_str = NULL,
		   *missing_filename = NULL,
		   *missing_filename = NULL,
		   *update_name_list_str = NULL,
		   *update_name_list_str = NULL,
		   *kcore_filename = NULL,
		   *kcore_filename = NULL;
		   *debuginfod = NULL;
	struct perf_debuginfod debuginfod = { };
	char sbuf[STRERR_BUFSIZE];
	char sbuf[STRERR_BUFSIZE];


	struct perf_data data = {
	struct perf_data data = {
@@ -399,8 +403,10 @@ int cmd_buildid_cache(int argc, const char **argv)
	OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
	OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
	OPT_STRING('u', "update", &update_name_list_str, "file list",
	OPT_STRING('u', "update", &update_name_list_str, "file list",
		    "file(s) to update"),
		    "file(s) to update"),
	OPT_STRING(0, "debuginfod", &debuginfod, "debuginfod url",
	OPT_STRING_OPTARG_SET(0, "debuginfod", &debuginfod.urls,
		    "set debuginfod url"),
			&debuginfod.set, "debuginfod urls",
			"Enable debuginfod data retrieval from DEBUGINFOD_URLS or specified urls",
			"system"),
	OPT_INCR('v', "verbose", &verbose, "be more verbose"),
	OPT_INCR('v', "verbose", &verbose, "be more verbose"),
	OPT_INTEGER(0, "target-ns", &ns_id, "target pid for namespace context"),
	OPT_INTEGER(0, "target-ns", &ns_id, "target pid for namespace context"),
	OPT_END()
	OPT_END()
@@ -425,10 +431,7 @@ int cmd_buildid_cache(int argc, const char **argv)
	if (argc || !(list_files || opts_flag))
	if (argc || !(list_files || opts_flag))
		usage_with_options(buildid_cache_usage, buildid_cache_options);
		usage_with_options(buildid_cache_usage, buildid_cache_options);


	if (debuginfod) {
	perf_debuginfod_setup(&debuginfod);
		pr_debug("DEBUGINFOD_URLS=%s\n", debuginfod);
		setenv("DEBUGINFOD_URLS", debuginfod, 1);
	}


	/* -l is exclusive. It can not be used with other options. */
	/* -l is exclusive. It can not be used with other options. */
	if (list_files && opts_flag) {
	if (list_files && opts_flag) {
+13 −0
Original line number Original line Diff line number Diff line
@@ -111,6 +111,7 @@ struct record {
	unsigned long long	samples;
	unsigned long long	samples;
	struct mmap_cpu_mask	affinity_mask;
	struct mmap_cpu_mask	affinity_mask;
	unsigned long		output_max_size;	/* = 0: unlimited */
	unsigned long		output_max_size;	/* = 0: unlimited */
	struct perf_debuginfod	debuginfod;
};
};


static volatile int done;
static volatile int done;
@@ -2177,6 +2178,12 @@ static int perf_record_config(const char *var, const char *value, void *cb)
			rec->opts.nr_cblocks = nr_cblocks_default;
			rec->opts.nr_cblocks = nr_cblocks_default;
	}
	}
#endif
#endif
	if (!strcmp(var, "record.debuginfod")) {
		rec->debuginfod.urls = strdup(value);
		if (!rec->debuginfod.urls)
			return -ENOMEM;
		rec->debuginfod.set = true;
	}


	return 0;
	return 0;
}
}
@@ -2667,6 +2674,10 @@ static struct option __record_options[] = {
		      parse_control_option),
		      parse_control_option),
	OPT_CALLBACK(0, "synth", &record.opts, "no|all|task|mmap|cgroup",
	OPT_CALLBACK(0, "synth", &record.opts, "no|all|task|mmap|cgroup",
		     "Fine-tune event synthesis: default=all", parse_record_synth_option),
		     "Fine-tune event synthesis: default=all", parse_record_synth_option),
	OPT_STRING_OPTARG_SET(0, "debuginfod", &record.debuginfod.urls,
			  &record.debuginfod.set, "debuginfod urls",
			  "Enable debuginfod data retrieval from DEBUGINFOD_URLS or specified urls",
			  "system"),
	OPT_END()
	OPT_END()
};
};


@@ -2720,6 +2731,8 @@ int cmd_record(int argc, const char **argv)
	if (err)
	if (err)
		return err;
		return err;


	perf_debuginfod_setup(&record.debuginfod);

	/* Make system wide (-a) the default target. */
	/* Make system wide (-a) the default target. */
	if (!argc && target__none(&rec->opts.target))
	if (!argc && target__none(&rec->opts.target))
		rec->opts.target.system_wide = true;
		rec->opts.target.system_wide = true;
Loading