[PATCH V4 6/7] arm64/perf: Add BRBE driver

Anshuman Khandual anshuman.khandual at arm.com
Sun Nov 6 18:41:28 PST 2022



On 11/2/22 21:06, James Clark wrote:
> 
> On 17/10/2022 06:57, Anshuman Khandual wrote:
>> This adds a BRBE driver which implements all the required helper functions
>> for struct arm_pmu. Following functions are defined by this driver which
>> will configure, enable, capture, reset and disable BRBE buffer HW as and
>> when requested via perf branch stack sampling framework.
>>
>> - arm64_pmu_brbe_filter()
>> - arm64_pmu_brbe_enable()
>> - arm64_pmu_brbe_disable()
>> - arm64_pmu_brbe_read()
>> - arm64_pmu_brbe_probe()
>> - arm64_pmu_brbe_reset()
>> - arm64_pmu_brbe_supported()
>>
>> Cc: Peter Zijlstra <peterz at infradead.org>
>> Cc: Ingo Molnar <mingo at redhat.com>
>> Cc: Arnaldo Carvalho de Melo <acme at kernel.org>
>> Cc: Mark Rutland <mark.rutland at arm.com>
>> Cc: Will Deacon <will at kernel.org>
>> Cc: Catalin Marinas <catalin.marinas at arm.com>
>> Cc: linux-arm-kernel at lists.infradead.org
>> Cc: linux-perf-users at vger.kernel.org
>> Cc: linux-kernel at vger.kernel.org
>> Signed-off-by: Anshuman Khandual <anshuman.khandual at arm.com>
>> ---
>>  arch/arm64/kernel/perf_event.c |   8 +-
>>  drivers/perf/Kconfig           |  11 +
>>  drivers/perf/Makefile          |   1 +
>>  drivers/perf/arm_pmu_brbe.c    | 441 +++++++++++++++++++++++++++++++++
>>  drivers/perf/arm_pmu_brbe.h    | 259 +++++++++++++++++++
>>  include/linux/perf/arm_pmu.h   |  20 ++
>>  6 files changed, 739 insertions(+), 1 deletion(-)
>>  create mode 100644 drivers/perf/arm_pmu_brbe.c
>>  create mode 100644 drivers/perf/arm_pmu_brbe.h
>>
>> diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
>> index 97db333d1208..85a3aaefc0fb 100644
>> --- a/arch/arm64/kernel/perf_event.c
>> +++ b/arch/arm64/kernel/perf_event.c
>> @@ -1034,31 +1034,37 @@ static int armv8pmu_filter_match(struct perf_event *event)
>>  
>>  static void armv8pmu_brbe_filter(struct pmu_hw_events *hw_event, struct perf_event *event)
>>  {
>> +	arm64_pmu_brbe_filter(hw_event, event);
>>  }
>>  
>>  static void armv8pmu_brbe_enable(struct pmu_hw_events *hw_event)
>>  {
>> +	arm64_pmu_brbe_enable(hw_event);
>>  }
>>  
>>  static void armv8pmu_brbe_disable(struct pmu_hw_events *hw_event)
>>  {
>> +	arm64_pmu_brbe_disable(hw_event);
>>  }
>>  
>>  static void armv8pmu_brbe_read(struct pmu_hw_events *hw_event, struct perf_event *event)
>>  {
>> +	arm64_pmu_brbe_read(hw_event, event);
>>  }
>>  
>>  static void armv8pmu_brbe_probe(struct pmu_hw_events *hw_event)
>>  {
>> +	arm64_pmu_brbe_probe(hw_event);
>>  }
>>  
>>  static void armv8pmu_brbe_reset(struct pmu_hw_events *hw_event)
>>  {
>> +	arm64_pmu_brbe_reset(hw_event);
>>  }
>>  
>>  static bool armv8pmu_brbe_supported(struct perf_event *event)
>>  {
>> -	return false;
>> +	return arm64_pmu_brbe_supported(event);
>>  }
>>  
>>  static void armv8pmu_reset(void *info)
>> diff --git a/drivers/perf/Kconfig b/drivers/perf/Kconfig
>> index 341010f20b77..4efd0a77c5ff 100644
>> --- a/drivers/perf/Kconfig
>> +++ b/drivers/perf/Kconfig
>> @@ -190,6 +190,17 @@ config ALIBABA_UNCORE_DRW_PMU
>>  	  Support for Driveway PMU events monitoring on Yitian 710 DDR
>>  	  Sub-system.
>>  
>> +config ARM_BRBE_PMU
>> +	tristate "Enable support for Branch Record Buffer Extension (BRBE)"
> Hi Anshuman,
> 
> I get a few build errors if this is enabled as a module, and it's
> missing the module boilerplate stuff. I'm wondering if tristate is a
> mistake and it's supposed to be static only? Otherwise it probably needs
> a few different things fixing up.
> 
> It would be nice to have it as a module so it's easy to work on in the
> future.
> 
>> +	depends on ARM64 && ARM_PMU
>> +	default y
> Should this be default m?
> 

Right, "Tristate" here does not really make sense as ARM_BRBE_PMU is dependent
on base ARM_PMU, where as ARM_SPE is abstracted as a separate PMU in itself.



More information about the linux-arm-kernel mailing list