Re: [PATCH v3 1/5] perf/core: Allow multiple AUX PMU events with the same module
From: Leo Yan
Date: Tue Aug 06 2024 - 17:51:42 EST
On 8/6/2024 10:14 PM, Peter Zijlstra wrote:
> On Tue, Aug 06, 2024 at 09:48:09PM +0100, Leo Yan wrote:
>> This commit changes the condition from checking the same PMU instance to
>> checking the same PMU driver module. This allows support for multiple
>> PMU events with the same driver module.
>>
>> As a result, more than one AUX event (e.g. arm_spe_0 and arm_spe_1) can
>> record trace into the AUX ring buffer.
>>
>> Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
>> ---
>> kernel/events/core.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/events/core.c b/kernel/events/core.c
>> index aa3450bdc227..fdb8918e62a0 100644
>> --- a/kernel/events/core.c
>> +++ b/kernel/events/core.c
>> @@ -12344,9 +12344,10 @@ perf_event_set_output(struct perf_event *event, struct perf_event *output_event)
>>
>> /*
>> * If both events generate aux data, they must be on the same PMU
>> + * module but can be with different PMU instances.
>> */
>> if (has_aux(event) && has_aux(output_event) &&
>> - event->pmu != output_event->pmu)
>> + event->pmu->module != output_event->pmu->module)
>
> A very quick look at: arch/x86/events/intel/pt.c seems to suggest that
> doesn't set pmu->module. Which seems to suggest the above won't work for
> us.
Seems Intel PT and BTS drivers both do not set the pmu->module.
Either we assign the pmu->module for both drivers, or we can update this patch
like below:
if (has_aux(event) && has_aux(output_event)) {
/*
* No idea the module for the PMU is pmu->module is NULL,
* do not allow tracing for these two AUX event.
*/
if (!event->pmu->module || !output_event->pmu->module)
goto out;
/*
* Don't allow generate AUX trace data if PMUs don't come from
* the same module.
*/
if (event->pmu->module != output_event->pmu->module)
goto out;
}
How about you think? Thanks for review!
Leo