答复: [PATCH v2 0/3] perf/x86/amd/uncore: Add common helpers and Hygon support

From: Qi Liu

Date: Mon Jul 06 2026 - 07:46:29 EST


Hi Boris,
Thanks for your reply!

This makes sense. I see the concern about introducing common helpers too early when AMD and Hygon may still evolve differently in details.
For the next revision, I can keep the Hygon support self-contained by copying the needed AMD logic first, and avoid introducing a generic common layer at this stage. If the helpers remain identical over time, we can always consolidate them later in a separate cleanup.
I’ll also revisit the symbol exports and drop them unless there is a clear module boundary requirement

Thanks,
Qi Liu

-----邮件原件-----
发件人: Borislav Petkov <bp@xxxxxxxxx>
发送时间: 2026年7月2日 10:36
收件人: Qi Liu <liuqi@xxxxxxxx>
抄送: peterz@xxxxxxxxxxxxx; mingo@xxxxxxxxxx; namhyung@xxxxxxxxxx; alexander.shishkin@xxxxxxxxxxxxxxx; jolsa@xxxxxxxxxx; x86@xxxxxxxxxx; linux-perf-users@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Jing Li <lijing@xxxxxxxx>; Sandipan Das <sandipan.das@xxxxxxx>; Ravi Bangoria <ravi.bangoria@xxxxxxx>
主题: Re: [PATCH v2 0/3] perf/x86/amd/uncore: Add common helpers and Hygon support

+ AMD people who work on this code.

On Wed, Jul 01, 2026 at 09:34:14AM +0000, Qi Liu wrote:
> This series adds initial Hygon uncore PMU support.
>
> Hygon uncore PMUs use a programming model close to the AMD uncore PMU,
> so this series factors out a small set of common helpers for perf
> event handling, counter assignment and per-CPU context management.
>
> The Hygon-specific support is kept in the Hygon driver. This series
> supports the Hygon DF and DF IOD PMUs. No Hygon-specific logic is
> added to the AMD driver.
>
> Changes since RFC:
> - Address sashiko bot review.
> Changes since v1:
> - Rename the helper namespace to amd_uncore_common_* to avoid
> an generic uncore_common_* prefix, and to keep it distinct
> from the existing amd_uncore_* names.
>
>
> Qi Liu (3):
> perf/x86/amd/uncore: Add common PMU helper functions
> perf/x86/amd/uncore: Convert AMD driver to common PMU helpers
> perf/x86/amd/uncore: Add Hygon uncore PMU support
>
> arch/x86/events/Kconfig | 17 +
> arch/x86/events/amd/Makefile | 4 +
> arch/x86/events/amd/amd_uncore_common.c | 403 +++++++++++++++++
> arch/x86/events/amd/amd_uncore_common.h | 114 +++++
> arch/x86/events/amd/hygon_uncore.c | 556 +++++++++++++++++++++++
> arch/x86/events/amd/uncore.c | 578 +++---------------------
> arch/x86/include/asm/msr-index.h | 2 +
> arch/x86/include/asm/perf_event.h | 20 +
> include/linux/cpuhotplug.h | 3 +
> 9 files changed, 1192 insertions(+), 505 deletions(-) create mode
> 100644 arch/x86/events/amd/amd_uncore_common.c
> create mode 100644 arch/x86/events/amd/amd_uncore_common.h
> create mode 100644 arch/x86/events/amd/hygon_uncore.c

I'm sure Ravi and Sandipan will give you more indepth comments but the general direction with reusing AMD code on Hygon is to copy it first for your purposes and, later, when it turns out the helpers do remain identical, then to merge them.

Vs defining common helpers now and stifling your and AMD development by trying to shoehorn common helpers with an architecture which is here and there a bit different.

Also, I'm not sure about all those export symbols gunk - why would common events helpers need exports to modules but meh, Peter will give his thoughts here.

Also, Sashiko has comments:

https://lore.kernel.org/r/20260701094808.5C8BC1F000E9@xxxxxxxxxxxxxxx

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette