perf: buildid: Print error for creating folder failure
PATCH 1/1 perf: buildid: Print error for creating folder failure
The mkdir_p() function will fail to create a buildid cache folder if the folder name is not an absolute path. As a result, the cache folder is empty after recording.
Print an error to remind users to use an absolute path name or check permissions. Update the documentation to reflect the requirement of using an absolute path name.
After:
# perf --buildid-dir debug_dir record -- test_program
...
Failed to create build_id cache folder: debug_dir/[kernel.kallsyms]/5c81911cab18f69bab96f8a1fae64a9f1d83b104.
Use an absolute path name or check permissions.Signed-off-by Leo Yan <[email protected]>
--- tools/perf/Documentation/perf-config.txt | 2 ++ tools/perf/Documentation/perf.txt | 4 ++-- tools/perf/util/build-id.c | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-config.txt +2 -0
@@ -236,6 +236,8 @@ buildid.*:: cache location, or to disable it altogether. If you want to disable it, set buildid.dir to /dev/null. The default is $HOME/.debug + This option must be an absolute path name. + buildid-cache.*:: buildid-cache.debuginfod=URLs Specify debuginfod URLs to be used when retrieving perf.data binaries,
tools/perf/Documentation/perf.txt +2 -2
@@ -37,8 +37,8 @@ OPTIONS Do not set pager. --buildid-dir:: - Setup buildid cache directory. It has higher priority - than buildid.dir config file option. + Setup buildid cache directory with an absolute path name. + It has higher priority than buildid.dir config file option. --list-cmds:: List the most commonly used perf commands.
tools/perf/util/build-id.c +5 -1
@@ -637,8 +637,12 @@ build_id_cache__add(const char *sbuild_id, const char *name, const char *realnamif (unlink (dir_name)) goto out_free; -if (mkdir_p (dir_name,0755 )) +if (mkdir_p (dir_name,0755 )) { +pr_err ("Failed to create build_id cache folder: %s.\n" +" Use an absolute path name or check permissions.\n" , + dir_name); goto out_free; + }/* Save the allocated buildid dirname */ if (asprintf(&filename, "%s/%s", dir_name,
Signature · 1 line
2.25.1