From nobody Fri Dec 19 14:21:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE137C83F12 for ; Tue, 29 Aug 2023 12:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235736AbjH2M6j (ORCPT ); Tue, 29 Aug 2023 08:58:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235671AbjH2M6F (ORCPT ); Tue, 29 Aug 2023 08:58:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69F9199 for ; Tue, 29 Aug 2023 05:58:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693313882; x=1724849882; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PGt4g7CgoiWLmvBstya6mXeIAJWoEZJWoOB/DLSYmd4=; b=nus5uqLJwr5NIGKklEfgbdraT+hhoMDSIGOt6WqZmcTfiTZZUhNIHPbL h1oQ3+B9JFyKSXsh47Z4FOHAp5n+ZL/MWP9yJS+XkAyYFn5bAODkQhzYK IrxctiTk0y2LMV4PNk06gEArsPEwmo/BrUYL9LCCElKS/c3f4UKvIkwVl 7/3FamXMWE21YpSLp4F/QONeanGVqeijF109mwaK4EpQQz0ucn4hOv67C Wn4s454Xe6gi50kuTGciVypV6DbsxFjDjKxTuWxzafFGpK393JwI+g2Wh c3RDPgCKS/Jt/3+7DBgWweYVCnRCO/6goKoVr2ws5QFSMxbkRicZzH7CR g==; X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="406354906" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="406354906" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2023 05:58:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="853272012" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="853272012" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga002.fm.intel.com with ESMTP; 29 Aug 2023 05:58:01 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, zhenyuw@linux.intel.com, Kan Liang Subject: [PATCH 1/6] perf/x86/intel: Use the common uarch name for the shared functions Date: Tue, 29 Aug 2023 05:58:01 -0700 Message-Id: <20230829125806.3016082-2-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230829125806.3016082-1-kan.liang@linux.intel.com> References: <20230829125806.3016082-1-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kan Liang From PMU's perspective, the SPR/GNR server has a similar uarch to the ADL/MTL client p-core. Many functions are shared. However, the shared function name uses the abbreviation of the server product code name, rather than the common uarch code name. Rename these internal shared functions by the common uarch name. Signed-off-by: Kan Liang --- arch/x86/events/intel/core.c | 64 ++++++++++++++++++------------------ arch/x86/events/intel/ds.c | 2 +- arch/x86/events/perf_event.h | 2 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 64a3533997e1..6c98c272d4f8 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -299,7 +299,7 @@ static struct extra_reg intel_icl_extra_regs[] __read_m= ostly =3D { EVENT_EXTRA_END }; =20 -static struct extra_reg intel_spr_extra_regs[] __read_mostly =3D { +static struct extra_reg intel_glc_extra_regs[] __read_mostly =3D { INTEL_UEVENT_EXTRA_REG(0x012a, MSR_OFFCORE_RSP_0, 0x3fffffffffull, RSP_0), INTEL_UEVENT_EXTRA_REG(0x012b, MSR_OFFCORE_RSP_1, 0x3fffffffffull, RSP_1), INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd), @@ -309,7 +309,7 @@ static struct extra_reg intel_spr_extra_regs[] __read_m= ostly =3D { EVENT_EXTRA_END }; =20 -static struct event_constraint intel_spr_event_constraints[] =3D { +static struct event_constraint intel_glc_event_constraints[] =3D { FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */ FIXED_EVENT_CONSTRAINT(0x0100, 0), /* INST_RETIRED.PREC_DIST */ FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */ @@ -349,7 +349,7 @@ static struct event_constraint intel_spr_event_constrai= nts[] =3D { EVENT_CONSTRAINT_END }; =20 -static struct extra_reg intel_gnr_extra_regs[] __read_mostly =3D { +static struct extra_reg intel_rwc_extra_regs[] __read_mostly =3D { INTEL_UEVENT_EXTRA_REG(0x012a, MSR_OFFCORE_RSP_0, 0x3fffffffffull, RSP_0), INTEL_UEVENT_EXTRA_REG(0x012b, MSR_OFFCORE_RSP_1, 0x3fffffffffull, RSP_1), INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd), @@ -473,7 +473,7 @@ static u64 intel_pmu_event_map(int hw_event) return intel_perfmon_event_map[hw_event]; } =20 -static __initconst const u64 spr_hw_cache_event_ids +static __initconst const u64 glc_hw_cache_event_ids [PERF_COUNT_HW_CACHE_MAX] [PERF_COUNT_HW_CACHE_OP_MAX] [PERF_COUNT_HW_CACHE_RESULT_MAX] =3D @@ -552,7 +552,7 @@ static __initconst const u64 spr_hw_cache_event_ids }, }; =20 -static __initconst const u64 spr_hw_cache_extra_regs +static __initconst const u64 glc_hw_cache_extra_regs [PERF_COUNT_HW_CACHE_MAX] [PERF_COUNT_HW_CACHE_OP_MAX] [PERF_COUNT_HW_CACHE_RESULT_MAX] =3D @@ -4266,7 +4266,7 @@ icl_get_event_constraints(struct cpu_hw_events *cpuc,= int idx, } =20 static struct event_constraint * -spr_get_event_constraints(struct cpu_hw_events *cpuc, int idx, +glc_get_event_constraints(struct cpu_hw_events *cpuc, int idx, struct perf_event *event) { struct event_constraint *c; @@ -4355,7 +4355,7 @@ adl_get_event_constraints(struct cpu_hw_events *cpuc,= int idx, struct x86_hybrid_pmu *pmu =3D hybrid_pmu(event->pmu); =20 if (pmu->cpu_type =3D=3D hybrid_big) - return spr_get_event_constraints(cpuc, idx, event); + return glc_get_event_constraints(cpuc, idx, event); else if (pmu->cpu_type =3D=3D hybrid_small) return tnt_get_event_constraints(cpuc, idx, event); =20 @@ -4402,7 +4402,7 @@ rwc_get_event_constraints(struct cpu_hw_events *cpuc,= int idx, { struct event_constraint *c; =20 - c =3D spr_get_event_constraints(cpuc, idx, event); + c =3D glc_get_event_constraints(cpuc, idx, event); =20 /* The Retire Latency is not supported by the fixed counter 0. */ if (event->attr.precise_ip && @@ -4483,7 +4483,7 @@ static void nhm_limit_period(struct perf_event *event= , s64 *left) *left =3D max(*left, 32LL); } =20 -static void spr_limit_period(struct perf_event *event, s64 *left) +static void glc_limit_period(struct perf_event *event, s64 *left) { if (event->attr.precise_ip =3D=3D 3) *left =3D max(*left, 128LL); @@ -5330,14 +5330,14 @@ static struct attribute *icl_tsx_events_attrs[] =3D= { EVENT_ATTR_STR(mem-stores, mem_st_spr, "event=3D0xcd,umask=3D0x2"); EVENT_ATTR_STR(mem-loads-aux, mem_ld_aux, "event=3D0x03,umask=3D0x82"); =20 -static struct attribute *spr_events_attrs[] =3D { +static struct attribute *glc_events_attrs[] =3D { EVENT_PTR(mem_ld_hsw), EVENT_PTR(mem_st_spr), EVENT_PTR(mem_ld_aux), NULL, }; =20 -static struct attribute *spr_td_events_attrs[] =3D { +static struct attribute *glc_td_events_attrs[] =3D { EVENT_PTR(slots), EVENT_PTR(td_retiring), EVENT_PTR(td_bad_spec), @@ -5350,7 +5350,7 @@ static struct attribute *spr_td_events_attrs[] =3D { NULL, }; =20 -static struct attribute *spr_tsx_events_attrs[] =3D { +static struct attribute *glc_tsx_events_attrs[] =3D { EVENT_PTR(tx_start), EVENT_PTR(tx_abort), EVENT_PTR(tx_commit), @@ -6208,7 +6208,7 @@ __init int intel_pmu_init(void) intel_pmu_pebs_data_source_grt(); x86_pmu.pebs_latency_data =3D adl_latency_data_small; x86_pmu.get_event_constraints =3D tnt_get_event_constraints; - x86_pmu.limit_period =3D spr_limit_period; + x86_pmu.limit_period =3D glc_limit_period; td_attr =3D tnt_events_attrs; mem_attr =3D grt_mem_attrs; extra_attr =3D nhm_format_attr; @@ -6239,7 +6239,7 @@ __init int intel_pmu_init(void) intel_pmu_pebs_data_source_cmt(); x86_pmu.pebs_latency_data =3D mtl_latency_data_small; x86_pmu.get_event_constraints =3D cmt_get_event_constraints; - x86_pmu.limit_period =3D spr_limit_period; + x86_pmu.limit_period =3D glc_limit_period; td_attr =3D cmt_events_attrs; mem_attr =3D grt_mem_attrs; extra_attr =3D cmt_format_attr; @@ -6556,20 +6556,20 @@ __init int intel_pmu_init(void) case INTEL_FAM6_SAPPHIRERAPIDS_X: case INTEL_FAM6_EMERALDRAPIDS_X: x86_pmu.flags |=3D PMU_FL_MEM_LOADS_AUX; - x86_pmu.extra_regs =3D intel_spr_extra_regs; + x86_pmu.extra_regs =3D intel_glc_extra_regs; fallthrough; case INTEL_FAM6_GRANITERAPIDS_X: case INTEL_FAM6_GRANITERAPIDS_D: pmem =3D true; x86_pmu.late_ack =3D true; - memcpy(hw_cache_event_ids, spr_hw_cache_event_ids, sizeof(hw_cache_event= _ids)); - memcpy(hw_cache_extra_regs, spr_hw_cache_extra_regs, sizeof(hw_cache_ext= ra_regs)); + memcpy(hw_cache_event_ids, glc_hw_cache_event_ids, sizeof(hw_cache_event= _ids)); + memcpy(hw_cache_extra_regs, glc_hw_cache_extra_regs, sizeof(hw_cache_ext= ra_regs)); =20 - x86_pmu.event_constraints =3D intel_spr_event_constraints; - x86_pmu.pebs_constraints =3D intel_spr_pebs_event_constraints; + x86_pmu.event_constraints =3D intel_glc_event_constraints; + x86_pmu.pebs_constraints =3D intel_glc_pebs_event_constraints; if (!x86_pmu.extra_regs) - x86_pmu.extra_regs =3D intel_gnr_extra_regs; - x86_pmu.limit_period =3D spr_limit_period; + x86_pmu.extra_regs =3D intel_rwc_extra_regs; + x86_pmu.limit_period =3D glc_limit_period; x86_pmu.pebs_ept =3D 1; x86_pmu.pebs_aliases =3D NULL; x86_pmu.pebs_prec_dist =3D true; @@ -6579,13 +6579,13 @@ __init int intel_pmu_init(void) x86_pmu.flags |=3D PMU_FL_INSTR_LATENCY; =20 x86_pmu.hw_config =3D hsw_hw_config; - x86_pmu.get_event_constraints =3D spr_get_event_constraints; + x86_pmu.get_event_constraints =3D glc_get_event_constraints; extra_attr =3D boot_cpu_has(X86_FEATURE_RTM) ? hsw_format_attr : nhm_format_attr; extra_skl_attr =3D skl_format_attr; - mem_attr =3D spr_events_attrs; - td_attr =3D spr_td_events_attrs; - tsx_attr =3D spr_tsx_events_attrs; + mem_attr =3D glc_events_attrs; + td_attr =3D glc_td_events_attrs; + tsx_attr =3D glc_tsx_events_attrs; x86_pmu.rtm_abort_event =3D X86_CONFIG(.event=3D0xc9, .umask=3D0x04); x86_pmu.lbr_pt_coexist =3D true; intel_pmu_pebs_data_source_skl(pmem); @@ -6635,7 +6635,7 @@ __init int intel_pmu_init(void) x86_pmu.filter =3D intel_pmu_filter; x86_pmu.get_event_constraints =3D adl_get_event_constraints; x86_pmu.hw_config =3D adl_hw_config; - x86_pmu.limit_period =3D spr_limit_period; + x86_pmu.limit_period =3D glc_limit_period; x86_pmu.get_hybrid_cpu_type =3D adl_get_hybrid_cpu_type; /* * The rtm_abort_event is used to check whether to enable GPRs @@ -6684,11 +6684,11 @@ __init int intel_pmu_init(void) pmu->intel_cap.perf_metrics =3D 1; pmu->intel_cap.pebs_output_pt_available =3D 0; =20 - memcpy(pmu->hw_cache_event_ids, spr_hw_cache_event_ids, sizeof(pmu->hw_c= ache_event_ids)); - memcpy(pmu->hw_cache_extra_regs, spr_hw_cache_extra_regs, sizeof(pmu->hw= _cache_extra_regs)); - pmu->event_constraints =3D intel_spr_event_constraints; - pmu->pebs_constraints =3D intel_spr_pebs_event_constraints; - pmu->extra_regs =3D intel_spr_extra_regs; + memcpy(pmu->hw_cache_event_ids, glc_hw_cache_event_ids, sizeof(pmu->hw_c= ache_event_ids)); + memcpy(pmu->hw_cache_extra_regs, glc_hw_cache_extra_regs, sizeof(pmu->hw= _cache_extra_regs)); + pmu->event_constraints =3D intel_glc_event_constraints; + pmu->pebs_constraints =3D intel_glc_pebs_event_constraints; + pmu->extra_regs =3D intel_glc_extra_regs; =20 /* Initialize Atom core specific PerfMon capabilities.*/ pmu =3D &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_ATOM_IDX]; @@ -6712,7 +6712,7 @@ __init int intel_pmu_init(void) pmu->pebs_constraints =3D intel_grt_pebs_event_constraints; pmu->extra_regs =3D intel_grt_extra_regs; if (is_mtl(boot_cpu_data.x86_model)) { - x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX].extra_regs =3D intel_gnr_ex= tra_regs; + x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX].extra_regs =3D intel_rwc_ex= tra_regs; x86_pmu.pebs_latency_data =3D mtl_latency_data_small; extra_attr =3D boot_cpu_has(X86_FEATURE_RTM) ? mtl_hybrid_extra_attr_rtm : mtl_hybrid_extra_attr; diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index eb8dd8b8a1e8..74642469ca7b 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1058,7 +1058,7 @@ struct event_constraint intel_icl_pebs_event_constrai= nts[] =3D { EVENT_CONSTRAINT_END }; =20 -struct event_constraint intel_spr_pebs_event_constraints[] =3D { +struct event_constraint intel_glc_pebs_event_constraints[] =3D { INTEL_FLAGS_UEVENT_CONSTRAINT(0x100, 0x100000000ULL), /* INST_RETIRED.PRE= C_DIST */ INTEL_FLAGS_UEVENT_CONSTRAINT(0x0400, 0x800000000ULL), =20 diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index c8ba2be7585d..96a427fc55cf 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -1521,7 +1521,7 @@ extern struct event_constraint intel_skl_pebs_event_c= onstraints[]; =20 extern struct event_constraint intel_icl_pebs_event_constraints[]; =20 -extern struct event_constraint intel_spr_pebs_event_constraints[]; +extern struct event_constraint intel_glc_pebs_event_constraints[]; =20 struct event_constraint *intel_pebs_constraints(struct perf_event *event); =20 --=20 2.35.1 From nobody Fri Dec 19 14:21:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81962C83F19 for ; Tue, 29 Aug 2023 12:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235797AbjH2M6o (ORCPT ); Tue, 29 Aug 2023 08:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235687AbjH2M6G (ORCPT ); Tue, 29 Aug 2023 08:58:06 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1289BF for ; Tue, 29 Aug 2023 05:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693313883; x=1724849883; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QldM16VWt9sIxeALCKvfIhayNh8wAJ4+hob5Nr/kC4A=; b=HjFR5bc+UF6rzaSOPWwrgzWlzlvwSaZAx6gnP4SlCOZXN3F4u+KS2MGb fwb5FRkNoNlokwMOvEXBwaUzf1/f5nJSzEj1sQ1Wjkq2IhOAk42bZi1Qu +T2hzbRXKVOrgmTYUiajHIMAF9YBt+hmKyELpIfjugQmWlzoEtqWkrcdU zZg1twmyH+zsFcBzuYF+7Ff1xo6h1NClw2nATA+rtK/9dl5zaotv7NE3Z T3s8WD9WFsdtIfPjfGqrDu4eyKJn5WcwpVQLkDgmZINAbI8lD3/lW2PfH IryPHlD+/YjDo/rNQvU0uhsrrWwmkLy6R1z6tYdQ4YJ1ZXOB3wqPDIM8q g==; X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="406354912" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="406354912" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2023 05:58:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="853272014" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="853272014" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga002.fm.intel.com with ESMTP; 29 Aug 2023 05:58:03 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, zhenyuw@linux.intel.com, Kan Liang Subject: [PATCH 2/6] perf/x86/intel: Factor out the initialization code for SPR Date: Tue, 29 Aug 2023 05:58:02 -0700 Message-Id: <20230829125806.3016082-3-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230829125806.3016082-1-kan.liang@linux.intel.com> References: <20230829125806.3016082-1-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kan Liang The SPR and ADL p-core have a similar uarch. Most of the initialization code can be shared. Factor out intel_pmu_init_glc() for the common initialization code. The common part of the ADL p-core will be replaced by the later patch. Signed-off-by: Kan Liang --- arch/x86/events/intel/core.c | 49 +++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 6c98c272d4f8..e9e69401524a 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -5909,6 +5909,30 @@ static __always_inline bool is_mtl(u8 x86_model) (x86_model =3D=3D INTEL_FAM6_METEORLAKE_L); } =20 +static __always_inline void intel_pmu_init_glc(struct pmu *pmu) +{ + x86_pmu.late_ack =3D true; + x86_pmu.limit_period =3D glc_limit_period; + x86_pmu.pebs_aliases =3D NULL; + x86_pmu.pebs_prec_dist =3D true; + x86_pmu.pebs_block =3D true; + x86_pmu.flags |=3D PMU_FL_HAS_RSP_1; + x86_pmu.flags |=3D PMU_FL_NO_HT_SHARING; + x86_pmu.flags |=3D PMU_FL_INSTR_LATENCY; + x86_pmu.rtm_abort_event =3D X86_CONFIG(.event=3D0xc9, .umask=3D0x04); + x86_pmu.lbr_pt_coexist =3D true; + x86_pmu.num_topdown_events =3D 8; + static_call_update(intel_pmu_update_topdown_event, + &icl_update_topdown_event); + static_call_update(intel_pmu_set_topdown_event_period, + &icl_set_topdown_event_period); + + memcpy(hybrid_var(pmu, hw_cache_event_ids), glc_hw_cache_event_ids, sizeo= f(hw_cache_event_ids)); + memcpy(hybrid_var(pmu, hw_cache_extra_regs), glc_hw_cache_extra_regs, siz= eof(hw_cache_extra_regs)); + hybrid(pmu, event_constraints) =3D intel_glc_event_constraints; + hybrid(pmu, pebs_constraints) =3D intel_glc_pebs_event_constraints; +} + __init int intel_pmu_init(void) { struct attribute **extra_skl_attr =3D &empty_attrs; @@ -6560,24 +6584,10 @@ __init int intel_pmu_init(void) fallthrough; case INTEL_FAM6_GRANITERAPIDS_X: case INTEL_FAM6_GRANITERAPIDS_D: - pmem =3D true; - x86_pmu.late_ack =3D true; - memcpy(hw_cache_event_ids, glc_hw_cache_event_ids, sizeof(hw_cache_event= _ids)); - memcpy(hw_cache_extra_regs, glc_hw_cache_extra_regs, sizeof(hw_cache_ext= ra_regs)); - - x86_pmu.event_constraints =3D intel_glc_event_constraints; - x86_pmu.pebs_constraints =3D intel_glc_pebs_event_constraints; + intel_pmu_init_glc(NULL); if (!x86_pmu.extra_regs) x86_pmu.extra_regs =3D intel_rwc_extra_regs; - x86_pmu.limit_period =3D glc_limit_period; x86_pmu.pebs_ept =3D 1; - x86_pmu.pebs_aliases =3D NULL; - x86_pmu.pebs_prec_dist =3D true; - x86_pmu.pebs_block =3D true; - x86_pmu.flags |=3D PMU_FL_HAS_RSP_1; - x86_pmu.flags |=3D PMU_FL_NO_HT_SHARING; - x86_pmu.flags |=3D PMU_FL_INSTR_LATENCY; - x86_pmu.hw_config =3D hsw_hw_config; x86_pmu.get_event_constraints =3D glc_get_event_constraints; extra_attr =3D boot_cpu_has(X86_FEATURE_RTM) ? @@ -6586,14 +6596,7 @@ __init int intel_pmu_init(void) mem_attr =3D glc_events_attrs; td_attr =3D glc_td_events_attrs; tsx_attr =3D glc_tsx_events_attrs; - x86_pmu.rtm_abort_event =3D X86_CONFIG(.event=3D0xc9, .umask=3D0x04); - x86_pmu.lbr_pt_coexist =3D true; - intel_pmu_pebs_data_source_skl(pmem); - x86_pmu.num_topdown_events =3D 8; - static_call_update(intel_pmu_update_topdown_event, - &icl_update_topdown_event); - static_call_update(intel_pmu_set_topdown_event_period, - &icl_set_topdown_event_period); + intel_pmu_pebs_data_source_skl(true); pr_cont("Sapphire Rapids events, "); name =3D "sapphire_rapids"; break; --=20 2.35.1 From nobody Fri Dec 19 14:21:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26BEEC83F14 for ; Tue, 29 Aug 2023 12:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235780AbjH2M6n (ORCPT ); Tue, 29 Aug 2023 08:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235677AbjH2M6I (ORCPT ); Tue, 29 Aug 2023 08:58:08 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA406BF for ; Tue, 29 Aug 2023 05:58:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693313884; x=1724849884; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+MgxxfOL3Ya8/z9wpXTgjf4K5Z5+XB/wR2Opc55Rkc0=; b=TJXiy3cUC99f9wwUPabQy2xeJSIjIQEkgqF007vNB6UiC02UYklUJmTm nESCEc0WoHTVJaZpPJaAq+Bg8OlXrp3L6YTBTgcp1kZPkMKgNYv+DtAu6 EV5SdA3AtG+GP+XKulL/zYuJRGAJbhC+qAR/qai1z8FrY1F5nxjSOnjSl FgQArUVkmDUwFhTw/MkZTimw6Xcdc65fZwlKMOzPBp+RjdissGN+iSZSS NeEJKmiVPCJ3csdSRDZQ3jh20s03iU4w07oXuGJD6fa0OQdioPlc9J3hF fShq0pmCeSK7LPMexnK6zceeaNl7t1I3neeJ2jaEf8NJRONIoMYLT9llr g==; X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="406354916" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="406354916" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2023 05:58:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="853272023" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="853272023" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga002.fm.intel.com with ESMTP; 29 Aug 2023 05:58:04 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, zhenyuw@linux.intel.com, Kan Liang Subject: [PATCH 3/6] perf/x86/intel: Factor out the initialization code for ADL e-core Date: Tue, 29 Aug 2023 05:58:03 -0700 Message-Id: <20230829125806.3016082-4-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230829125806.3016082-1-kan.liang@linux.intel.com> References: <20230829125806.3016082-1-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kan Liang From PMU's perspective, the ADL e-core and newer SRF/GRR have a similar uarch. Most of the initialization code can be shared. Factor out intel_pmu_init_grt() for the common initialization code. The common part of the ADL e-core will be replaced by the later patch. Signed-off-by: Kan Liang --- arch/x86/events/intel/core.c | 58 +++++++++++++----------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index e9e69401524a..cffaa97035a0 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -5933,6 +5933,25 @@ static __always_inline void intel_pmu_init_glc(struc= t pmu *pmu) hybrid(pmu, pebs_constraints) =3D intel_glc_pebs_event_constraints; } =20 +static __always_inline void intel_pmu_init_grt(struct pmu *pmu) +{ + x86_pmu.mid_ack =3D true; + x86_pmu.limit_period =3D glc_limit_period; + x86_pmu.pebs_aliases =3D NULL; + x86_pmu.pebs_prec_dist =3D true; + x86_pmu.pebs_block =3D true; + x86_pmu.lbr_pt_coexist =3D true; + x86_pmu.flags |=3D PMU_FL_HAS_RSP_1; + x86_pmu.flags |=3D PMU_FL_INSTR_LATENCY; + + memcpy(hybrid_var(pmu, hw_cache_event_ids), glp_hw_cache_event_ids, sizeo= f(hw_cache_event_ids)); + memcpy(hybrid_var(pmu, hw_cache_extra_regs), tnt_hw_cache_extra_regs, siz= eof(hw_cache_extra_regs)); + hybrid_var(pmu, hw_cache_event_ids)[C(ITLB)][C(OP_READ)][C(RESULT_ACCESS)= ] =3D -1; + hybrid(pmu, event_constraints) =3D intel_slm_event_constraints; + hybrid(pmu, pebs_constraints) =3D intel_grt_pebs_event_constraints; + hybrid(pmu, extra_regs) =3D intel_grt_extra_regs; +} + __init int intel_pmu_init(void) { struct attribute **extra_skl_attr =3D &empty_attrs; @@ -6211,28 +6230,10 @@ __init int intel_pmu_init(void) break; =20 case INTEL_FAM6_ATOM_GRACEMONT: - x86_pmu.mid_ack =3D true; - memcpy(hw_cache_event_ids, glp_hw_cache_event_ids, - sizeof(hw_cache_event_ids)); - memcpy(hw_cache_extra_regs, tnt_hw_cache_extra_regs, - sizeof(hw_cache_extra_regs)); - hw_cache_event_ids[C(ITLB)][C(OP_READ)][C(RESULT_ACCESS)] =3D -1; - - x86_pmu.event_constraints =3D intel_slm_event_constraints; - x86_pmu.pebs_constraints =3D intel_grt_pebs_event_constraints; - x86_pmu.extra_regs =3D intel_grt_extra_regs; - - x86_pmu.pebs_aliases =3D NULL; - x86_pmu.pebs_prec_dist =3D true; - x86_pmu.pebs_block =3D true; - x86_pmu.lbr_pt_coexist =3D true; - x86_pmu.flags |=3D PMU_FL_HAS_RSP_1; - x86_pmu.flags |=3D PMU_FL_INSTR_LATENCY; - + intel_pmu_init_grt(NULL); intel_pmu_pebs_data_source_grt(); x86_pmu.pebs_latency_data =3D adl_latency_data_small; x86_pmu.get_event_constraints =3D tnt_get_event_constraints; - x86_pmu.limit_period =3D glc_limit_period; td_attr =3D tnt_events_attrs; mem_attr =3D grt_mem_attrs; extra_attr =3D nhm_format_attr; @@ -6242,28 +6243,11 @@ __init int intel_pmu_init(void) =20 case INTEL_FAM6_ATOM_CRESTMONT: case INTEL_FAM6_ATOM_CRESTMONT_X: - x86_pmu.mid_ack =3D true; - memcpy(hw_cache_event_ids, glp_hw_cache_event_ids, - sizeof(hw_cache_event_ids)); - memcpy(hw_cache_extra_regs, tnt_hw_cache_extra_regs, - sizeof(hw_cache_extra_regs)); - hw_cache_event_ids[C(ITLB)][C(OP_READ)][C(RESULT_ACCESS)] =3D -1; - - x86_pmu.event_constraints =3D intel_slm_event_constraints; - x86_pmu.pebs_constraints =3D intel_grt_pebs_event_constraints; + intel_pmu_init_grt(NULL); x86_pmu.extra_regs =3D intel_cmt_extra_regs; - - x86_pmu.pebs_aliases =3D NULL; - x86_pmu.pebs_prec_dist =3D true; - x86_pmu.lbr_pt_coexist =3D true; - x86_pmu.pebs_block =3D true; - x86_pmu.flags |=3D PMU_FL_HAS_RSP_1; - x86_pmu.flags |=3D PMU_FL_INSTR_LATENCY; - intel_pmu_pebs_data_source_cmt(); x86_pmu.pebs_latency_data =3D mtl_latency_data_small; x86_pmu.get_event_constraints =3D cmt_get_event_constraints; - x86_pmu.limit_period =3D glc_limit_period; td_attr =3D cmt_events_attrs; mem_attr =3D grt_mem_attrs; extra_attr =3D cmt_format_attr; --=20 2.35.1 From nobody Fri Dec 19 14:21:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0ED95C83F18 for ; Tue, 29 Aug 2023 12:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235758AbjH2M6l (ORCPT ); Tue, 29 Aug 2023 08:58:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235695AbjH2M6I (ORCPT ); Tue, 29 Aug 2023 08:58:08 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00AC8103 for ; Tue, 29 Aug 2023 05:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693313885; x=1724849885; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2fO88cgS2dndEL6XdAkpOAGNtf0jrYKCFzDS190Nwag=; b=iiWjmMkc9HTPIMvIR7F8bsW+tJ9OpqkDn/sADzR3Wgas+4uHnOwpr0nA urJF0uCDjEhPfwBq9N80lHrITlqHROoUd9A2hFHYsSORSCVU8eYQuwE2+ KcN0lCBSMRfucdSBHCUkmRGAbHjZPFgMm33x/vc0CyhGlNjbdSBL38KJt W9xJ3K6NwgTlDJIhYz6rJ8j251rzI1TJJpFU+dmPp7erEIIBYf6ZguIcb ARRlof9AhLYBFUsdsx5Fe+dmNL2qGJhA7gBrPMIShVblcnfmbiKUvsYbw pWIR4gvWYXeUDVymKLy6/T4Og4r6gC/yNZhcjrWp6gts/khx4uViqE3Fj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="406354920" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="406354920" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2023 05:58:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="853272034" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="853272034" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga002.fm.intel.com with ESMTP; 29 Aug 2023 05:58:05 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, zhenyuw@linux.intel.com, Kan Liang Subject: [PATCH 4/6] perf/x86/intel: Apply the common initialization code for ADL Date: Tue, 29 Aug 2023 05:58:04 -0700 Message-Id: <20230829125806.3016082-5-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230829125806.3016082-1-kan.liang@linux.intel.com> References: <20230829125806.3016082-1-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kan Liang Use the intel_pmu_init_glc() and intel_pmu_init_grt() to replace the duplicate code for ADL. The current code already checks the PERF_X86_EVENT_TOPDOWN flag before invoking the Topdown metrics functions. (The PERF_X86_EVENT_TOPDOWN flag is to indicate the Topdown metric feature, which is only available for the p-core.) Drop the unnecessary adl_set_topdown_event_period() and adl_update_topdown_event(). Signed-off-by: Kan Liang --- arch/x86/events/intel/core.c | 53 ++---------------------------------- 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index cffaa97035a0..3537b62a4f17 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -2556,16 +2556,6 @@ static int icl_set_topdown_event_period(struct perf_= event *event) return 0; } =20 -static int adl_set_topdown_event_period(struct perf_event *event) -{ - struct x86_hybrid_pmu *pmu =3D hybrid_pmu(event->pmu); - - if (pmu->cpu_type !=3D hybrid_big) - return 0; - - return icl_set_topdown_event_period(event); -} - DEFINE_STATIC_CALL(intel_pmu_set_topdown_event_period, x86_perf_event_set_= period); =20 static inline u64 icl_get_metrics_event_value(u64 metric, u64 slots, int i= dx) @@ -2708,16 +2698,6 @@ static u64 icl_update_topdown_event(struct perf_even= t *event) x86_pmu.num_topdown_events - 1); } =20 -static u64 adl_update_topdown_event(struct perf_event *event) -{ - struct x86_hybrid_pmu *pmu =3D hybrid_pmu(event->pmu); - - if (pmu->cpu_type !=3D hybrid_big) - return 0; - - return icl_update_topdown_event(event); -} - DEFINE_STATIC_CALL(intel_pmu_update_topdown_event, x86_perf_event_update); =20 static void intel_pmu_read_topdown_event(struct perf_event *event) @@ -6605,32 +6585,11 @@ __init int intel_pmu_init(void) static_branch_enable(&perf_is_hybrid); x86_pmu.num_hybrid_pmus =3D X86_HYBRID_NUM_PMUS; =20 - x86_pmu.pebs_aliases =3D NULL; - x86_pmu.pebs_prec_dist =3D true; - x86_pmu.pebs_block =3D true; - x86_pmu.flags |=3D PMU_FL_HAS_RSP_1; - x86_pmu.flags |=3D PMU_FL_NO_HT_SHARING; - x86_pmu.flags |=3D PMU_FL_INSTR_LATENCY; - x86_pmu.lbr_pt_coexist =3D true; x86_pmu.pebs_latency_data =3D adl_latency_data_small; - x86_pmu.num_topdown_events =3D 8; - static_call_update(intel_pmu_update_topdown_event, - &adl_update_topdown_event); - static_call_update(intel_pmu_set_topdown_event_period, - &adl_set_topdown_event_period); - x86_pmu.filter =3D intel_pmu_filter; x86_pmu.get_event_constraints =3D adl_get_event_constraints; x86_pmu.hw_config =3D adl_hw_config; - x86_pmu.limit_period =3D glc_limit_period; x86_pmu.get_hybrid_cpu_type =3D adl_get_hybrid_cpu_type; - /* - * The rtm_abort_event is used to check whether to enable GPRs - * for the RTM abort event. Atom doesn't have the RTM abort - * event. There is no harmful to set it in the common - * x86_pmu.rtm_abort_event. - */ - x86_pmu.rtm_abort_event =3D X86_CONFIG(.event=3D0xc9, .umask=3D0x04); =20 td_attr =3D adl_hybrid_events_attrs; mem_attr =3D adl_hybrid_mem_attrs; @@ -6642,6 +6601,7 @@ __init int intel_pmu_init(void) pmu =3D &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX]; pmu->name =3D "cpu_core"; pmu->cpu_type =3D hybrid_big; + intel_pmu_init_glc(&pmu->pmu); pmu->late_ack =3D true; if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) { pmu->num_counters =3D x86_pmu.num_counters + 2; @@ -6671,16 +6631,13 @@ __init int intel_pmu_init(void) pmu->intel_cap.perf_metrics =3D 1; pmu->intel_cap.pebs_output_pt_available =3D 0; =20 - memcpy(pmu->hw_cache_event_ids, glc_hw_cache_event_ids, sizeof(pmu->hw_c= ache_event_ids)); - memcpy(pmu->hw_cache_extra_regs, glc_hw_cache_extra_regs, sizeof(pmu->hw= _cache_extra_regs)); - pmu->event_constraints =3D intel_glc_event_constraints; - pmu->pebs_constraints =3D intel_glc_pebs_event_constraints; pmu->extra_regs =3D intel_glc_extra_regs; =20 /* Initialize Atom core specific PerfMon capabilities.*/ pmu =3D &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_ATOM_IDX]; pmu->name =3D "cpu_atom"; pmu->cpu_type =3D hybrid_small; + intel_pmu_init_grt(&pmu->pmu); pmu->mid_ack =3D true; pmu->num_counters =3D x86_pmu.num_counters; pmu->num_counters_fixed =3D x86_pmu.num_counters_fixed; @@ -6692,12 +6649,6 @@ __init int intel_pmu_init(void) pmu->intel_cap.perf_metrics =3D 0; pmu->intel_cap.pebs_output_pt_available =3D 1; =20 - memcpy(pmu->hw_cache_event_ids, glp_hw_cache_event_ids, sizeof(pmu->hw_c= ache_event_ids)); - memcpy(pmu->hw_cache_extra_regs, tnt_hw_cache_extra_regs, sizeof(pmu->hw= _cache_extra_regs)); - pmu->hw_cache_event_ids[C(ITLB)][C(OP_READ)][C(RESULT_ACCESS)] =3D -1; - pmu->event_constraints =3D intel_slm_event_constraints; - pmu->pebs_constraints =3D intel_grt_pebs_event_constraints; - pmu->extra_regs =3D intel_grt_extra_regs; if (is_mtl(boot_cpu_data.x86_model)) { x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX].extra_regs =3D intel_rwc_ex= tra_regs; x86_pmu.pebs_latency_data =3D mtl_latency_data_small; --=20 2.35.1 From nobody Fri Dec 19 14:21:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3317C83F1A for ; Tue, 29 Aug 2023 12:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235829AbjH2M6q (ORCPT ); Tue, 29 Aug 2023 08:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235702AbjH2M6K (ORCPT ); Tue, 29 Aug 2023 08:58:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ACB9BF for ; Tue, 29 Aug 2023 05:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693313887; x=1724849887; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=THg7GnXcWD5Z0mLbTgh+8xaYdma4pHunCisGc6fKDGM=; b=Do23nOYKjR3aQlvST9cSbkNDw7dbKOvqGsSo9gGiINACS17BKni4N8/D 2iQjFrGYhTDtVYvmmXbxFdSaBkVuwFPpTvqIgAGFjlNsPzkxPVDJ7Eadl OUwE+WY5OcL9ueUfPG4jEjwWhDVQwpc9Yf0Oxe7q8SACBRMi1wSlkGE+9 r13/1CMlfk0rQVS8WWjHYEu17Uj41ygq2bL6ky12eRp99+L15KMUL9eO7 fKVMmIhAOAcGp3tqtcXbPgsjwSBdV9t04lC5RT8S4Vmxmt6QbhUivgKOD DY5ZPVOhWfDGhpfnS35NNNYilGSvgnjY0UEpGSLS397vP46vqJC1v416i A==; X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="406354924" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="406354924" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2023 05:58:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="853272040" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="853272040" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga002.fm.intel.com with ESMTP; 29 Aug 2023 05:58:06 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, zhenyuw@linux.intel.com, Kan Liang , Dave Hansen Subject: [PATCH 5/6] perf/x86/intel: Cleanup the hybrid CPU type Date: Tue, 29 Aug 2023 05:58:05 -0700 Message-Id: <20230829125806.3016082-6-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230829125806.3016082-1-kan.liang@linux.intel.com> References: <20230829125806.3016082-1-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kan Liang There is a fairly long list of grievances about the current code. The main beefs: 1. hybrid_big_small assumes that the *HARDWARE* (CPUID) provided core types are a bitmap. They are not. If Intel happened to make a core type of 0xff, hilarity would ensue. 2. adl_get_hybrid_cpu_type() utterly inscrutable. There are precisely zero comments and zero changelog about what it is attempting to do. According to Kan, the adl_get_hybrid_cpu_type() is there because some Alder Lake (ADL) CPUs can do some silly things. Some ADL models are *supposed* to be hybrid CPUs with big and little cores, but there are some SKUs that only have big cores. CPUID(0x1a) on those CPUs does not say that the CPUs are big cores. It apparently just returns 0x0. It confuses perf because it expects to see either 0x40 (Core) or 0x20 (Atom). The perf workaround for this is to watch for a CPU core saying it is type 0x0. If that happens on an Alder Lake, it calls x86_pmu.get_hybrid_cpu_type() and just assumes that the core is a Core (0x40) CPU. To fix up the mess, separate out the CPU types and the 'pmu' types. This allows 'hybrid_pmu_type' bitmaps without worrying that some future CPU type will set multiple bits. Since the types are now separate, add a function to glue them back together again. Actual comment on the situation in the glue function (find_hybrid_pmu_for_cpu()). Also, give ->get_hybrid_cpu_type() a real return type and make it clear that it is overriding the *CPU* type, not the PMU type. Rename cpu_type to pmu_type in the struct x86_hybrid_pmu to reflect the change. Originally-by: Dave Hansen Signed-off-by: Kan Liang Cc: Dave Hansen --- arch/x86/events/core.c | 6 ++-- arch/x86/events/intel/core.c | 69 ++++++++++++++++++++++++------------ arch/x86/events/intel/ds.c | 2 +- arch/x86/events/perf_event.h | 35 ++++++++++-------- 4 files changed, 72 insertions(+), 40 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 185f902e5f28..40ad1425ffa2 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1887,9 +1887,9 @@ ssize_t events_hybrid_sysfs_show(struct device *dev, =20 str =3D pmu_attr->event_str; for (i =3D 0; i < x86_pmu.num_hybrid_pmus; i++) { - if (!(x86_pmu.hybrid_pmu[i].cpu_type & pmu_attr->pmu_type)) + if (!(x86_pmu.hybrid_pmu[i].pmu_type & pmu_attr->pmu_type)) continue; - if (x86_pmu.hybrid_pmu[i].cpu_type & pmu->cpu_type) { + if (x86_pmu.hybrid_pmu[i].pmu_type & pmu->pmu_type) { next_str =3D strchr(str, ';'); if (next_str) return snprintf(page, next_str - str + 1, "%s", str); @@ -2169,7 +2169,7 @@ static int __init init_hw_perf_events(void) hybrid_pmu->pmu.capabilities |=3D PERF_PMU_CAP_EXTENDED_HW_TYPE; =20 err =3D perf_pmu_register(&hybrid_pmu->pmu, hybrid_pmu->name, - (hybrid_pmu->cpu_type =3D=3D hybrid_big) ? PERF_TYPE_RAW : -1); + (hybrid_pmu->pmu_type =3D=3D hybrid_big) ? PERF_TYPE_RAW : -1); if (err) break; } diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 3537b62a4f17..bfa0649c31f4 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3849,7 +3849,7 @@ static inline bool require_mem_loads_aux_event(struct= perf_event *event) return false; =20 if (is_hybrid()) - return hybrid_pmu(event->pmu)->cpu_type =3D=3D hybrid_big; + return hybrid_pmu(event->pmu)->pmu_type =3D=3D hybrid_big; =20 return true; } @@ -4334,9 +4334,9 @@ adl_get_event_constraints(struct cpu_hw_events *cpuc,= int idx, { struct x86_hybrid_pmu *pmu =3D hybrid_pmu(event->pmu); =20 - if (pmu->cpu_type =3D=3D hybrid_big) + if (pmu->pmu_type =3D=3D hybrid_big) return glc_get_event_constraints(cpuc, idx, event); - else if (pmu->cpu_type =3D=3D hybrid_small) + else if (pmu->pmu_type =3D=3D hybrid_small) return tnt_get_event_constraints(cpuc, idx, event); =20 WARN_ON(1); @@ -4406,9 +4406,9 @@ mtl_get_event_constraints(struct cpu_hw_events *cpuc,= int idx, { struct x86_hybrid_pmu *pmu =3D hybrid_pmu(event->pmu); =20 - if (pmu->cpu_type =3D=3D hybrid_big) + if (pmu->pmu_type =3D=3D hybrid_big) return rwc_get_event_constraints(cpuc, idx, event); - if (pmu->cpu_type =3D=3D hybrid_small) + if (pmu->pmu_type =3D=3D hybrid_small) return cmt_get_event_constraints(cpuc, idx, event); =20 WARN_ON(1); @@ -4419,18 +4419,18 @@ static int adl_hw_config(struct perf_event *event) { struct x86_hybrid_pmu *pmu =3D hybrid_pmu(event->pmu); =20 - if (pmu->cpu_type =3D=3D hybrid_big) + if (pmu->pmu_type =3D=3D hybrid_big) return hsw_hw_config(event); - else if (pmu->cpu_type =3D=3D hybrid_small) + else if (pmu->pmu_type =3D=3D hybrid_small) return intel_pmu_hw_config(event); =20 WARN_ON(1); return -EOPNOTSUPP; } =20 -static u8 adl_get_hybrid_cpu_type(void) +static enum hybrid_cpu_type adl_get_hybrid_cpu_type(void) { - return hybrid_big; + return HYBRID_INTEL_CORE; } =20 /* @@ -4606,22 +4606,47 @@ static void update_pmu_cap(struct x86_hybrid_pmu *p= mu) } } =20 -static bool init_hybrid_pmu(int cpu) +static struct x86_hybrid_pmu *find_hybrid_pmu_for_cpu(void) { - struct cpu_hw_events *cpuc =3D &per_cpu(cpu_hw_events, cpu); u8 cpu_type =3D get_this_hybrid_cpu_type(); - struct x86_hybrid_pmu *pmu =3D NULL; int i; =20 - if (!cpu_type && x86_pmu.get_hybrid_cpu_type) - cpu_type =3D x86_pmu.get_hybrid_cpu_type(); + /* + * This is running on a CPU model that is known to have hybrid + * configurations. But the CPU told us it is not hybrid, shame + * on it. There should be a fixup function provided for these + * troublesome cpus (->get_hybrid_cpu_type). + */ + if (cpu_type =3D=3D HYBRID_INTEL_NONE) { + if (x86_pmu.get_hybrid_cpu_type) + cpu_type =3D x86_pmu.get_hybrid_cpu_type(); + else + return NULL; + } =20 + /* + * This essentially just maps between the 'hybrid_cpu_type' + * and 'hybrid_pmu_type' enums: + */ for (i =3D 0; i < x86_pmu.num_hybrid_pmus; i++) { - if (x86_pmu.hybrid_pmu[i].cpu_type =3D=3D cpu_type) { - pmu =3D &x86_pmu.hybrid_pmu[i]; - break; - } + enum hybrid_pmu_type pmu_type =3D x86_pmu.hybrid_pmu[i].pmu_type; + + if (cpu_type =3D=3D HYBRID_INTEL_CORE && + pmu_type =3D=3D hybrid_big) + return &x86_pmu.hybrid_pmu[i]; + if (cpu_type =3D=3D HYBRID_INTEL_ATOM && + pmu_type =3D=3D hybrid_small) + return &x86_pmu.hybrid_pmu[i]; } + + return NULL; +} + +static bool init_hybrid_pmu(int cpu) +{ + struct cpu_hw_events *cpuc =3D &per_cpu(cpu_hw_events, cpu); + struct x86_hybrid_pmu *pmu =3D find_hybrid_pmu_for_cpu(); + if (WARN_ON_ONCE(!pmu || (pmu->pmu.type =3D=3D -1))) { cpuc->pmu =3D NULL; return false; @@ -5672,7 +5697,7 @@ static bool is_attr_for_this_pmu(struct kobject *kobj= , struct attribute *attr) struct perf_pmu_events_hybrid_attr *pmu_attr =3D container_of(attr, struct perf_pmu_events_hybrid_attr, attr.attr); =20 - return pmu->cpu_type & pmu_attr->pmu_type; + return pmu->pmu_type & pmu_attr->pmu_type; } =20 static umode_t hybrid_events_is_visible(struct kobject *kobj, @@ -5709,7 +5734,7 @@ static umode_t hybrid_format_is_visible(struct kobjec= t *kobj, container_of(attr, struct perf_pmu_format_hybrid_attr, attr.attr); int cpu =3D hybrid_find_supported_cpu(pmu); =20 - return (cpu >=3D 0) && (pmu->cpu_type & pmu_attr->pmu_type) ? attr->mode = : 0; + return (cpu >=3D 0) && (pmu->pmu_type & pmu_attr->pmu_type) ? attr->mode = : 0; } =20 static struct attribute_group hybrid_group_events_td =3D { @@ -6600,7 +6625,7 @@ __init int intel_pmu_init(void) /* Initialize big core specific PerfMon capabilities.*/ pmu =3D &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX]; pmu->name =3D "cpu_core"; - pmu->cpu_type =3D hybrid_big; + pmu->pmu_type =3D hybrid_big; intel_pmu_init_glc(&pmu->pmu); pmu->late_ack =3D true; if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) { @@ -6636,7 +6661,7 @@ __init int intel_pmu_init(void) /* Initialize Atom core specific PerfMon capabilities.*/ pmu =3D &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_ATOM_IDX]; pmu->name =3D "cpu_atom"; - pmu->cpu_type =3D hybrid_small; + pmu->pmu_type =3D hybrid_small; intel_pmu_init_grt(&pmu->pmu); pmu->mid_ack =3D true; pmu->num_counters =3D x86_pmu.num_counters; diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 74642469ca7b..bf97ab904d40 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -261,7 +261,7 @@ static u64 __adl_latency_data_small(struct perf_event *= event, u64 status, { u64 val; =20 - WARN_ON_ONCE(hybrid_pmu(event->pmu)->cpu_type =3D=3D hybrid_big); + WARN_ON_ONCE(hybrid_pmu(event->pmu)->pmu_type =3D=3D hybrid_big); =20 dse &=3D PERF_PEBS_DATA_SOURCE_MASK; val =3D hybrid_var(event->pmu, pebs_data_source)[dse]; diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index 96a427fc55cf..53dd5d495ba6 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -652,10 +652,29 @@ enum { #define PERF_PEBS_DATA_SOURCE_MAX 0x10 #define PERF_PEBS_DATA_SOURCE_MASK (PERF_PEBS_DATA_SOURCE_MAX - 1) =20 +enum hybrid_cpu_type { + HYBRID_INTEL_NONE, + HYBRID_INTEL_ATOM =3D 0x20, + HYBRID_INTEL_CORE =3D 0x40, +}; + +enum hybrid_pmu_type { + not_hybrid, + hybrid_small =3D BIT(0), + hybrid_big =3D BIT(1), + + hybrid_big_small =3D hybrid_big | hybrid_small, /* only used for matching= */ +}; + +#define X86_HYBRID_PMU_ATOM_IDX 0 +#define X86_HYBRID_PMU_CORE_IDX 1 + +#define X86_HYBRID_NUM_PMUS 2 + struct x86_hybrid_pmu { struct pmu pmu; const char *name; - u8 cpu_type; + enum hybrid_pmu_type pmu_type; cpumask_t supported_cpus; union perf_capabilities intel_cap; u64 intel_ctrl; @@ -721,18 +740,6 @@ extern struct static_key_false perf_is_hybrid; __Fp; \ }) =20 -enum hybrid_pmu_type { - hybrid_big =3D 0x40, - hybrid_small =3D 0x20, - - hybrid_big_small =3D hybrid_big | hybrid_small, -}; - -#define X86_HYBRID_PMU_ATOM_IDX 0 -#define X86_HYBRID_PMU_CORE_IDX 1 - -#define X86_HYBRID_NUM_PMUS 2 - /* * struct x86_pmu - generic x86 pmu */ @@ -940,7 +947,7 @@ struct x86_pmu { */ int num_hybrid_pmus; struct x86_hybrid_pmu *hybrid_pmu; - u8 (*get_hybrid_cpu_type) (void); + enum hybrid_cpu_type (*get_hybrid_cpu_type) (void); }; =20 struct x86_perf_task_context_opt { --=20 2.35.1 From nobody Fri Dec 19 14:21:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 928CFC83F1B for ; Tue, 29 Aug 2023 12:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235814AbjH2M6p (ORCPT ); Tue, 29 Aug 2023 08:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235704AbjH2M6L (ORCPT ); Tue, 29 Aug 2023 08:58:11 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 568741B1 for ; Tue, 29 Aug 2023 05:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693313888; x=1724849888; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B19Z5mDZjHZJzulH+0lq1kciqImUSK7h19ku8N3Ofx4=; b=EeM7MqkiYEoSwE/PswYlkXO020QXtCOCzxE3poa2B4edhgIui3BvCmXt IPGErFSJmEBT+sEVUeUn8mE8TSq/IU8J5K8PiM7dxf/sY0FqISy+fKw4o qkqsH6RAUh0DBWjXK4wQ/tMPoZlV6ijKbb2JE1/f/CzM8oLRhz9E9OOWb s5I03z/AI87Ybape8wI1RJaOnHNNP9oRxaLjTWDeChfnsjgp2juzMQZn4 HcrswdnJA/+cj9KLQtM55X9CCvVWxZYWsLcl3xtHy+yJJTlHFw4rpOJu4 2u2gvUdiE0TPfc0d1BOYNBIbTMmYW11p6GGojtTlp7FjmnhFJre+Dlrkv g==; X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="406354928" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="406354928" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2023 05:58:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10817"; a="853272045" X-IronPort-AV: E=Sophos;i="6.02,210,1688454000"; d="scan'208";a="853272045" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga002.fm.intel.com with ESMTP; 29 Aug 2023 05:58:07 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, zhenyuw@linux.intel.com, Kan Liang Subject: [PATCH 6/6] perf/x86/intel: Add common intel_pmu_init_hybrid Date: Tue, 29 Aug 2023 05:58:06 -0700 Message-Id: <20230829125806.3016082-7-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230829125806.3016082-1-kan.liang@linux.intel.com> References: <20230829125806.3016082-1-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kan Liang The current hybrid initialization codes aren't well organized and are hard to read. Factor out intel_pmu_init_hybrid() to do a common setup for each hybrid PMU. The PMU-specific capability will be updated later via either hard code (ADL) or CPUID hybrid enumeration (MTL). Splitting the ADL and MTL initialization codes, since they have different uarches. The hard code PMU capabilities are not required for MTL either. They can be enumerated by the new leaf 0x23 and IA32_PERF_CAPABILITIES MSR. The hybrid enumeration of the IA32_PERF_CAPABILITIES MSR is broken on MTL. Using the default value. Signed-off-by: Kan Liang --- arch/x86/events/intel/core.c | 162 ++++++++++++++++++++++++----------- 1 file changed, 111 insertions(+), 51 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index bfa0649c31f4..89be504abca9 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -4591,6 +4591,16 @@ static void intel_pmu_check_num_counters(int *num_co= unters, int *num_counters_fixed, u64 *intel_ctrl, u64 fixed_mask); =20 +static inline bool intel_pmu_broken_perf_cap(void) +{ + /* The Perf Metric (Bit 15) is always cleared */ + if ((boot_cpu_data.x86_model =3D=3D INTEL_FAM6_METEORLAKE) || + (boot_cpu_data.x86_model =3D=3D INTEL_FAM6_METEORLAKE_L)) + return true; + + return false; +} + static void update_pmu_cap(struct x86_hybrid_pmu *pmu) { unsigned int sub_bitmaps =3D cpuid_eax(ARCH_PERFMON_EXT_LEAF); @@ -4603,7 +4613,27 @@ static void update_pmu_cap(struct x86_hybrid_pmu *pm= u) pmu->num_counters_fixed =3D fls(ebx); intel_pmu_check_num_counters(&pmu->num_counters, &pmu->num_counters_fixe= d, &pmu->intel_ctrl, ebx); + pmu->max_pebs_events =3D min_t(unsigned, MAX_PEBS_EVENTS, pmu->num_count= ers); + pmu->unconstrained =3D (struct event_constraint) + __EVENT_CONSTRAINT(0, (1ULL << pmu->num_counters) - 1, + 0, pmu->num_counters, 0, 0); } + + + if (!intel_pmu_broken_perf_cap()) { + /* Perf Metric (Bit 15) and PEBS via PT (Bit 16) are hybrid enumeration = */ + rdmsrl(MSR_IA32_PERF_CAPABILITIES, pmu->intel_cap.capabilities); + } + + if (pmu->intel_cap.perf_metrics) + pmu->intel_ctrl |=3D 1ULL << GLOBAL_CTRL_EN_PERF_METRICS; + else + pmu->intel_ctrl &=3D ~(1ULL << GLOBAL_CTRL_EN_PERF_METRICS); + + if (pmu->intel_cap.pebs_output_pt_available) + pmu->pmu.capabilities |=3D PERF_PMU_CAP_AUX_OUTPUT; + else + pmu->pmu.capabilities |=3D ~PERF_PMU_CAP_AUX_OUTPUT; } =20 static struct x86_hybrid_pmu *find_hybrid_pmu_for_cpu(void) @@ -5908,10 +5938,52 @@ static void intel_pmu_check_hybrid_pmus(u64 fixed_m= ask) } } =20 -static __always_inline bool is_mtl(u8 x86_model) +static const struct { enum hybrid_pmu_type id; char *name; } intel_hybrid_= pmu_type_map[] __initconst =3D { + { hybrid_small, "cpu_atom" }, + { hybrid_big, "cpu_core" }, +}; + +static __always_inline int intel_pmu_init_hybrid(enum hybrid_pmu_type pmus) { - return (x86_model =3D=3D INTEL_FAM6_METEORLAKE) || - (x86_model =3D=3D INTEL_FAM6_METEORLAKE_L); + unsigned long pmus_mask =3D pmus; + struct x86_hybrid_pmu *pmu; + int idx =3D 0, bit; + + x86_pmu.num_hybrid_pmus =3D hweight_long(pmus_mask); + x86_pmu.hybrid_pmu =3D kcalloc(x86_pmu.num_hybrid_pmus, + sizeof(struct x86_hybrid_pmu), + GFP_KERNEL); + if (!x86_pmu.hybrid_pmu) + return -ENOMEM; + + static_branch_enable(&perf_is_hybrid); + x86_pmu.filter =3D intel_pmu_filter; + + for_each_set_bit(bit, &pmus_mask, ARRAY_SIZE(intel_hybrid_pmu_type_map)) { + pmu =3D &x86_pmu.hybrid_pmu[idx++]; + pmu->pmu_type =3D intel_hybrid_pmu_type_map[bit].id; + pmu->name =3D intel_hybrid_pmu_type_map[bit].name; + + pmu->num_counters =3D x86_pmu.num_counters; + pmu->num_counters_fixed =3D x86_pmu.num_counters_fixed; + pmu->max_pebs_events =3D min_t(unsigned, MAX_PEBS_EVENTS, pmu->num_count= ers); + pmu->unconstrained =3D (struct event_constraint) + __EVENT_CONSTRAINT(0, (1ULL << pmu->num_counters) - 1, + 0, pmu->num_counters, 0, 0); + + pmu->intel_cap.capabilities =3D x86_pmu.intel_cap.capabilities; + if (pmu->pmu_type & hybrid_small) { + pmu->intel_cap.perf_metrics =3D 0; + pmu->intel_cap.pebs_output_pt_available =3D 1; + pmu->mid_ack =3D true; + } else if (pmu->pmu_type & hybrid_big) { + pmu->intel_cap.perf_metrics =3D 1; + pmu->intel_cap.pebs_output_pt_available =3D 0; + pmu->late_ack =3D true; + } + } + + return 0; } =20 static __always_inline void intel_pmu_init_glc(struct pmu *pmu) @@ -6595,23 +6667,14 @@ __init int intel_pmu_init(void) case INTEL_FAM6_RAPTORLAKE: case INTEL_FAM6_RAPTORLAKE_P: case INTEL_FAM6_RAPTORLAKE_S: - case INTEL_FAM6_METEORLAKE: - case INTEL_FAM6_METEORLAKE_L: /* * Alder Lake has 2 types of CPU, core and atom. * * Initialize the common PerfMon capabilities here. */ - x86_pmu.hybrid_pmu =3D kcalloc(X86_HYBRID_NUM_PMUS, - sizeof(struct x86_hybrid_pmu), - GFP_KERNEL); - if (!x86_pmu.hybrid_pmu) - return -ENOMEM; - static_branch_enable(&perf_is_hybrid); - x86_pmu.num_hybrid_pmus =3D X86_HYBRID_NUM_PMUS; + intel_pmu_init_hybrid(hybrid_big_small); =20 x86_pmu.pebs_latency_data =3D adl_latency_data_small; - x86_pmu.filter =3D intel_pmu_filter; x86_pmu.get_event_constraints =3D adl_get_event_constraints; x86_pmu.hw_config =3D adl_hw_config; x86_pmu.get_hybrid_cpu_type =3D adl_get_hybrid_cpu_type; @@ -6624,10 +6687,7 @@ __init int intel_pmu_init(void) =20 /* Initialize big core specific PerfMon capabilities.*/ pmu =3D &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX]; - pmu->name =3D "cpu_core"; - pmu->pmu_type =3D hybrid_big; intel_pmu_init_glc(&pmu->pmu); - pmu->late_ack =3D true; if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) { pmu->num_counters =3D x86_pmu.num_counters + 2; pmu->num_counters_fixed =3D x86_pmu.num_counters_fixed + 1; @@ -6652,45 +6712,45 @@ __init int intel_pmu_init(void) pmu->unconstrained =3D (struct event_constraint) __EVENT_CONSTRAINT(0, (1ULL << pmu->num_counters) - 1, 0, pmu->num_counters, 0, 0); - pmu->intel_cap.capabilities =3D x86_pmu.intel_cap.capabilities; - pmu->intel_cap.perf_metrics =3D 1; - pmu->intel_cap.pebs_output_pt_available =3D 0; - pmu->extra_regs =3D intel_glc_extra_regs; =20 /* Initialize Atom core specific PerfMon capabilities.*/ pmu =3D &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_ATOM_IDX]; - pmu->name =3D "cpu_atom"; - pmu->pmu_type =3D hybrid_small; intel_pmu_init_grt(&pmu->pmu); - pmu->mid_ack =3D true; - pmu->num_counters =3D x86_pmu.num_counters; - pmu->num_counters_fixed =3D x86_pmu.num_counters_fixed; - pmu->max_pebs_events =3D x86_pmu.max_pebs_events; - pmu->unconstrained =3D (struct event_constraint) - __EVENT_CONSTRAINT(0, (1ULL << pmu->num_counters) - 1, - 0, pmu->num_counters, 0, 0); - pmu->intel_cap.capabilities =3D x86_pmu.intel_cap.capabilities; - pmu->intel_cap.perf_metrics =3D 0; - pmu->intel_cap.pebs_output_pt_available =3D 1; - - if (is_mtl(boot_cpu_data.x86_model)) { - x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX].extra_regs =3D intel_rwc_ex= tra_regs; - x86_pmu.pebs_latency_data =3D mtl_latency_data_small; - extra_attr =3D boot_cpu_has(X86_FEATURE_RTM) ? - mtl_hybrid_extra_attr_rtm : mtl_hybrid_extra_attr; - mem_attr =3D mtl_hybrid_mem_attrs; - intel_pmu_pebs_data_source_mtl(); - x86_pmu.get_event_constraints =3D mtl_get_event_constraints; - pmu->extra_regs =3D intel_cmt_extra_regs; - pr_cont("Meteorlake Hybrid events, "); - name =3D "meteorlake_hybrid"; - } else { - x86_pmu.flags |=3D PMU_FL_MEM_LOADS_AUX; - intel_pmu_pebs_data_source_adl(); - pr_cont("Alderlake Hybrid events, "); - name =3D "alderlake_hybrid"; - } + + x86_pmu.flags |=3D PMU_FL_MEM_LOADS_AUX; + intel_pmu_pebs_data_source_adl(); + pr_cont("Alderlake Hybrid events, "); + name =3D "alderlake_hybrid"; + break; + + case INTEL_FAM6_METEORLAKE: + case INTEL_FAM6_METEORLAKE_L: + intel_pmu_init_hybrid(hybrid_big_small); + + x86_pmu.pebs_latency_data =3D mtl_latency_data_small; + x86_pmu.get_event_constraints =3D mtl_get_event_constraints; + x86_pmu.hw_config =3D adl_hw_config; + + td_attr =3D adl_hybrid_events_attrs; + mem_attr =3D mtl_hybrid_mem_attrs; + tsx_attr =3D adl_hybrid_tsx_attrs; + extra_attr =3D boot_cpu_has(X86_FEATURE_RTM) ? + mtl_hybrid_extra_attr_rtm : mtl_hybrid_extra_attr; + + /* Initialize big core specific PerfMon capabilities.*/ + pmu =3D &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX]; + intel_pmu_init_glc(&pmu->pmu); + pmu->extra_regs =3D intel_rwc_extra_regs; + + /* Initialize Atom core specific PerfMon capabilities.*/ + pmu =3D &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_ATOM_IDX]; + intel_pmu_init_grt(&pmu->pmu); + pmu->extra_regs =3D intel_cmt_extra_regs; + + intel_pmu_pebs_data_source_mtl(); + pr_cont("Meteorlake Hybrid events, "); + name =3D "meteorlake_hybrid"; break; =20 default: @@ -6802,7 +6862,7 @@ __init int intel_pmu_init(void) if (!is_hybrid() && x86_pmu.intel_cap.perf_metrics) x86_pmu.intel_ctrl |=3D 1ULL << GLOBAL_CTRL_EN_PERF_METRICS; =20 - if (is_hybrid()) + if (is_hybrid() && !boot_cpu_has(X86_FEATURE_ARCH_PERFMON_EXT)) intel_pmu_check_hybrid_pmus((u64)fixed_mask); =20 if (x86_pmu.intel_cap.pebs_timing_info) --=20 2.35.1