lkml.org 
[lkml]   [2023]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH V11 06/10] arm64/perf: Enable branch stack events via FEAT_BRBE
Hello,

On Tue, May 30, 2023 at 9:21 PM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
> This enables branch stack sampling events in ARMV8 PMU, via an architecture
> feature FEAT_BRBE aka branch record buffer extension. This defines required
> branch helper functions pmuv8pmu_branch_XXXXX() and the implementation here
> is wrapped with a new config option CONFIG_ARM64_BRBE.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Tested-by: James Clark <james.clark@arm.com>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---

[SNIP]
> +void armv8pmu_branch_read(struct pmu_hw_events *cpuc, struct perf_event *event)
> +{
> + struct brbe_hw_attr *brbe_attr = (struct brbe_hw_attr *)cpuc->percpu_pmu->private;
> + u64 brbfcr, brbcr;
> + int idx, loop1_idx1, loop1_idx2, loop2_idx1, loop2_idx2, count;
> +
> + brbcr = read_sysreg_s(SYS_BRBCR_EL1);
> + brbfcr = read_sysreg_s(SYS_BRBFCR_EL1);
> +
> + /* Ensure pause on PMU interrupt is enabled */
> + WARN_ON_ONCE(!(brbcr & BRBCR_EL1_FZP));
> +
> + /* Pause the buffer */
> + write_sysreg_s(brbfcr | BRBFCR_EL1_PAUSED, SYS_BRBFCR_EL1);
> + isb();
> +
> + /* Determine the indices for each loop */
> + loop1_idx1 = BRBE_BANK0_IDX_MIN;
> + if (brbe_attr->brbe_nr <= BRBE_BANK_MAX_ENTRIES) {
> + loop1_idx2 = brbe_attr->brbe_nr - 1;
> + loop2_idx1 = BRBE_BANK1_IDX_MIN;
> + loop2_idx2 = BRBE_BANK0_IDX_MAX;

Is this to disable the bank1? Maybe need a comment.


> + } else {
> + loop1_idx2 = BRBE_BANK0_IDX_MAX;
> + loop2_idx1 = BRBE_BANK1_IDX_MIN;
> + loop2_idx2 = brbe_attr->brbe_nr - 1;
> + }

The loop2_idx1 is the same for both cases. Maybe better
to move it out of the if statement.

Thanks,
Namhyung


> +
> + /* Loop through bank 0 */
> + select_brbe_bank(BRBE_BANK_IDX_0);
> + for (idx = 0, count = loop1_idx1; count <= loop1_idx2; idx++, count++) {
> + if (!capture_branch_entry(cpuc, event, idx))
> + goto skip_bank_1;
> + }
> +
> + /* Loop through bank 1 */
> + select_brbe_bank(BRBE_BANK_IDX_1);
> + for (count = loop2_idx1; count <= loop2_idx2; idx++, count++) {
> + if (!capture_branch_entry(cpuc, event, idx))
> + break;
> + }
> +
> +skip_bank_1:
> + cpuc->branches->branch_stack.nr = idx;
> + cpuc->branches->branch_stack.hw_idx = -1ULL;
> + process_branch_aborts(cpuc);
> +
> + /* Unpause the buffer */
> + write_sysreg_s(brbfcr & ~BRBFCR_EL1_PAUSED, SYS_BRBFCR_EL1);
> + isb();
> + armv8pmu_branch_reset();
> +}

\
 
 \ /
  Last update: 2023-06-02 03:46    [W:1.746 / U:0.944 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site