Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
9bce13ea 2eea0b56

+70 -12
+4 -1
tools/perf/Documentation/perf-buildid-cache.txt
··· 74 74 used when creating a uprobe for a process that resides in a 75 75 different mount namespace from the perf(1) utility. 76 76 77 - --debuginfod=URLs:: 77 + --debuginfod[=URLs]:: 78 78 Specify debuginfod URL to be used when retrieving perf.data binaries, 79 79 it follows the same syntax as the DEBUGINFOD_URLS variable, like: 80 80 81 81 buildid-cache.debuginfod=http://192.168.122.174:8002 82 + 83 + If the URLs is not specified, the value of DEBUGINFOD_URLS 84 + system environment variable is used. 82 85 83 86 SEE ALSO 84 87 --------
+9
tools/perf/Documentation/perf-config.txt
··· 587 587 Use 'n' control blocks in asynchronous (Posix AIO) trace writing 588 588 mode ('n' default: 1, max: 4). 589 589 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 + 590 599 diff.*:: 591 600 diff.order:: 592 601 This option sets the number of columns to sort the result.
+9
tools/perf/Documentation/perf-record.txt
··· 715 715 716 716 include::intel-hybrid.txt[] 717 717 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 + 718 727 SEE ALSO 719 728 -------- 720 729 linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-intel-pt[1]
+14 -11
tools/perf/builtin-buildid-cache.c
··· 351 351 352 352 static int perf_buildid_cache_config(const char *var, const char *value, void *cb) 353 353 { 354 - const char **debuginfod = cb; 354 + struct perf_debuginfod *di = cb; 355 355 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 + } 358 362 359 363 return 0; 360 364 } ··· 377 373 *purge_name_list_str = NULL, 378 374 *missing_filename = NULL, 379 375 *update_name_list_str = NULL, 380 - *kcore_filename = NULL, 381 - *debuginfod = NULL; 376 + *kcore_filename = NULL; 377 + struct perf_debuginfod debuginfod = { }; 382 378 char sbuf[STRERR_BUFSIZE]; 383 379 384 380 struct perf_data data = { ··· 403 399 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), 404 400 OPT_STRING('u', "update", &update_name_list_str, "file list", 405 401 "file(s) to update"), 406 - OPT_STRING(0, "debuginfod", &debuginfod, "debuginfod url", 407 - "set debuginfod url"), 402 + OPT_STRING_OPTARG_SET(0, "debuginfod", &debuginfod.urls, 403 + &debuginfod.set, "debuginfod urls", 404 + "Enable debuginfod data retrieval from DEBUGINFOD_URLS or specified urls", 405 + "system"), 408 406 OPT_INCR('v', "verbose", &verbose, "be more verbose"), 409 407 OPT_INTEGER(0, "target-ns", &ns_id, "target pid for namespace context"), 410 408 OPT_END() ··· 431 425 if (argc || !(list_files || opts_flag)) 432 426 usage_with_options(buildid_cache_usage, buildid_cache_options); 433 427 434 - if (debuginfod) { 435 - pr_debug("DEBUGINFOD_URLS=%s\n", debuginfod); 436 - setenv("DEBUGINFOD_URLS", debuginfod, 1); 437 - } 428 + perf_debuginfod_setup(&debuginfod); 438 429 439 430 /* -l is exclusive. It can not be used with other options. */ 440 431 if (list_files && opts_flag) {
+13
tools/perf/builtin-record.c
··· 111 111 unsigned long long samples; 112 112 struct mmap_cpu_mask affinity_mask; 113 113 unsigned long output_max_size; /* = 0: unlimited */ 114 + struct perf_debuginfod debuginfod; 114 115 }; 115 116 116 117 static volatile int done; ··· 2178 2177 rec->opts.nr_cblocks = nr_cblocks_default; 2179 2178 } 2180 2179 #endif 2180 + if (!strcmp(var, "record.debuginfod")) { 2181 + rec->debuginfod.urls = strdup(value); 2182 + if (!rec->debuginfod.urls) 2183 + return -ENOMEM; 2184 + rec->debuginfod.set = true; 2185 + } 2181 2186 2182 2187 return 0; 2183 2188 } ··· 2674 2667 parse_control_option), 2675 2668 OPT_CALLBACK(0, "synth", &record.opts, "no|all|task|mmap|cgroup", 2676 2669 "Fine-tune event synthesis: default=all", parse_record_synth_option), 2670 + OPT_STRING_OPTARG_SET(0, "debuginfod", &record.debuginfod.urls, 2671 + &record.debuginfod.set, "debuginfod urls", 2672 + "Enable debuginfod data retrieval from DEBUGINFOD_URLS or specified urls", 2673 + "system"), 2677 2674 OPT_END() 2678 2675 }; 2679 2676 ··· 2730 2719 err = symbol__validate_sym_arguments(); 2731 2720 if (err) 2732 2721 return err; 2722 + 2723 + perf_debuginfod_setup(&record.debuginfod); 2733 2724 2734 2725 /* Make system wide (-a) the default target. */ 2735 2726 if (!argc && target__none(&rec->opts.target))
+15
tools/perf/util/util.c
··· 416 416 } 417 417 return strcpy(buf, "perf"); 418 418 } 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 + }
+6
tools/perf/util/util.h
··· 71 71 struct perf_event_attr; 72 72 void test_attr__open(struct perf_event_attr *attr, pid_t pid, struct perf_cpu cpu, 73 73 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); 74 80 #endif /* GIT_COMPAT_UTIL_H */