linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, will@kernel.org,
	catalin.marinas@arm.com, Mark Brown <broonie@kernel.org>,
	James Clark <james.clark@arm.com>, Rob Herring <robh@kernel.org>,
	Marc Zyngier <maz@kernel.org>,
	Suzuki Poulose <suzuki.poulose@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH V17 3/9] drivers: perf: arm_pmu: Add infrastructure for branch stack sampling
Date: Mon, 3 Jun 2024 12:10:12 +0530	[thread overview]
Message-ID: <8ec0f93a-a1f9-4b04-875c-dd4a9172e339@arm.com> (raw)
In-Reply-To: <ZkylUT0R9lwseF4a@J2N7QTR9R3>



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.

  reply	other threads:[~2024-06-03  6:40 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05  2:46 [PATCH V17 0/9] arm64/perf: Enable branch stack sampling Anshuman Khandual
2024-04-05  2:46 ` [PATCH V17 1/9] arm64/sysreg: Add BRBE registers and fields Anshuman Khandual
2024-05-21 13:24   ` Mark Rutland
2024-06-03  5:12     ` Anshuman Khandual
2024-04-05  2:46 ` [PATCH V17 2/9] KVM: arm64: Explicitly handle BRBE traps as UNDEFINED Anshuman Khandual
2024-05-21 13:26   ` Mark Rutland
2024-06-03  5:31     ` Anshuman Khandual
2024-04-05  2:46 ` [PATCH V17 3/9] drivers: perf: arm_pmu: Add infrastructure for branch stack sampling Anshuman Khandual
2024-05-21 13:44   ` Mark Rutland
2024-06-03  6:40     ` Anshuman Khandual [this message]
2024-04-05  2:46 ` [PATCH V17 4/9] arm64/boot: Enable EL2 requirements for BRBE Anshuman Khandual
2024-05-29 10:51   ` Mark Rutland
2024-06-03  9:11     ` Anshuman Khandual
2024-06-03  9:38       ` Mark Rutland
2024-04-05  2:46 ` [PATCH V17 5/9] drivers: perf: arm_pmuv3: Enable branch stack sampling via FEAT_BRBE Anshuman Khandual
2024-04-05  2:46 ` [PATCH V17 6/9] KVM: arm64: nvhe: Disable branch generation in nVHE guests Anshuman Khandual
2024-04-05  2:46 ` [PATCH V17 7/9] perf: test: Speed up running brstack test on an Arm model Anshuman Khandual
2024-04-05  2:46 ` [PATCH V17 8/9] perf: test: Remove empty lines from branch filter test output Anshuman Khandual
2024-04-05  2:46 ` [PATCH V17 9/9] perf: test: Extend branch stack sampling test for Arm64 BRBE Anshuman Khandual
2024-05-30  9:47 ` [PATCH V17 0/9] arm64/perf: Enable branch stack sampling James Clark
2024-05-30 17:41   ` Mark Rutland
2024-05-31 13:01     ` Mark Rutland
2024-06-06  4:58     ` Anshuman Khandual
2024-06-06  6:27       ` Anshuman Khandual
2024-06-06 11:01       ` James Clark
2024-06-06  3:57   ` Anshuman Khandual
2024-05-30 10:03 ` James Clark
2024-06-03  9:18   ` Anshuman Khandual
2024-06-03  9:39     ` Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ec0f93a-a1f9-4b04-875c-dd4a9172e339@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=acme@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.clark@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=robh@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).