Skip to content

Commit 9bce13e

Browse files
Jiri Olsaacmel
authored andcommitted
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: Jiri 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: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 2eea0b5 commit 9bce13e

File tree

7 files changed

+70
-12
lines changed

7 files changed

+70
-12
lines changed

tools/perf/Documentation/perf-buildid-cache.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,15 @@ OPTIONS
7474
used when creating a uprobe for a process that resides in a
7575
different mount namespace from the perf(1) utility.
7676

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

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

83+
If the URLs is not specified, the value of DEBUGINFOD_URLS
84+
system environment variable is used.
85+
8386
SEE ALSO
8487
--------
8588
linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-buildid-list[1]

tools/perf/Documentation/perf-config.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,15 @@ record.*::
587587
Use 'n' control blocks in asynchronous (Posix AIO) trace writing
588588
mode ('n' default: 1, max: 4).
589589

590+
record.debuginfod::
591+
Specify debuginfod URL to be used when cacheing perf.data binaries,
592+
it follows the same syntax as the DEBUGINFOD_URLS variable, like:
593+
594+
http://192.168.122.174:8002
595+
596+
If the URLs is 'system', the value of DEBUGINFOD_URLS system environment
597+
variable is used.
598+
590599
diff.*::
591600
diff.order::
592601
This option sets the number of columns to sort the result.

tools/perf/Documentation/perf-record.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,15 @@ measurements:
715715

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

718+
--debuginfod[=URLs]::
719+
Specify debuginfod URL to be used when cacheing perf.data binaries,
720+
it follows the same syntax as the DEBUGINFOD_URLS variable, like:
721+
722+
http://192.168.122.174:8002
723+
724+
If the URLs is not specified, the value of DEBUGINFOD_URLS
725+
system environment variable is used.
726+
718727
SEE ALSO
719728
--------
720729
linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-intel-pt[1]

tools/perf/builtin-buildid-cache.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,14 @@ static int build_id_cache__show_all(void)
351351

352352
static int perf_buildid_cache_config(const char *var, const char *value, void *cb)
353353
{
354-
const char **debuginfod = cb;
354+
struct perf_debuginfod *di = cb;
355355

356-
if (!strcmp(var, "buildid-cache.debuginfod"))
357-
*debuginfod = strdup(value);
356+
if (!strcmp(var, "buildid-cache.debuginfod")) {
357+
di->urls = strdup(value);
358+
if (!di->urls)
359+
return -ENOMEM;
360+
di->set = true;
361+
}
358362

359363
return 0;
360364
}
@@ -373,8 +377,8 @@ int cmd_buildid_cache(int argc, const char **argv)
373377
*purge_name_list_str = NULL,
374378
*missing_filename = NULL,
375379
*update_name_list_str = NULL,
376-
*kcore_filename = NULL,
377-
*debuginfod = NULL;
380+
*kcore_filename = NULL;
381+
struct perf_debuginfod debuginfod = { };
378382
char sbuf[STRERR_BUFSIZE];
379383

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

428-
if (debuginfod) {
429-
pr_debug("DEBUGINFOD_URLS=%s\n", debuginfod);
430-
setenv("DEBUGINFOD_URLS", debuginfod, 1);
431-
}
434+
perf_debuginfod_setup(&debuginfod);
432435

433436
/* -l is exclusive. It can not be used with other options. */
434437
if (list_files && opts_flag) {

tools/perf/builtin-record.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct record {
111111
unsigned long long samples;
112112
struct mmap_cpu_mask affinity_mask;
113113
unsigned long output_max_size; /* = 0: unlimited */
114+
struct perf_debuginfod debuginfod;
114115
};
115116

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

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

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

2734+
perf_debuginfod_setup(&record.debuginfod);
2735+
27232736
/* Make system wide (-a) the default target. */
27242737
if (!argc && target__none(&rec->opts.target))
27252738
rec->opts.target.system_wide = true;

tools/perf/util/util.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,18 @@ char *perf_exe(char *buf, int len)
416416
}
417417
return strcpy(buf, "perf");
418418
}
419+
420+
void perf_debuginfod_setup(struct perf_debuginfod *di)
421+
{
422+
/*
423+
* By default '!di->set' we clear DEBUGINFOD_URLS, so debuginfod
424+
* processing is not triggered, otherwise we set it to 'di->urls'
425+
* value. If 'di->urls' is "system" we keep DEBUGINFOD_URLS value.
426+
*/
427+
if (!di->set)
428+
setenv("DEBUGINFOD_URLS", "", 1);
429+
else if (di->urls && strcmp(di->urls, "system"))
430+
setenv("DEBUGINFOD_URLS", di->urls, 1);
431+
432+
pr_debug("DEBUGINFOD_URLS=%s\n", getenv("DEBUGINFOD_URLS"));
433+
}

tools/perf/util/util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,10 @@ void test_attr__init(void);
7171
struct perf_event_attr;
7272
void test_attr__open(struct perf_event_attr *attr, pid_t pid, struct perf_cpu cpu,
7373
int fd, int group_fd, unsigned long flags);
74+
75+
struct perf_debuginfod {
76+
const char *urls;
77+
bool set;
78+
};
79+
void perf_debuginfod_setup(struct perf_debuginfod *di);
7480
#endif /* GIT_COMPAT_UTIL_H */

0 commit comments

Comments
 (0)