perf tools: Fix not finding kcore in buildid cache
Adrian Hunter
reviewerPATCH 1/1 perf tools: Fix not finding kcore in buildid cache
The logic was not looking in the buildid cache for kcore if the host kernel buildid did not match the recorded kernel buildid.
--- tools/perf/util/symbol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/util/symbol.c +7 -2
@@ -1526,14 +1526,15 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)build_id__sprintf (dso->build_id,sizeof (dso->build_id), sbuild_id); +scnprintf (path,sizeof (path),"%s/[kernel.kcore]/%s" , buildid_dir, + sbuild_id); +/* Use /proc/kallsyms if possible */ if (is_host) {DIR *d;int fd;/* If no cached kcore go with /proc/kallsyms */ -scnprintf (path,sizeof (path),"%s/[kernel.kcore]/%s" , - buildid_dir, sbuild_id); d =opendir (path);if (!d) goto proc_kallsyms;
@@ -1558,6 +1559,10 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map) goto proc_kallsyms; } +/* Find kallsyms in build-id cache with kcore */ +if (!find_matching_kcore (map, path,sizeof (path))) +return strdup (path); +scnprintf (path,sizeof (path),"%s/[kernel.kallsyms]/%s" , buildid_dir, sbuild_id);
Signature · 1 line
1.7.11.7
Quoted 3 lines · Adrian Hunter
The logic was not looking in the buildid cache for kcore if the host kernel buildid did not match the recorded kernel buildid.
It would be nice to also include the specific failure mode in the
changelog: exactly how can users run into this. That will be more useful to most people reading these changelogs than a more abstract bug description.
Thanks,
Ingo
Adrian Hunter
reviewerQuoted 11 lines · Ingo Molnar
Quoted 3 lines · Adrian Hunter
The logic was not looking in the buildid cache for kcore if the host kernel buildid did not match the recorded kernel buildid.
It would be nice to also include the specific failure mode in the
changelog: exactly how can users run into this. That will be more useful to most people reading these changelogs than a more abstract bug description.
The preconditions for the problem are that kcore is in the buildid cache and that the running kernel has a different buildid e.g.
$ perf buildid-list | grep kernel.kallsyms b18fbe769dea12513028a4287dae02efc1582c29 [kernel.kallsyms]
$ perf record -o /tmp/junk true >/dev/null 2>&1 ; perf buildid-list -i /tmp/junk | grep kernel.kallsyms 504f9fd9328c40714995ce76fe1354c6e90136ce [kernel.kallsyms]
Before the patch:
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kallsyms]/b18fbe769dea12513028a4287dae02efc1582c29 for symbols
perf script stopped
After the patch:
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kcore for kernel object code Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kallsyms for symbols
perf script stopped
Quoted 38 lines · Adrian Hunter
Quoted 11 lines · Ingo Molnar
Quoted 3 lines · Adrian Hunter
The logic was not looking in the buildid cache for kcore if the host kernel buildid did not match the recorded kernel buildid.
It would be nice to also include the specific failure mode in the
changelog: exactly how can users run into this. That will be more useful to most people reading these changelogs than a more abstract bug description.The preconditions for the problem are that kcore is in the buildid cache and that the running kernel has a different buildid e.g.
$ perf buildid-list | grep kernel.kallsyms b18fbe769dea12513028a4287dae02efc1582c29 [kernel.kallsyms]$ perf record -o /tmp/junk true >/dev/null 2>&1 ; perf buildid-list -i /tmp/junk | grep kernel.kallsyms 504f9fd9328c40714995ce76fe1354c6e90136ce [kernel.kallsyms]Before the patch:
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kallsyms]/b18fbe769dea12513028a4287dae02efc1582c29 for symbolsperf script stopped
After the patch:
Quoted 7 lines
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kcore for kernel object code Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kallsyms for symbolsperf script stopped
So the result of the patch is that kernel symbols get resolved/annotated correctly, as expected from the live kcore feature, right?
Thanks,
Ingo
Adrian Hunter
reviewerQuoted 47 lines · Ingo Molnar
Quoted 44 lines · Adrian Hunter
Quoted 11 lines · Ingo Molnar
Quoted 3 lines · Adrian Hunter
The logic was not looking in the buildid cache for kcore if the host kernel buildid did not match the recorded kernel buildid.
It would be nice to also include the specific failure mode in the
changelog: exactly how can users run into this. That will be more useful to most people reading these changelogs than a more abstract bug description.The preconditions for the problem are that kcore is in the buildid cache and that the running kernel has a different buildid e.g.
$ perf buildid-list | grep kernel.kallsyms b18fbe769dea12513028a4287dae02efc1582c29 [kernel.kallsyms]$ perf record -o /tmp/junk true >/dev/null 2>&1 ; perf buildid-list -i /tmp/junk | grep kernel.kallsyms 504f9fd9328c40714995ce76fe1354c6e90136ce [kernel.kallsyms]Before the patch:
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kallsyms]/b18fbe769dea12513028a4287dae02efc1582c29 for symbolsperf script stopped
After the patch:
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kcore for kernel object code Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kallsyms for symbols
Quoted 5 lines
Quoted 1 line
perf script stopped
So the result of the patch is that kernel symbols get resolved/annotated correctly, as expected from the live kcore feature, right?
Yes but this is the non-live case i.e. the kernel has changed and we are looking at a special copy of kcore that we placed in the buildid cache (using "perf buildid-cache -v -k /proc/kcore") when the data was recorded.
Quoted 50 lines · Adrian Hunter
Quoted 49 lines · Ingo Molnar
Quoted 45 lines · Adrian Hunter
Quoted 11 lines · Ingo Molnar
Quoted 3 lines · Adrian Hunter
The logic was not looking in the buildid cache for kcore if the host kernel buildid did not match the recorded kernel buildid.
It would be nice to also include the specific failure mode in the
changelog: exactly how can users run into this. That will be more useful to most people reading these changelogs than a more abstract bug description.The preconditions for the problem are that kcore is in the buildid cache and that the running kernel has a different buildid e.g.
$ perf buildid-list | grep kernel.kallsyms b18fbe769dea12513028a4287dae02efc1582c29 [kernel.kallsyms]$ perf record -o /tmp/junk true >/dev/null 2>&1 ; perf buildid-list -i /tmp/junk | grep kernel.kallsyms 504f9fd9328c40714995ce76fe1354c6e90136ce [kernel.kallsyms]Before the patch:
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kallsyms]/b18fbe769dea12513028a4287dae02efc1582c29 for symbolsperf script stopped
After the patch:
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kcore for kernel object code Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kallsyms for symbolsperf script stopped
Quoted 7 lines
Quoted 3 lines
So the result of the patch is that kernel symbols get resolved/annotated correctly, as expected from the live kcore feature, right?
Yes but this is the non-live case i.e. the kernel has changed and we are looking at a special copy of kcore that we placed in the buildid cache (using "perf buildid-cache -v -k
/proc/kcore") when the data was recorded.
Okay.
Thanks,
Ingo
Em Wed, Nov 27, 2013 at 12:52:47PM +0100, Ingo Molnar escreveu:
Quoted 57 lines · Adrian Hunter
Quoted 55 lines · Ingo Molnar
Quoted 52 lines · Adrian Hunter
Quoted 39 lines · Ingo Molnar
Quoted 11 lines · Adrian Hunter
Quoted 4 lines
The logic was not looking in the buildid cache for kcore if the host kernel buildid did not match the recorded kernel buildid.
It would be nice to also include the specific failure mode in the
changelog: exactly how can users run into this. That will be more useful to most people reading these changelogs than a more abstract bug description.The preconditions for the problem are that kcore is in the buildid cache and that the running kernel has a different buildid e.g.
$ perf buildid-list | grep kernel.kallsyms b18fbe769dea12513028a4287dae02efc1582c29 [kernel.kallsyms]$ perf record -o /tmp/junk true >/dev/null 2>&1 ; perf buildid-list -i /tmp/junk | grep kernel.kallsyms 504f9fd9328c40714995ce76fe1354c6e90136ce [kernel.kallsyms]Before the patch:
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kallsyms]/b18fbe769dea12513028a4287dae02efc1582c29 for symbolsperf script stopped
After the patch:
Quoted 7 lines
$ perf script -v >out.txt build id event received for [kernel.kallsyms]: b18fbe769dea12513028a4287dae02efc1582c29 <SNIP> Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kcore for kernel object code Using /home/ahunter/.debug/[kernel.kcore]/b18fbe769dea12513028a4287dae02efc1582c29/2013112617084061/kallsyms for symbolsperf script stopped
So the result of the patch is that kernel symbols get resolved/annotated correctly, as expected from the live kcore feature, right?
Quoted 5 lines
Quoted 3 lines
Yes but this is the non-live case i.e. the kernel has changed and we are looking at a special copy of kcore that we placed in the buildid cache (using "perf buildid-cache -v -k
/proc/kcore") when the data was recorded.Okay.
Thanks for the questions and answers, I'll edit it and add to the patch.
- Arnaldo
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf symbols: Fix not finding kcore in buildid cache
In reply to Adrian Hunterperf symbols: Fix not finding kcore in buildid cache
Commit-ID: 449867e346bfd52c5df6bba5b706a795c35e78d4 Gitweb: http://git.kernel.org/tip/449867e346bfd52c5df6bba5b706a795c35e78d4 Author: Adrian Hunter <[email protected]> AuthorDate: Tue, 26 Nov 2013 15:19:24 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 27 Nov 2013 14:58:38 -0300
perf symbols: Fix not finding kcore in buildid cache
The logic was not looking in the buildid cache for kcore if the host kernel buildid did not match the recorded kernel buildid.
This affects the non-live case i.e. the kernel has changed and we are looking at a special copy of kcore that we placed in the buildid cache (using "perf buildid-cache -v -k /proc/kcore") when the data was recorded.
After this fix kernel symbols get resolved/annotated correctly.
--- tools/perf/util/symbol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/util/symbol.c +7 -2
@@ -1526,14 +1526,15 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)build_id__sprintf (dso->build_id,sizeof (dso->build_id), sbuild_id); +scnprintf (path,sizeof (path),"%s/[kernel.kcore]/%s" , buildid_dir, + sbuild_id); +/* Use /proc/kallsyms if possible */ if (is_host) {DIR *d;int fd;/* If no cached kcore go with /proc/kallsyms */ -scnprintf (path,sizeof (path),"%s/[kernel.kcore]/%s" , - buildid_dir, sbuild_id); d =opendir (path);if (!d) goto proc_kallsyms;
@@ -1558,6 +1559,10 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map) goto proc_kallsyms; } +/* Find kallsyms in build-id cache with kcore */ +if (!find_matching_kcore (map, path,sizeof (path))) +return strdup (path); +scnprintf (path,sizeof (path),"%s/[kernel.kallsyms]/%s" , buildid_dir, sbuild_id);