[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8ec0f93a-a1f9-4b04-875c-dd4a9172e339@arm.com>
Date: Mon, 3 Jun 2024 12:10:12 +0530
From: Anshuman Khandual <anshuman.khandual@....com>
To: Mark Rutland <mark.rutland@....com>
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
will@...nel.org, catalin.marinas@....com, Mark Brown <broonie@...nel.org>,
James Clark <james.clark@....com>, Rob Herring <robh@...nel.org>,
Marc Zyngier <maz@...nel.org>, Suzuki Poulose <suzuki.poulose@....com>,
Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, linux-perf-users@...r.kernel.org
Subject: Re: [PATCH V17 3/9] drivers: perf: arm_pmu: Add infrastructure for
branch stack sampling
On 5/21/24 19:14, Mark Rutland wrote:
> On Fri, Apr 05, 2024 at 08:16:33AM +0530, Anshuman Khandual wrote:
>> In order to support the Branch Record Buffer Extension (BRBE), we need to
>> extend the arm_pmu framework with some basic infrastructure for the branch
>> stack sampling which arm_pmu drivers can opt-in using a new feature flag
>> called 'has_branch_stack'. Subsequent patches will use this to add support
>> for BRBE in the PMUv3 driver.
>
> Please, just use ther *exact* wording I asked for last time:
>
> | In order to support the Branch Record Buffer Extension (BRBE), we need to
> | extend the arm_pmu framework with some basic infrastructure for branch stack
> | sampling which arm_pmu drivers can opt-in to using. Subsequent patches will
> | use this to add support for BRBE in the PMUv3 driver.
>
> At this point in the commit message, the 'has_branch_stack' flag doesn't
> matter, and dropping the 'to' after 'opt-in' makes this painful to read.
Okay, will replace with the original paragraph.
>
>> Branch stack sampling support i.e capturing branch records during execution
>> in core perf, rides along with normal HW events being scheduled on the PMU.
>> This prepares ARMV8 PMU framework for branch stack support on relevant PMUs
>> with required HW implementation.
>
> Please delete this paragraph.
Done.
>
>> With BRBE, the hardware records branches into a hardware FIFO, which will
>> be sampled by software when perf events overflow. A task may be context-
>> switched an arbitrary number of times between overflows, and to avoid
>> losing samples we need to save the current records when a task is context-
>> switched out. To do these we'll need to use the pmu::sched_task() callback,
>> and we'll also need to allocate some per-task storage space via event flag
>> PERF_ATTACH_TASK_DATA.
>
> [...]
>
>> /* The events for a given PMU register set. */
>> struct pmu_hw_events {
>> /*
>> @@ -66,6 +78,17 @@ struct pmu_hw_events {
>> struct arm_pmu *percpu_pmu;
>>
>> int irq;
>> +
>> + struct branch_records *branches;
>> +
>> + /* Active context for task events */
>> + void *branch_context;
>> +
>> + /* Active events requesting branch records */
>> + unsigned int branch_users;
>> +
>> + /* Active branch sample type filters */
>> + unsigned long branch_sample_type;
>> };
>
> At this point in the series I understand why we have the 'branches' and
> 'branch_users' fields, but the 'branch_context' and 'branch_sample_type'
> fields haven't been introduced and are not obvious.
>
> What exactly is branch_context, and why is that a 'void *' ?
branch_context tracks event->ctx which is 'struct perf_event_context *'. The
'void *' seemed more generic in case this tracking structure changes later.
But this could be changed as 'struct perf_event_context *' if required.
>
> I can understand if that's a PMU-specific structure to track the active
> branch records, but if so I don't understand why 'branch_sample_type'
> isn't folded into that.
branch_sample_type is applicable both for cpu and task bound events, where as
branch_context is applicable only for task bound events tracking their active
branch records that need to be dropped (or saved), in case a cpu bound event
comes in.
Powered by blists - more mailing lists