Page MenuHomeFreeBSD

dev/hwpmc: Add interrupt callback for arm64
AbandonedPublic

Authored by sarah.walker2_arm.com on Wed, Jul 29, 3:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Aug 25, 1:53 AM
Unknown Object (File)
Mon, Aug 24, 10:46 PM
Unknown Object (File)
Sun, Aug 23, 8:17 PM
Unknown Object (File)
Thu, Aug 20, 4:54 PM
Unknown Object (File)
Fri, Aug 14, 2:58 AM
Unknown Object (File)
Mon, Aug 10, 5:10 PM
Unknown Object (File)
Mon, Aug 10, 9:21 AM
Unknown Object (File)
Sat, Aug 8, 5:20 PM

Details

Summary

Add a callback to allow additional drivers to capture state on PMC interrupt.
This is required to integrate extensions such as BRBE.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75265
Build 72148: arc lint + arc unit

Event Timeline

So is the reason we aren't hard coding this and integrating BRBE into the pmc module is that it will be used by hwt as well? Is this best exposed through hwt or is it just extended data that can be exposed throught he multipart flag I added for AMD IBS? The multipart flag lets you add arbitrary payloads alongside a counter. LBR will be using this as well.

Only problem I can see is the potential race on an unload when setting pmc_intr_callback to NULL.

So is the reason we aren't hard coding this and integrating BRBE into the pmc module is that it will be used by hwt as well? Is this best exposed through hwt or is it just extended data that can be exposed throught he multipart flag I added for AMD IBS? The multipart flag lets you add arbitrary payloads alongside a counter. LBR will be using this as well.

Only problem I can see is the potential race on an unload when setting pmc_intr_callback to NULL.

It was decided that hwt was the best method to use for dumping BRBE samples, however BRBE uses the PMC interrupt which hwpmc owns. Integrating the BRBE functionality into hwpmc would therefore add a dependency between hwpmc and hwt which seemed less than ideal, hence this approach.

So is the reason we aren't hard coding this and integrating BRBE into the pmc module is that it will be used by hwt as well? Is this best exposed through hwt or is it just extended data that can be exposed throught he multipart flag I added for AMD IBS? The multipart flag lets you add arbitrary payloads alongside a counter. LBR will be using this as well.

Only problem I can see is the potential race on an unload when setting pmc_intr_callback to NULL.

It was decided that hwt was the best method to use for dumping BRBE samples, however BRBE uses the PMC interrupt which hwpmc owns. Integrating the BRBE functionality into hwpmc would therefore add a dependency between hwpmc and hwt which seemed less than ideal, hence this approach.

Hello Sarah,

I'm concurrently working with the AMD folks that are adding LBR the equivalent feature for x86.

Please correct me if I'm wrong, but BRBE also can freeze on a perf counter overflow (FZP bit) so we would want to attach it to the performance counters. We should introduce a per counter flag that will collect BRBE or LBR data as a payload to any supported counter. In the interrupt handler for the performance counters you can use the multipart function (see [1] below) to include the branch history payload inside the pmc event. Given how much data there is it might make more sense to add an explicit callback to fill in the pmc buffer rather than call the MP function that requires copying it onto the stack.

In addition to using it for PGO, this helps improve performance counter analysis by giving us precise branch traces. It would ideal we agree on a common per counter flag/capability bits so both systems can use the same interface.

[1] https://github.com/freebsd/freebsd-src/blob/4dc196233e406cd30b9b1936adb91381f6892a6a/sys/dev/hwpmc/hwpmc_ibs.c#L673

@mhorne @imp @afscoelho_gmail.com @raghavendra.kt_amd.com

Best,
Ali

On arm64, the hwpmc interrupt (arm64_intr()) is dispatched from the PMU driver: pmu_intr() in sys/arm/arm/pmu.c.

I think this is the place where a new callback should be registered and invoked.