mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Clark <james.clark@linaro.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>, Amir Ayupov <aaupov@fb.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Daniel Pereira <danielmaraboo@gmail.com>,
	coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, Leo Yan <leo.yan@arm.com>,
	Mike Leach <mike.leach@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH v4 5/7] perf: arm_pmuv3: Add pmuv3_event_implemented()
Date: Thu, 5 Nov 2026 15:10:45 +0000	[thread overview]
Message-ID: <f7b19834-dc88-4431-a383-4b73edc5dc4d@linaro.org> (raw)
In-Reply-To: <a876b77b-c4e4-4019-868a-af12c93f441f@arm.com>



On 05/11/2026 14:54, Suzuki K Poulose wrote:
> On 26/10/2026 05:48, Amir Ayupov wrote:
>> Drivers outside the PMU driver may need to know whether the local CPU's
>> PMU implements a common event before relying on it, for example a trace
>> unit driver checking that the PMU counts its external outputs as
>> TRCEXTOUTn.
>>
>> Add pmuv3_event_implemented() to the arm64 asm/arm_pmuv3.h, next to
>> read_pmceid0() and read_pmceid1(). It reads PMCEID0/1 on the calling CPU:
>> events 0x0000-0x003f are reported in bits [31:0], and the common events
>> from ARMV8_PMUV3_EXT_COMMON_EVENT_BASE in bits [63:32] from PMUv3p1. Move
>> ARMV8_PMUV3_EXT_COMMON_EVENT_BASE next to the event numbers in
>> linux/perf/arm_pmuv3.h so it is available without CONFIG_ARM_PMU.
>>
>> Suggested-by: James Clark <james.clark@linaro.org>
>> Assisted-by: Devmate:Opus-5.5
>> Signed-off-by: Amir Ayupov <aaupov@fb.com>
>> ---
>>   arch/arm64/include/asm/arm_pmuv3.h | 19 +++++++++++++++++++
>>   include/linux/perf/arm_pmu.h       |  1 -
>>   include/linux/perf/arm_pmuv3.h     |  3 +++
>>   3 files changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/include/asm/arm_pmuv3.h b/arch/arm64/include/ 
>> asm/arm_pmuv3.h
>> index 8a777dec8d88a..acd62c4f16743 100644
>> --- a/arch/arm64/include/asm/arm_pmuv3.h
>> +++ b/arch/arm64/include/asm/arm_pmuv3.h
>> @@ -173,6 +173,25 @@ static inline bool pmuv3_implemented(int pmuver)
>>            pmuver == ID_AA64DFR0_EL1_PMUVer_NI);
>>   }
>> +/*
>> + * Whether this CPU's PMU implements a common event, as reported by
>> + * PMCEID{0,1}: events 0x0000-0x003f in bits [31:0], and from PMUv3p1 
>> events
>> + * 0x4000-0x403f in bits [63:32], which read as zero before PMUv3p1.
>> + * Must run on the CPU whose PMU is queried.
>> + */
>> +static inline bool pmuv3_event_implemented(u16 event)
>> +{
>> +    bool ext = event >= ARMV8_PMUV3_EXT_COMMON_EVENT_BASE;
>> +    u16 id = ext ? event - ARMV8_PMUV3_EXT_COMMON_EVENT_BASE : event;
>> +    u64 pmceid;
>> +
>> +    if (id >= 64 || !pmuv3_implemented(read_pmuver()))
>> +        return false;
>> +
>> +    pmceid = id < 32 ? :() : read_pmceid1();
>> +    return pmceid & BIT_ULL(id % 32 + (ext ? 32 : 0));
>> +}
>> +
>>   static inline bool is_pmuv3p4(int pmuver)
>>   {
>>       return pmuver >= ID_AA64DFR0_EL1_PMUVer_V3P4;
>> diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h
>> index 02d2c7f45b527..792283d29d7b5 100644
>> --- a/include/linux/perf/arm_pmu.h
>> +++ b/include/linux/perf/arm_pmu.h
>> @@ -124,7 +124,6 @@ struct arm_pmu {
>>       u64        reg_brbidr;
>>   #define ARMV8_PMUV3_MAX_COMMON_EVENTS        0x40
>>       DECLARE_BITMAP(pmceid_bitmap, ARMV8_PMUV3_MAX_COMMON_EVENTS);
>> -#define ARMV8_PMUV3_EXT_COMMON_EVENT_BASE    0x4000
>>       DECLARE_BITMAP(pmceid_ext_bitmap, ARMV8_PMUV3_MAX_COMMON_EVENTS);
> 
> Could we not avoid this change ? Or why not move both of the definitions ?
> 

I don't think you can avoid it unless you redefine it. But the place 
it's moved to has similar event number definitions, so it seems ok to me.

Moving both makes sense though.

> 
> Also, I would need an ACK from the arm_pmu maintainers to accept this
> change via coresight tree.
> 
> Cheers
> Suzuki
> 
> 
>>       /* Only to be used by ACPI probing code */
>> diff --git a/include/linux/perf/arm_pmuv3.h b/include/linux/perf/ 
>> arm_pmuv3.h
>> index d698efba28a27..c21f185a283d6 100644
>> --- a/include/linux/perf/arm_pmuv3.h
>> +++ b/include/linux/perf/arm_pmuv3.h
>> @@ -78,6 +78,9 @@
>>   #define ARMV8_PMUV3_PERFCTR_STALL_SLOT_FRONTEND            0x003E
>>   #define ARMV8_PMUV3_PERFCTR_STALL_SLOT                0x003F
>> +/* Base of the common events reported in PMCEID{0,1}[63:32] from 
>> PMUv3p1 */
>> +#define ARMV8_PMUV3_EXT_COMMON_EVENT_BASE            0x4000
>> +
>>   /* Statistical profiling extension microarchitectural events */
>>   #define ARMV8_SPE_PERFCTR_SAMPLE_POP                0x4000
>>   #define ARMV8_SPE_PERFCTR_SAMPLE_FEED                0x4001
> 


  reply	other threads:[~2026-11-05 15:10 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 23:05 [PATCH v2 0/4] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-10-12 23:05 ` [PATCH v2 1/4] coresight: syscfg: Fail to enable a configuration not loaded on the device Amir Ayupov
2026-10-21 14:09   ` Leo Yan
2026-10-12 23:05 ` [PATCH v2 2/4] coresight: syscfg: Match feature capabilities separately from device class Amir Ayupov
2026-10-21 14:39   ` Leo Yan
2026-10-25  6:21     ` Amir Ayupov
2026-10-27 11:21     ` Suzuki K Poulose
2026-10-12 23:05 ` [PATCH v2 3/4] coresight: etm4x: Report the external outputs the PMU counts Amir Ayupov
2026-10-21 16:43   ` Leo Yan
2026-10-23  9:49     ` James Clark
2026-10-23 14:00       ` Leo Yan
2026-10-26  9:22         ` James Clark
2026-10-25  6:34     ` Amir Ayupov
2026-10-23  9:57   ` James Clark
2026-10-12 23:05 ` [PATCH v2 4/4] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
2026-10-13  1:09   ` Daniel Pereira
2026-10-25  6:38     ` Amir Ayupov
2026-10-26  9:36       ` James Clark
2026-10-25  6:39 ` [PATCH v3 0/7] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-10-25  6:39   ` [PATCH v3 1/7] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-10-25  6:39   ` [PATCH v3 2/7] coresight: syscfg: Fail to enable a configuration not loaded on the device Amir Ayupov
2026-10-25  6:39   ` [PATCH v3 3/7] coresight: syscfg: Match feature capabilities separately from device class Amir Ayupov
2026-10-25  6:39   ` [PATCH v3 4/7] coresight: syscfg: Remove unused CS_CFG_MATCH_INST_ANY Amir Ayupov
2026-10-25  6:39   ` [PATCH v3 5/7] perf: arm_pmuv3: Add pmuv3_event_implemented() Amir Ayupov
2026-10-25 17:05     ` kernel test robot
2026-10-26  0:43     ` kernel test robot
2026-10-25  6:39   ` [PATCH v3 6/7] coresight: etm4x: Report whether the PMU counts the external outputs Amir Ayupov
2026-10-25  6:39   ` [PATCH v3 7/7] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
2026-10-26  5:48   ` [PATCH v4 0/7] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-10-26  5:48     ` [PATCH v4 1/7] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-10-26  9:37       ` James Clark
2026-10-26  5:48     ` [PATCH v4 2/7] coresight: syscfg: Fail to enable a configuration not loaded on the device Amir Ayupov
2026-10-26  5:48     ` [PATCH v4 3/7] coresight: syscfg: Match feature capabilities separately from device class Amir Ayupov
2026-10-26  9:45       ` James Clark
2026-11-05 12:24       ` Suzuki K Poulose
2026-10-26  5:48     ` [PATCH v4 4/7] coresight: syscfg: Remove unused CS_CFG_MATCH_INST_ANY Amir Ayupov
2026-10-26  9:45       ` James Clark
2026-10-26  5:48     ` [PATCH v4 5/7] perf: arm_pmuv3: Add pmuv3_event_implemented() Amir Ayupov
2026-10-26  9:47       ` James Clark
2026-11-05 14:54       ` Suzuki K Poulose
2026-11-05 15:10         ` James Clark [this message]
2026-10-26  5:48     ` [PATCH v4 6/7] coresight: etm4x: Report whether the PMU counts the external outputs Amir Ayupov
2026-10-26  9:49       ` James Clark
2026-11-05 12:23       ` Suzuki K Poulose
2026-10-26  5:48     ` [PATCH v4 7/7] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
2026-10-26  9:50       ` James Clark
2026-11-05 11:43     ` [PATCH v4 0/7] coresight: Pulse an ETM external output for a PMU event Leo Yan

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=f7b19834-dc88-4431-a383-4b73edc5dc4d@linaro.org \
    --to=james.clark@linaro.org \
    --cc=aaupov@fb.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=coresight@lists.linaro.org \
    --cc=danielmaraboo@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@arm.com \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.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

all inboxes | Powered by JetHome®