Commit 5644a37a authored by Anshuman Khandual's avatar Anshuman Khandual Committed by Junhao He
Browse files

perf branch: Add branch privilege information request flag

mainline inclusion
from mainline-v6.1-rc1
commit bcb96ce6
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8EC9K
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=bcb96ce6d2544ae0738cf54fd0a6d048fad791ec



--------------------------------

This updates the perf tools with branch privilege information request flag
i.e PERF_SAMPLE_BRANCH_PRIV_SAVE that has been added earlier in the kernel.
This also updates 'perf record' documentation, branch_modes[], and generic
branch privilege level enumeration as added earlier in the kernel.

Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20220824044822.70230-8-anshuman.khandual@arm.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
parent fab828ee
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -188,6 +188,8 @@ enum perf_branch_sample_type_shift {

	PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT	= 17, /* save low level index of raw branch records */

	PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT	= 18, /* save privilege mode */

	PERF_SAMPLE_BRANCH_MAX_SHIFT		/* non-ABI */
};

@@ -217,6 +219,8 @@ enum perf_branch_sample_type {

	PERF_SAMPLE_BRANCH_HW_INDEX	= 1U << PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT,

	PERF_SAMPLE_BRANCH_PRIV_SAVE	= 1U << PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT,

	PERF_SAMPLE_BRANCH_MAX		= 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
};

@@ -255,6 +259,13 @@ enum {
	PERF_BR_NEW_MAX,
};

enum {
	PERF_BR_PRIV_UNKNOWN	= 0,
	PERF_BR_PRIV_USER	= 1,
	PERF_BR_PRIV_KERNEL	= 2,
	PERF_BR_PRIV_HV		= 3,
};

#define PERF_SAMPLE_BRANCH_PLM_ALL \
	(PERF_SAMPLE_BRANCH_USER|\
	 PERF_SAMPLE_BRANCH_KERNEL|\
@@ -1302,7 +1313,8 @@ struct perf_branch_entry {
		cycles:16,  /* cycle count to last branch */
		type:4,     /* branch type */
		new_type:4, /* additional branch type */
		reserved:36;
		priv:3,     /* privilege level */
		reserved:33;
};

union perf_sample_weight {
+2 −1
Original line number Diff line number Diff line
@@ -25,7 +25,8 @@ struct branch_flags {
			u64 cycles:16;
			u64 type:4;
			u64 new_type:4;
			u64 reserved:36;
			u64 priv:3;
			u64 reserved:33;
		};
	};
};
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ static const struct branch_mode branch_modes[] = {
	BRANCH_OPT("call", PERF_SAMPLE_BRANCH_CALL),
	BRANCH_OPT("save_type", PERF_SAMPLE_BRANCH_TYPE_SAVE),
	BRANCH_OPT("stack", PERF_SAMPLE_BRANCH_CALL_STACK),
	BRANCH_OPT("priv", PERF_SAMPLE_BRANCH_PRIV_SAVE),
	BRANCH_END
};

+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ static void __p_branch_sample_type(char *buf, size_t size, u64 value)
		bit_name(ABORT_TX), bit_name(IN_TX), bit_name(NO_TX),
		bit_name(COND), bit_name(CALL_STACK), bit_name(IND_JUMP),
		bit_name(CALL), bit_name(NO_FLAGS), bit_name(NO_CYCLES),
		bit_name(TYPE_SAVE), bit_name(HW_INDEX),
		bit_name(TYPE_SAVE), bit_name(HW_INDEX), bit_name(PRIV_SAVE),
		{ .name = NULL, }
	};
#undef bit_name