Commit 9a4e47ef authored by Leo Yan's avatar Leo Yan Committed by Namhyung Kim
Browse files

perf parse-regs: Introduce a weak function arch__sample_reg_masks()



Every architecture can provide a register list for sampling. If an
architecture doesn't support register sampling, it won't define the data
structure 'sample_reg_masks'. Consequently, any code using this
structure must be protected by the macro 'HAVE_PERF_REGS_SUPPORT'.

This patch defines a weak function, arch__sample_reg_masks(), which will
be replaced by an architecture-defined function for returning the
architecture's register list. With this refactoring, the function always
exists, the condition checking for 'HAVE_PERF_REGS_SUPPORT' is not
needed anymore, so remove it.

Signed-off-by: default avatarLeo Yan <leo.yan@linux.dev>
Reviewed-by: default avatarIan Rogers <irogers@google.com>
Cc: James Clark <james.clark@arm.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Ming Wang <wangming01@loongson.cn>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: linux-csky@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240214113947.240957-4-leo.yan@linux.dev
parent ec87c99d
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
#include "perf_regs.h"
#include "../../../util/perf_regs.h"

const struct sample_reg sample_reg_masks[] = {
static const struct sample_reg sample_reg_masks[] = {
	SMPL_REG_END
};

@@ -15,3 +15,8 @@ uint64_t arch__user_reg_mask(void)
{
	return PERF_REGS_MASK;
}

const struct sample_reg *arch__sample_reg_masks(void)
{
	return sample_reg_masks;
}
+2 −0
Original line number Diff line number Diff line
@@ -12,5 +12,7 @@

void arch__add_leaf_frame_record_opts(struct record_opts *opts)
{
	const struct sample_reg *sample_reg_masks = arch__sample_reg_masks();

	opts->sample_user_regs |= sample_reg_masks[PERF_REG_ARM64_LR].mask;
}
+6 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
#define HWCAP_SVE	(1 << 22)
#endif

const struct sample_reg sample_reg_masks[] = {
static const struct sample_reg sample_reg_masks[] = {
	SMPL_REG(x0, PERF_REG_ARM64_X0),
	SMPL_REG(x1, PERF_REG_ARM64_X1),
	SMPL_REG(x2, PERF_REG_ARM64_X2),
@@ -175,3 +175,8 @@ uint64_t arch__user_reg_mask(void)
	}
	return PERF_REGS_MASK;
}

const struct sample_reg *arch__sample_reg_masks(void)
{
	return sample_reg_masks;
}
+6 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
#include "perf_regs.h"
#include "../../util/perf_regs.h"

const struct sample_reg sample_reg_masks[] = {
static const struct sample_reg sample_reg_masks[] = {
	SMPL_REG_END
};

@@ -15,3 +15,8 @@ uint64_t arch__user_reg_mask(void)
{
	return PERF_REGS_MASK;
}

const struct sample_reg *arch__sample_reg_masks(void)
{
	return sample_reg_masks;
}
+6 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
#include "perf_regs.h"
#include "../../../util/perf_regs.h"

const struct sample_reg sample_reg_masks[] = {
static const struct sample_reg sample_reg_masks[] = {
	SMPL_REG_END
};

@@ -15,3 +15,8 @@ uint64_t arch__user_reg_mask(void)
{
	return PERF_REGS_MASK;
}

const struct sample_reg *arch__sample_reg_masks(void)
{
	return sample_reg_masks;
}
Loading