Re: [PATCH V2 2/6] perf: Add branch stack extension

From: Sandipan Das
Date: Tue May 23 2023 - 02:04:21 EST


Hi Kan,

On 5/22/2023 5:00 PM, kan.liang@xxxxxxxxxxxxxxx wrote:
> From: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
>
> Currently, the extra information of a branch entry is stored in a u64
> space. With more and more information added, the space is running out.
> For example, the information of occurrences of events will be added for
> each branch.
>
> Add an extension space to record the new information for each branch
> entry. The space is appended after the struct perf_branch_stack.
>
> Add a bit in struct perf_branch_entry to indicate whether the extra
> information is included.
>
> Reviewed-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> Signed-off-by: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
> Cc: Sandipan Das <sandipan.das@xxxxxxx>
> Cc: Ravi Bangoria <ravi.bangoria@xxxxxxx>
> Cc: Athira Rajeev <atrajeev@xxxxxxxxxxxxxxxxxx>
> ---
>
> New patch
> - Introduce a generic extension space which can be used to
> store the LBR event information for Intel. It can also be used by
> other ARCHs for the other purpose.
> - Add a new bit in struct perf_branch_entry to indicate whether the
> extra information is included.
>
> arch/powerpc/perf/core-book3s.c | 2 +-
> arch/x86/events/amd/core.c | 2 +-
> arch/x86/events/intel/core.c | 2 +-
> arch/x86/events/intel/ds.c | 4 ++--
> include/linux/perf_event.h | 18 +++++++++++++++++-
> include/uapi/linux/perf_event.h | 4 +++-
> kernel/events/core.c | 5 +++++
> 7 files changed, 30 insertions(+), 7 deletions(-)
>

This seems to be missing the following:

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 6310fc5c9f52..b6739f63dc34 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1704,7 +1704,7 @@ int x86_pmu_handle_irq(struct pt_regs *regs)
perf_sample_data_init(&data, 0, event->hw.last_period);

if (has_branch_stack(event))
- perf_sample_save_brstack(&data, event, &cpuc->lbr_stack);
+ perf_sample_save_brstack(&data, event, &cpuc->lbr_stack, NULL);

if (perf_event_overflow(event, &data, regs))
x86_pmu_stop(event, 0);


Otherwise, the changes look good to me.

Reviewed-by: Sandipan Das <sandipan.das@xxxxxxx>