Skip to content

Commit 16dccbb

Browse files
Dapeng Miacmel
authored andcommitted
perf regs: Remove __weak attributive arch__xxx_reg_mask() functions
Currently, some architecture-specific perf-regs functions, such as arch__intr_reg_mask() and arch__user_reg_mask(), are defined with the __weak attribute. This approach ensures that only functions matching the architecture of the build/run host are compiled and executed, reducing build time and binary size. However, this __weak attribute restricts these functions to be called only on the same architecture, preventing cross-architecture functionality. For example, a perf.data file captured on x86 cannot be parsed on an ARM platform. To address this limitation, this patch removes the __weak attribute from these perf-regs functions. The architecture-specific code is moved from the arch/ directory to the util/perf-regs-arch/ directory. The appropriate architectural functions are then called based on the EM_HOST. No functional changes are intended. Suggested-by: Ian Rogers <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Signed-off-by: Dapeng Mi <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexandre Ghiti <[email protected]> Cc: Guo Ren <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: John Garry <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Falcon <[email protected]> Cc: Will Deacon <[email protected]> Cc: Xudong Hao <[email protected]> Cc: Zide Chen <[email protected]> [ Fixed up somme fuzz with s390 and riscv Build files wrt removing perf_regs.o ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent e716e69 commit 16dccbb

30 files changed

Lines changed: 332 additions & 236 deletions

tools/perf/arch/arm/util/Build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
perf-util-y += perf_regs.o
2-
31
perf-util-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
42

53
perf-util-y += pmu.o auxtrace.o cs-etm.o

tools/perf/arch/arm/util/perf_regs.c

Lines changed: 0 additions & 13 deletions
This file was deleted.

tools/perf/arch/arm64/util/perf_regs.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -103,39 +103,3 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)
103103

104104
return SDT_ARG_VALID;
105105
}
106-
107-
uint64_t arch__intr_reg_mask(void)
108-
{
109-
return PERF_REGS_MASK;
110-
}
111-
112-
uint64_t arch__user_reg_mask(void)
113-
{
114-
struct perf_event_attr attr = {
115-
.type = PERF_TYPE_HARDWARE,
116-
.config = PERF_COUNT_HW_CPU_CYCLES,
117-
.sample_type = PERF_SAMPLE_REGS_USER,
118-
.disabled = 1,
119-
.exclude_kernel = 1,
120-
.sample_period = 1,
121-
.sample_regs_user = PERF_REGS_MASK
122-
};
123-
int fd;
124-
125-
if (getauxval(AT_HWCAP) & HWCAP_SVE)
126-
attr.sample_regs_user |= SMPL_REG_MASK(PERF_REG_ARM64_VG);
127-
128-
/*
129-
* Check if the pmu supports perf extended regs, before
130-
* returning the register mask to sample.
131-
*/
132-
if (attr.sample_regs_user != PERF_REGS_MASK) {
133-
event_attr_init(&attr);
134-
fd = sys_perf_event_open(&attr, 0, -1, -1, 0);
135-
if (fd != -1) {
136-
close(fd);
137-
return attr.sample_regs_user;
138-
}
139-
}
140-
return PERF_REGS_MASK;
141-
}

tools/perf/arch/csky/Build

Lines changed: 0 additions & 1 deletion
This file was deleted.

tools/perf/arch/csky/util/Build

Lines changed: 0 additions & 1 deletion
This file was deleted.

tools/perf/arch/csky/util/perf_regs.c

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
perf-util-y += header.o
2-
perf-util-y += perf_regs.o
32

43
perf-util-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
54
perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o

tools/perf/arch/loongarch/util/perf_regs.c

Lines changed: 0 additions & 13 deletions
This file was deleted.

tools/perf/arch/mips/util/Build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
perf-util-y += perf_regs.o
21
perf-util-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o

tools/perf/arch/mips/util/perf_regs.c

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)