Commit 16dccbb8 authored by Dapeng Mi's avatar Dapeng Mi Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarIan Rogers <irogers@google.com>
Reviewed-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarDapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Guo Ren <guoren@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Will Deacon <will@kernel.org>
Cc: Xudong Hao <xudong.hao@intel.com>
Cc: Zide Chen <zide.chen@intel.com>
[ Fixed up somme fuzz with s390 and riscv Build files wrt removing perf_regs.o ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e716e69c
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
perf-util-y += perf_regs.o

perf-util-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind.o

perf-util-y += pmu.o auxtrace.o cs-etm.o
+0 −13
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
#include "perf_regs.h"
#include "../../../util/perf_regs.h"

uint64_t arch__intr_reg_mask(void)
{
	return PERF_REGS_MASK;
}

uint64_t arch__user_reg_mask(void)
{
	return PERF_REGS_MASK;
}
+0 −36
Original line number Diff line number Diff line
@@ -103,39 +103,3 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)

	return SDT_ARG_VALID;
}

uint64_t arch__intr_reg_mask(void)
{
	return PERF_REGS_MASK;
}

uint64_t arch__user_reg_mask(void)
{
	struct perf_event_attr attr = {
		.type                   = PERF_TYPE_HARDWARE,
		.config                 = PERF_COUNT_HW_CPU_CYCLES,
		.sample_type            = PERF_SAMPLE_REGS_USER,
		.disabled               = 1,
		.exclude_kernel         = 1,
		.sample_period		= 1,
		.sample_regs_user	= PERF_REGS_MASK
	};
	int fd;

	if (getauxval(AT_HWCAP) & HWCAP_SVE)
		attr.sample_regs_user |= SMPL_REG_MASK(PERF_REG_ARM64_VG);

	/*
	 * Check if the pmu supports perf extended regs, before
	 * returning the register mask to sample.
	 */
	if (attr.sample_regs_user != PERF_REGS_MASK) {
		event_attr_init(&attr);
		fd = sys_perf_event_open(&attr, 0, -1, -1, 0);
		if (fd != -1) {
			close(fd);
			return attr.sample_regs_user;
		}
	}
	return PERF_REGS_MASK;
}

tools/perf/arch/csky/Build

deleted100644 → 0
+0 −1
Original line number Diff line number Diff line
perf-util-y += util/

tools/perf/arch/csky/util/Build

deleted100644 → 0
+0 −1
Original line number Diff line number Diff line
perf-util-y += perf_regs.o
Loading