backport perf bugfix patches from maillist.
Li Huafei (2): perf env: Normalize aarch64.* and arm64.* to arm64 in normalize_arch() perf annotate: Add error log in symbol__annotate()
tools/perf/util/annotate.c | 4 +++- tools/perf/util/env.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
From: Li Huafei lihuafei1@huawei.com
maillist inclusion category: bugfix bugzilla: 175624 https://gitee.com/openeuler/kernel/issues/I4DDEL
Reference: https://lkml.org/lkml/2021/7/26/599
--------------------------------
On my aarch64 big endian machine, the perf annotate does not work.
# perf annotate Percent | Source code & Disassembly of [kernel.kallsyms] for cycles (253 samples, percent: local period) -------------------------------------------------------------------------------------------------------------- Percent | Source code & Disassembly of [kernel.kallsyms] for cycles (1 samples, percent: local period) ------------------------------------------------------------------------------------------------------------ Percent | Source code & Disassembly of [kernel.kallsyms] for cycles (47 samples, percent: local period) ------------------------------------------------------------------------------------------------------------- ...
This is because the arch_find() function uses the normalized architecture name provided by normalize_arch(), and my machine's architecture name aarch64_be is not normalized to arm64. Like other architectures such as arm and powerpc, we can fuzzy match the architecture names associated with aarch64.* and normalize them.
It seems that there is also arm64_be architecture name, which we also normalize to arm64.
Signed-off-by: Li Huafei lihuafei1@huawei.com Reviewed-by: James Clark james.clark@arm.com Signed-off-by: Li Huafei lihuafei1@huawei.com Reviewed-by: Kuohai Xu xukuohai@huawei.com Signed-off-by: Chen Jun chenjun102@huawei.com --- tools/perf/util/env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index f0dceb527ca3..d5fd6bddaa6d 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -328,7 +328,7 @@ static const char *normalize_arch(char *arch) return "x86"; if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5)) return "sparc"; - if (!strcmp(arch, "aarch64") || !strcmp(arch, "arm64")) + if (!strncmp(arch, "aarch64", 7) || !strncmp(arch, "arm64", 5)) return "arm64"; if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110")) return "arm";
From: Li Huafei lihuafei1@huawei.com
maillist inclusion category: bugfix bugzilla: 175624 https://gitee.com/openeuler/kernel/issues/I4DDEL
Reference: https://lkml.org/lkml/2021/7/26/406
--------------------------------
When users use the perf annotate feature on unsupported machines, error logs should be printed for user feedback.
Signed-off-by: Li Huafei lihuafei1@huawei.com Reviewed-by: James Clark james.clark@arm.com Signed-off-by: Li Huafei lihuafei1@huawei.com Reviewed-by: Kuohai Xu xukuohai@huawei.com Signed-off-by: Chen Jun chenjun102@huawei.com --- tools/perf/util/annotate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 308189454788..4aaaf23b4878 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2178,8 +2178,10 @@ int symbol__annotate(struct map_symbol *ms, struct evsel *evsel, return errno;
args.arch = arch = arch__find(arch_name); - if (arch == NULL) + if (arch == NULL) { + pr_err("%s: unsupported arch %s\n", __func__, arch_name); return ENOTSUP; + }
if (parch) *parch = arch;