lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <adfbd1ba-62ca-49c9-893a-3c10780ee186@arm.com>
Date: Wed, 4 Sep 2024 20:35:58 +0100
From: Leo Yan <leo.yan@....com>
To: Adrian Hunter <adrian.hunter@...el.com>,
 Peter Zijlstra <peterz@...radead.org>,
 Arnaldo Carvalho de Melo <acme@...nel.org>,
 Namhyung Kim <namhyung@...nel.org>, Mark Rutland <mark.rutland@....com>,
 Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
 "Liang, Kan" <kan.liang@...ux.intel.com>,
 Suzuki K Poulose <suzuki.poulose@....com>, Mike Leach
 <mike.leach@...aro.org>, James Clark <james.clark@...aro.org>,
 John Garry <john.g.garry@...cle.com>, Will Deacon <will@...nel.org>,
 Yicong Yang <yangyicong@...ilicon.com>,
 Jonathan Cameron <jonathan.cameron@...wei.com>,
 linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-arm-kernel@...ts.infradead.org, coresight@...ts.linaro.org
Subject: Re: [PATCH v6 1/8] perf/core: Allow multiple AUX PMU events with the
 same module

On 9/3/2024 11:06 AM, Adrian Hunter wrote:
>> @@ -12345,9 +12345,16 @@ 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.
>> +      *
>> +      * For a built-in PMU module, the 'pmu->module' pointer is NULL,
>> +      * thus it is not feasible to compare the module pointers when
>> +      * AUX PMU drivers are built into the kernel image. Instead,
>> +      * comparing the .setup_aux() callback pointer can determine if
>> +      * the two PMU events come from the same PMU driver.
>>        */
>>       if (has_aux(event) && has_aux(output_event) &&
>> -         event->pmu != output_event->pmu)
>> +         event->pmu->setup_aux != output_event->pmu->setup_aux)
> 
> It is not very flexible and risks someone adding aux PMUs that
> do not want that rule but accidentally support it.  Another
> option is to add a PMU callback, but really you need to Peter's
> feedback.

Thanks a lot for sharing opinion, Adrian!

How about below code? An alternative way is to compare the PMU's parent
device driver, e.g. for Arm SPE PMU events, this can compare if two PMU
events are using the Arm SPE driver.

/*
 * 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)) {
        /* It isn't allowed if it fails to find driver pointer */
        if (!event->pmu->parent || !event->pmu->parent->driver)
                goto out;

        if (!output_event->pmu->parent || !output_event->pmu->parent->driver)
                goto out;

        /*
         * It isn't allowed if aux events are not same type of PMU
         * device. This is determined by comparing the associated
         * driver pointers.
         */
        if (event->pmu->parent->driver != output_event->pmu->parent->driver)
                goto out;
}

I verified the code above, it also works well at my side.

@Peter.Z, Please let me know if this is okay for you.

Thanks,
Leo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ