perf record: Refactor ARM64 leaf caller setup out of arch
Subsystems (2)
Ian Rogers
reviewerPATCH 1/1 perf record: Refactor ARM64 leaf caller setup out of arch
Code in tools/perf/arch causes portability issues/opaqueness and LTO issues due to the use of weak symbols. Move the adding of LR to the sample_user_regs into arm64-frame-pointer-unwind-support.c conditional on EM_HOST == EM_AARCH64 (false on all non-ARM64 builds). This also better encapsulates the use of the sampled registers by get_leaf_frame_caller_aarch64 and the set up by the new add_leaf_frame_caller_opts_aarch64, exposing opportunities for possibly sampling PC and SP to help the unwinder.
--- tools/perf/arch/arm64/util/Build | 1 - tools/perf/arch/arm64/util/machine.c | 12 ------------ tools/perf/builtin-record.c | 11 +++++------ tools/perf/util/arm64-frame-pointer-unwind-support.c | 6 ++++++ tools/perf/util/arm64-frame-pointer-unwind-support.h | 2 ++ 5 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 tools/perf/arch/arm64/util/machine.c
tools/perf/arch/arm64/util/Build +0 -1
@@ -5,7 +5,6 @@ perf-util-y += ../../arm/util/pmu.o perf-util-y += arm-spe.o perf-util-y += header.o perf-util-y += hisi-ptt.o -perf-util-y += machine.o perf-util-y += mem-events.o perf-util-y += pmu.o perf-util-y += tsc.o
tools/perf/arch/arm64/util/machine.c deleted +0 -12
@@ -1,12 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include "callchain.h" // prototype of arch__add_leaf_frame_record_opts -#include "perf_regs.h" -#include "record.h" - -#define SMPL_REG_MASK (b) (1ULL << (b)) - -void arch__add_leaf_frame_record_opts (struct record_opts *opts) -{ - opts->sample_user_regs |=SMPL_REG_MASK (PERF_REG_ARM64_LR ); -}
tools/perf/builtin-record.c +5 -6
@@ -14,6 +14,7 @@#include "util/parse-events.h" #include "util/config.h" +#include "util/arm64-frame-pointer-unwind-support.h" #include "util/callchain.h" #include "util/cgroup.h" #include "util/header.h"
@@ -3230,10 +3231,6 @@ static int record__parse_off_cpu_thresh(const struct option *opt,return 0 ; } -void __weak arch__add_leaf_frame_record_opts (struct record_opts *opts__maybe_unused ) -{ -} -static int parse_control_option (const struct option *opt,const char *str,int unset__maybe_unused )
@@ -4319,8 +4316,10 @@ int cmd_record(int argc, const char **argv)evlist__warn_user_requested_cpus (rec->evlist, rec->opts.target.cpu_list); -if (callchain_param.enabled && callchain_param.record_mode ==CALLCHAIN_FP ) -arch__add_leaf_frame_record_opts (&rec->opts); +if (callchain_param.enabled && callchain_param.record_mode ==CALLCHAIN_FP ) { +if (EM_HOST ==EM_AARCH64 ) +add_leaf_frame_caller_opts_aarch64 (&rec->opts); + } err = -ENOMEM ;if (evlist__create_maps (rec->evlist, &rec->opts.target) <0 ) {
tools/perf/util/arm64-frame-pointer-unwind-support.c +6 -0
@@ -2,6 +2,7 @@#include "arm64-frame-pointer-unwind-support.h" #include "callchain.h" #include "event.h" +#include "record.h" #include "unwind.h" #include <string.h>
@@ -16,6 +17,11 @@ struct entries {#define SMPL_REG_MASK (b) (1ULL << (b)) +void add_leaf_frame_caller_opts_aarch64 (struct record_opts *opts) +{ + opts->sample_user_regs |=SMPL_REG_MASK (PERF_REG_ARM64_LR ); +} +static bool get_leaf_frame_caller_enabled (struct perf_sample *sample) {struct regs_dump *regs;
tools/perf/util/arm64-frame-pointer-unwind-support.h +2 -0
@@ -5,8 +5,10 @@#include <linux/types.h> struct perf_sample ; +struct record_opts ;struct thread ; +void add_leaf_frame_caller_opts_aarch64 (struct record_opts *opts);u64 get_leaf_frame_caller_aarch64 (struct perf_sample *sample,struct thread *thread,int user_idx);#endif /* __PERF_ARM_FRAME_POINTER_UNWIND_SUPPORT_H */
Signature · 1 line
2.54.0.545.g6539524ca2-goog
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Orphaned function declaration `arch__add_leaf_frame_record_opts` left in…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Orphaned function declaration arch__add_leaf_frame_record_opts left in tools/perf/util/callchain.h. --
commit 9201ab7426a557fd23fbb8e0f9c2a95f023a9477
Author: Ian Rogers <[email protected]>
perf record: Refactor ARM64 leaf caller setup out of arch
Code in tools/perf/arch causes portability issues/opaqueness and LTO issues due to the use of weak symbols. Move the adding of LR to the sample_user_regs into arm64-frame-pointer-unwind-support.c conditional on EM_HOST == EM_AARCH64.
Quoted 4 lines
tools/perf/builtin-record.c +0
-0
[ ... ]
tools/perf/builtin-record.c static int record__parse_off_cpu_thresh(const struct option *opt, · line 3236
Quoted 8 lines
tools/perf/builtin-record.c +0
-4@@ -3230,10 +3231,6 @@ static int record__parse_off_cpu_thresh(const struct option *opt,return 0 ; } -void __weak arch__add_leaf_frame_record_opts (struct record_opts *opts__maybe_unused ) -{ -} -
Since the weak definition and usage of arch__add_leaf_frame_record_opts() are removed in this commit, should its declaration in tools/perf/util/callchain.h also be removed to avoid leaving an orphaned function declaration?
tools/perf/util/callchain.h:
[ ... ]
#endif
void arch__add_leaf_frame_record_opts(struct record_opts *opts);
char *callchain_list__sym_name(struct callchain_list *cl, [ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 114 lines · Ian Rogers
Code in
tools/perf/archcauses portability issues/opaqueness and LTO issues due to the use of weak symbols. Move the adding of LR to thesample_user_regsintoarm64-frame-pointer-unwind-support.cconditional onEM_HOST==EM_AARCH64(false on all non-ARM64 builds). This also better encapsulates the use of the sampled registers byget_leaf_frame_caller_aarch64and the set up by the newadd_leaf_frame_caller_opts_aarch64, exposing opportunities for possibly sampling PC and SP to help the unwinder.Signed-off-by Ian Rogers <[email protected]>--- tools/perf/arch/arm64/util/Build | 1 - tools/perf/arch/arm64/util/machine.c | 12 ------------ tools/perf/builtin-record.c | 11 +++++------ tools/perf/util/arm64-frame-pointer-unwind-support.c | 6 ++++++ tools/perf/util/arm64-frame-pointer-unwind-support.h | 2 ++ 5 files changed, 13 insertions(+), 19 deletions(-)delete mode 100644
tools/perf/arch/arm64/util/machine.ctools/perf/arch/arm64/util/Build +0
-1@@ -5,7 +5,6 @@ perf-util-y += ../../arm/util/pmu.o perf-util-y += arm-spe.o perf-util-y += header.o perf-util-y += hisi-ptt.o -perf-util-y += machine.o perf-util-y += mem-events.o perf-util-y += pmu.o perf-util-y += tsc.otools/perf/arch/arm64/util/machine.c deleted +0
-12@@ -1,12 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include "callchain.h" // prototype of arch__add_leaf_frame_record_opts -#include "perf_regs.h" -#include "record.h" - -#define SMPL_REG_MASK (b) (1ULL << (b)) - -void arch__add_leaf_frame_record_opts (struct record_opts *opts) -{ - opts->sample_user_regs |=SMPL_REG_MASK (PERF_REG_ARM64_LR ); -}tools/perf/builtin-record.c +5
-6@@ -14,6 +14,7 @@#include "util/parse-events.h" #include "util/config.h" +#include "util/arm64-frame-pointer-unwind-support.h" #include "util/callchain.h" #include "util/cgroup.h" #include "util/header.h" @@ -3230,10 +3231,6 @@ static int record__parse_off_cpu_thresh(const struct option *opt,return 0 ; } -void __weak arch__add_leaf_frame_record_opts (struct record_opts *opts__maybe_unused ) -{ -} -static int parse_control_option (const struct option *opt,const char *str,int unset__maybe_unused )@@ -4319,8 +4316,10 @@ int cmd_record(int argc, const char **argv)evlist__warn_user_requested_cpus (rec->evlist, rec->opts.target.cpu_list); -if (callchain_param.enabled && callchain_param.record_mode ==CALLCHAIN_FP ) -arch__add_leaf_frame_record_opts (&rec->opts); +if (callchain_param.enabled && callchain_param.record_mode ==CALLCHAIN_FP ) { +if (EM_HOST ==EM_AARCH64 ) +add_leaf_frame_caller_opts_aarch64 (&rec->opts); + } err = -ENOMEM ;if (evlist__create_maps (rec->evlist, &rec->opts.target) <0 ) {tools/perf/util/arm64-frame-pointer-unwind-support.c +6
-0@@ -2,6 +2,7 @@#include "arm64-frame-pointer-unwind-support.h" #include "callchain.h" #include "event.h" +#include "record.h" #include "unwind.h" #include <string.h> @@ -16,6 +17,11 @@ struct entries {#define SMPL_REG_MASK (b) (1ULL << (b)) +void add_leaf_frame_caller_opts_aarch64 (struct record_opts *opts) +{ + opts->sample_user_regs |=SMPL_REG_MASK (PERF_REG_ARM64_LR ); +} +static bool get_leaf_frame_caller_enabled (struct perf_sample *sample) {struct regs_dump *regs;tools/perf/util/arm64-frame-pointer-unwind-support.h +0
-0
tools/perf/util/arm64-frame-pointer-unwind-support.h line 14
Quoted 10 lines
tools/perf/util/arm64-frame-pointer-unwind-support.h +2
-0@@ -5,8 +5,10 @@#include <linux/types.h> struct perf_sample ; +struct record_opts ;struct thread ; +void add_leaf_frame_caller_opts_aarch64 (struct record_opts *opts);u64 get_leaf_frame_caller_aarch64 (struct perf_sample *sample,struct thread *thread,int user_idx);#endif /* __PERF_ARM_FRAME_POINTER_UNWIND_SUPPORT_H */
Ian Rogers
reviewerPATCH v2 1/1 perf record: Refactor ARM64 leaf caller setup out of arch
In reply to Ian RogersCode in tools/perf/arch causes portability issues/opaqueness and LTO issues due to the use of weak symbols. Move the adding of LR to the sample_user_regs into arm64-frame-pointer-unwind-support.c conditional on EM_HOST == EM_AARCH64 (false on all non-ARM64 builds). This also better encapsulates the use of the sampled registers by get_leaf_frame_caller_aarch64 and the set up by the new add_leaf_frame_caller_opts_aarch64, exposing opportunities for possibly sampling PC and SP to help the unwinder.
--- tools/perf/arch/arm64/util/Build | 1 - tools/perf/arch/arm64/util/machine.c | 12 ------------ tools/perf/builtin-record.c | 11 +++++------ tools/perf/util/arm64-frame-pointer-unwind-support.c | 6 ++++++ tools/perf/util/arm64-frame-pointer-unwind-support.h | 2 ++ tools/perf/util/callchain.h | 2 -- 6 files changed, 13 insertions(+), 21 deletions(-) delete mode 100644 tools/perf/arch/arm64/util/machine.c
tools/perf/arch/arm64/util/Build +0 -1
@@ -5,7 +5,6 @@ perf-util-y += ../../arm/util/pmu.o perf-util-y += arm-spe.o perf-util-y += header.o perf-util-y += hisi-ptt.o -perf-util-y += machine.o perf-util-y += mem-events.o perf-util-y += pmu.o perf-util-y += tsc.o
tools/perf/arch/arm64/util/machine.c deleted +0 -12
@@ -1,12 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include "callchain.h" // prototype of arch__add_leaf_frame_record_opts -#include "perf_regs.h" -#include "record.h" - -#define SMPL_REG_MASK (b) (1ULL << (b)) - -void arch__add_leaf_frame_record_opts (struct record_opts *opts) -{ - opts->sample_user_regs |=SMPL_REG_MASK (PERF_REG_ARM64_LR ); -}
tools/perf/builtin-record.c +5 -6
@@ -14,6 +14,7 @@#include "util/parse-events.h" #include "util/config.h" +#include "util/arm64-frame-pointer-unwind-support.h" #include "util/callchain.h" #include "util/cgroup.h" #include "util/header.h"
@@ -3230,10 +3231,6 @@ static int record__parse_off_cpu_thresh(const struct option *opt,return 0 ; } -void __weak arch__add_leaf_frame_record_opts (struct record_opts *opts__maybe_unused ) -{ -} -static int parse_control_option (const struct option *opt,const char *str,int unset__maybe_unused )
@@ -4319,8 +4316,10 @@ int cmd_record(int argc, const char **argv)evlist__warn_user_requested_cpus (rec->evlist, rec->opts.target.cpu_list); -if (callchain_param.enabled && callchain_param.record_mode ==CALLCHAIN_FP ) -arch__add_leaf_frame_record_opts (&rec->opts); +if (callchain_param.enabled && callchain_param.record_mode ==CALLCHAIN_FP ) { +if (EM_HOST ==EM_AARCH64 ) +add_leaf_frame_caller_opts_aarch64 (&rec->opts); + } err = -ENOMEM ;if (evlist__create_maps (rec->evlist, &rec->opts.target) <0 ) {
tools/perf/util/arm64-frame-pointer-unwind-support.c +6 -0
@@ -2,6 +2,7 @@#include "arm64-frame-pointer-unwind-support.h" #include "callchain.h" #include "event.h" +#include "record.h" #include "unwind.h" #include <string.h>
@@ -16,6 +17,11 @@ struct entries {#define SMPL_REG_MASK (b) (1ULL << (b)) +void add_leaf_frame_caller_opts_aarch64 (struct record_opts *opts) +{ + opts->sample_user_regs |=SMPL_REG_MASK (PERF_REG_ARM64_LR ); +} +static bool get_leaf_frame_caller_enabled (struct perf_sample *sample) {struct regs_dump *regs;
tools/perf/util/arm64-frame-pointer-unwind-support.h +2 -0
@@ -5,8 +5,10 @@#include <linux/types.h> struct perf_sample ; +struct record_opts ;struct thread ; +void add_leaf_frame_caller_opts_aarch64 (struct record_opts *opts);u64 get_leaf_frame_caller_aarch64 (struct perf_sample *sample,struct thread *thread,int user_idx);#endif /* __PERF_ARM_FRAME_POINTER_UNWIND_SUPPORT_H */
tools/perf/util/callchain.h +0 -2
@@ -277,8 +277,6 @@ static inline int arch_skip_callchain_idx(struct thread *thread __maybe_unused, }#endif -void arch__add_leaf_frame_record_opts (struct record_opts *opts); -char *callchain_list__sym_name (struct callchain_list *cl,char *bf,size_t bfsize,bool show_dso); char *callchain_node__scnprintf_value(struct callchain_node *node,
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
Ian Rogers
reviewerQuoted 10 lines · Ian Rogers
Code in
tools/perf/archcauses portability issues/opaqueness and LTO issues due to the use of weak symbols. Move the adding of LR to thesample_user_regsintoarm64-frame-pointer-unwind-support.cconditional onEM_HOST==EM_AARCH64(false on all non-ARM64 builds). This also better encapsulates the use of the sampled registers byget_leaf_frame_caller_aarch64and the set up by the newadd_leaf_frame_caller_opts_aarch64, exposing opportunities for possibly sampling PC and SP to help the unwinder.
Quoted 2 lines
Reviewed-by James Clark <[email protected]>Signed-off-by Ian Rogers <[email protected]>
Ping.
Thanks,
Ian
Quoted 131 lines
--- tools/perf/arch/arm64/util/Build | 1 - tools/perf/arch/arm64/util/machine.c | 12 ------------ tools/perf/builtin-record.c | 11 +++++------ tools/perf/util/arm64-frame-pointer-unwind-support.c | 6 ++++++ tools/perf/util/arm64-frame-pointer-unwind-support.h | 2 ++ tools/perf/util/callchain.h | 2 -- 6 files changed, 13 insertions(+), 21 deletions(-) delete mode 100644 tools/perf/arch/arm64/util/machine.ctools/perf/arch/arm64/util/Build +0
-1@@ -5,7 +5,6 @@ perf-util-y += ../../arm/util/pmu.o perf-util-y += arm-spe.o perf-util-y += header.o perf-util-y += hisi-ptt.o -perf-util-y += machine.o perf-util-y += mem-events.o perf-util-y += pmu.o perf-util-y += tsc.otools/perf/arch/arm64/util/machine.c deleted +0
-12@@ -1,12 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include "callchain.h" // prototype of arch__add_leaf_frame_record_opts -#include "perf_regs.h" -#include "record.h" - -#define SMPL_REG_MASK (b) (1ULL << (b)) - -void arch__add_leaf_frame_record_opts (struct record_opts *opts) -{ - opts->sample_user_regs |=SMPL_REG_MASK (PERF_REG_ARM64_LR ); -}tools/perf/builtin-record.c +5
-6@@ -14,6 +14,7 @@#include "util/parse-events.h" #include "util/config.h" +#include "util/arm64-frame-pointer-unwind-support.h" #include "util/callchain.h" #include "util/cgroup.h" #include "util/header.h" @@ -3230,10 +3231,6 @@ static int record__parse_off_cpu_thresh(const struct option *opt,return 0 ; } -void __weak arch__add_leaf_frame_record_opts (struct record_opts *opts__maybe_unused ) -{ -} -static int parse_control_option (const struct option *opt,const char *str,int unset__maybe_unused )@@ -4319,8 +4316,10 @@ int cmd_record(int argc, const char **argv)evlist__warn_user_requested_cpus (rec->evlist, rec->opts.target.cpu_list); -if (callchain_param.enabled && callchain_param.record_mode ==CALLCHAIN_FP ) -arch__add_leaf_frame_record_opts (&rec->opts); +if (callchain_param.enabled && callchain_param.record_mode ==CALLCHAIN_FP ) { +if (EM_HOST ==EM_AARCH64 ) +add_leaf_frame_caller_opts_aarch64 (&rec->opts); + } err = -ENOMEM ;if (evlist__create_maps (rec->evlist, &rec->opts.target) <0 ) {tools/perf/util/arm64-frame-pointer-unwind-support.c +6
-0@@ -2,6 +2,7 @@#include "arm64-frame-pointer-unwind-support.h" #include "callchain.h" #include "event.h" +#include "record.h" #include "unwind.h" #include <string.h> @@ -16,6 +17,11 @@ struct entries {#define SMPL_REG_MASK (b) (1ULL << (b)) +void add_leaf_frame_caller_opts_aarch64 (struct record_opts *opts) +{ + opts->sample_user_regs |=SMPL_REG_MASK (PERF_REG_ARM64_LR ); +} +static bool get_leaf_frame_caller_enabled (struct perf_sample *sample) {struct regs_dump *regs;tools/perf/util/arm64-frame-pointer-unwind-support.h +2
-0@@ -5,8 +5,10 @@#include <linux/types.h> struct perf_sample ; +struct record_opts ;struct thread ; +void add_leaf_frame_caller_opts_aarch64 (struct record_opts *opts);u64 get_leaf_frame_caller_aarch64 (struct perf_sample *sample,struct thread *thread,int user_idx);#endif /* __PERF_ARM_FRAME_POINTER_UNWIND_SUPPORT_H */ tools/perf/util/callchain.h +0
-3@@ -277,8 +277,6 @@ static inline int arch_skip_callchain_idx(struct thread *thread __maybe_unused, }#endif -void arch__add_leaf_frame_record_opts (struct record_opts *opts); -char *callchain_list__sym_name (struct callchain_list *cl,char *bf,size_t bfsize,bool show_dso); char *callchain_node__scnprintf_value(struct callchain_node *node, --2.54.0.563.g4f69b47b94-goog
Quoted 11 lines · Ian Rogers
Quoted 10 lines · Ian Rogers
Code in
tools/perf/archcauses portability issues/opaqueness and LTO issues due to the use of weak symbols. Move the adding of LR to thesample_user_regsintoarm64-frame-pointer-unwind-support.cconditional onEM_HOST==EM_AARCH64(false on all non-ARM64 builds). This also better encapsulates the use of the sampled registers byget_leaf_frame_caller_aarch64and the set up by the newadd_leaf_frame_caller_opts_aarch64, exposing opportunities for possibly sampling PC and SP to help the unwinder.
Quoted 4 lines
Quoted 2 lines
Reviewed-by James Clark <[email protected]>Signed-off-by Ian Rogers <[email protected]>Ping.
Thanks, applied to perf-tools-next, for v7.2.
- Arnaldo