perf/x86/intel/uncore: Clean up func_id
Subsystems (2)
PATCH 1/2 perf/x86/intel/uncore: Clean up func_id
From: Kan Liang <[email protected]>
The below warning may be triggered on GNR when the PCIE uncore units are exposed.
WARNING: CPU: 4 PID: 1 at arch/x86/events/intel/uncore.c:1169 uncore_pci_pmu_register+0x158/0x190
The current uncore driver assumes that all the devices in the same PMU have the exact same devfn. It's true for the previous platforms. But it doesn't work for the new PCIE uncore units on GNR.
The assumption doesn't make sense. There is no reason to limit the devices from the same PMU to the same devfn. Also, the current code just throws the warning, but still registers the device. The WARN_ON_ONCE() should be removed.
The func_id is used by the later event_init() to check if a event->pmu has valid devices. For cpu and mmio uncore PMUs, they are always valid. For pci uncore PMUs, it's set when the PMU is registered. It can be replaced by the pmu->registered. Clean up the func_id.
--- arch/x86/events/intel/uncore.c | 20 +++++++------------- arch/x86/events/intel/uncore.h | 1 - arch/x86/events/intel/uncore_snb.c | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-)
arch/x86/events/intel/uncore.c +7 -13
@@ -745,7 +745,7 @@ static int uncore_pmu_event_init(struct perf_event *event) pmu =uncore_event_to_pmu (event);/* no device found for this pmu */ -if (pmu->func_id <0 ) +if (!pmu->registered)return -ENOENT ;/* Sampling not supported yet */
@@ -992,7 +992,7 @@ static void uncore_types_exit(struct intel_uncore_type **types)uncore_type_exit (*types); } -static int __init uncore_type_init (struct intel_uncore_type *type,bool setid) +static int __init uncore_type_init (struct intel_uncore_type *type) {struct intel_uncore_pmu *pmus;size_t size;
@@ -1005,7 +1005,6 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) size =uncore_max_dies () *sizeof (struct intel_uncore_box *);for (i =0 ; i < type->num_boxes; i++) { - pmus[i].func_id = setid ? i :-1 ; pmus[i].pmu_idx = i; pmus[i].type = type; pmus[i].boxes =kzalloc (size,GFP_KERNEL );
@@ -1055,12 +1054,12 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) }static int __init -uncore_types_init (struct intel_uncore_type **types,bool setid) +uncore_types_init (struct intel_uncore_type **types) {int ret;for (; *types; types++) { - ret =uncore_type_init (*types, setid); + ret =uncore_type_init (*types);if (ret)return ret; }
@@ -1160,11 +1159,6 @@ static int uncore_pci_pmu_register(struct pci_dev *pdev,if (!box)return -ENOMEM ; -if (pmu->func_id <0 ) - pmu->func_id = pdev->devfn; -else -WARN_ON_ONCE (pmu->func_id != pdev->devfn); -atomic_inc (&box->refcnt); box->dieid = die; box->pci_dev = pdev;
@@ -1410,7 +1404,7 @@ static int __init uncore_pci_init(void) goto err; } - ret =uncore_types_init (uncore_pci_uncores, false); + ret =uncore_types_init (uncore_pci_uncores);if (ret) goto errtype;
@@ -1678,7 +1672,7 @@ static int __init uncore_cpu_init(void) {int ret; - ret =uncore_types_init (uncore_msr_uncores, true); + ret =uncore_types_init (uncore_msr_uncores);if (ret) goto err;
@@ -1697,7 +1691,7 @@ static int __init uncore_mmio_init(void)struct intel_uncore_type **types = uncore_mmio_uncores;int ret; - ret =uncore_types_init (types, true); + ret =uncore_types_init (types);if (ret) goto err;
arch/x86/events/intel/uncore.h +0 -1
@@ -125,7 +125,6 @@ struct intel_uncore_pmu {struct pmu pmu;char name[UNCORE_PMU_NAME_LEN ];int pmu_idx; -int func_id;bool registered;atomic_t activeboxes;cpumask_t cpu_mask;
arch/x86/events/intel/uncore_snb.c +1 -1
@@ -910,7 +910,7 @@ static int snb_uncore_imc_event_init(struct perf_event *event) pmu =uncore_event_to_pmu (event);/* no device found for this pmu */ -if (pmu->func_id <0 ) +if (!pmu->registered)return -ENOENT ;/* Sampling not supported yet */
Signature · 1 line
2.38.1
PATCH 2/2 perf/x86/intel/uncore: Support more units on Granite Rapids
From: Kan Liang <[email protected]>
The same CXL PMONs support is also avaiable on GNR. Apply spr_uncore_cxlcm and spr_uncore_cxldp to GNR as well.
The other units were broken on early HW samples, so they were ignored in the early enabling patch. The issue has been fixed and verified on the later production HW. Add UPI, B2UPI, B2HOT, PCIEX16 and PCIEX8 for GNR.
--- arch/x86/events/intel/uncore_snbep.c | 48 ++++++++++++++++++---------- 1 file changed, 32 insertions(+), 16 deletions(-)
arch/x86/events/intel/uncore_snbep.c +32 -16
@@ -6684,17 +6684,8 @@ void spr_uncore_mmio_init(void)/* GNR uncore support */ #define UNCORE_GNR_NUM_UNCORE_TYPES 23 -#define UNCORE_GNR_TYPE_15 15 -#define UNCORE_GNR_B2UPI 18 -#define UNCORE_GNR_TYPE_21 21 -#define UNCORE_GNR_TYPE_22 22int gnr_uncore_units_ignore[] = { -UNCORE_SPR_UPI , -UNCORE_GNR_TYPE_15 , -UNCORE_GNR_B2UPI , -UNCORE_GNR_TYPE_21 , -UNCORE_GNR_TYPE_22 ,UNCORE_IGNORE_END };
@@ -6703,6 +6694,31 @@ static struct intel_uncore_type gnr_uncore_ubox = { .attr_update = uncore_alias_groups, }; +static struct intel_uncore_type gnr_uncore_pciex8 = { +SPR_UNCORE_PCI_COMMON_FORMAT (), + .name ="pciex8" , +}; + +static struct intel_uncore_type gnr_uncore_pciex16 = { +SPR_UNCORE_PCI_COMMON_FORMAT (), + .name ="pciex16" , +}; + +static struct intel_uncore_type gnr_uncore_upi = { +SPR_UNCORE_PCI_COMMON_FORMAT (), + .name ="upi" , +}; + +static struct intel_uncore_type gnr_uncore_b2upi = { +SPR_UNCORE_PCI_COMMON_FORMAT (), + .name ="b2upi" , +}; + +static struct intel_uncore_type gnr_uncore_b2hot = { + .name ="b2hot" , + .attr_update = uncore_alias_groups, +}; +static struct intel_uncore_type gnr_uncore_b2cmi = {SPR_UNCORE_PCI_COMMON_FORMAT (), .name ="b2cmi" ,
@@ -6727,21 +6743,21 @@ static struct intel_uncore_type *gnr_uncores[UNCORE_GNR_NUM_UNCORE_TYPES] = { &gnr_uncore_ubox, &spr_uncore_imc,NULL , + &gnr_uncore_upi,NULL ,NULL ,NULL , + &spr_uncore_cxlcm, + &spr_uncore_cxldp,NULL , -NULL , -NULL , -NULL , -NULL , + &gnr_uncore_b2hot, &gnr_uncore_b2cmi, &gnr_uncore_b2cxl, -NULL , + &gnr_uncore_b2upi,NULL , &gnr_uncore_mdf_sbo, -NULL , - NULL, + &gnr_uncore_pciex16, + &gnr_uncore_pciex8, }; static struct freerunning_counters gnr_iio_freerunning[] = {
Signature · 1 line
2.38.1
[tip: perf/core] perf/x86/intel/uncore: Support more units on Granite Rapids
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 6d642735cdb6cdb814d2b6c81652caa53ce04842 Gitweb: https://git.kernel.org/tip/6d642735cdb6cdb814d2b6c81652caa53ce04842 Author: Kan Liang <[email protected]> AuthorDate: Wed, 08 Jan 2025 06:30:17 -08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 10 Jan 2025 18:16:50 +01:00
perf/x86/intel/uncore: Support more units on Granite Rapids
The same CXL PMONs support is also avaiable on GNR. Apply spr_uncore_cxlcm and spr_uncore_cxldp to GNR as well.
The other units were broken on early HW samples, so they were ignored in the early enabling patch. The issue has been fixed and verified on the later production HW. Add UPI, B2UPI, B2HOT, PCIEX16 and PCIEX8 for GNR.
--- arch/x86/events/intel/uncore_snbep.c | 48 ++++++++++++++++++--------- 1 file changed, 32 insertions(+), 16 deletions(-)
arch/x86/events/intel/uncore_snbep.c +32 -16
@@ -6684,17 +6684,8 @@ void spr_uncore_mmio_init(void)/* GNR uncore support */ #define UNCORE_GNR_NUM_UNCORE_TYPES 23 -#define UNCORE_GNR_TYPE_15 15 -#define UNCORE_GNR_B2UPI 18 -#define UNCORE_GNR_TYPE_21 21 -#define UNCORE_GNR_TYPE_22 22int gnr_uncore_units_ignore[] = { -UNCORE_SPR_UPI , -UNCORE_GNR_TYPE_15 , -UNCORE_GNR_B2UPI , -UNCORE_GNR_TYPE_21 , -UNCORE_GNR_TYPE_22 ,UNCORE_IGNORE_END };
@@ -6703,6 +6694,31 @@ static struct intel_uncore_type gnr_uncore_ubox = { .attr_update = uncore_alias_groups, }; +static struct intel_uncore_type gnr_uncore_pciex8 = { +SPR_UNCORE_PCI_COMMON_FORMAT (), + .name ="pciex8" , +}; + +static struct intel_uncore_type gnr_uncore_pciex16 = { +SPR_UNCORE_PCI_COMMON_FORMAT (), + .name ="pciex16" , +}; + +static struct intel_uncore_type gnr_uncore_upi = { +SPR_UNCORE_PCI_COMMON_FORMAT (), + .name ="upi" , +}; + +static struct intel_uncore_type gnr_uncore_b2upi = { +SPR_UNCORE_PCI_COMMON_FORMAT (), + .name ="b2upi" , +}; + +static struct intel_uncore_type gnr_uncore_b2hot = { + .name ="b2hot" , + .attr_update = uncore_alias_groups, +}; +static struct intel_uncore_type gnr_uncore_b2cmi = {SPR_UNCORE_PCI_COMMON_FORMAT (), .name ="b2cmi" ,
@@ -6727,21 +6743,21 @@ static struct intel_uncore_type *gnr_uncores[UNCORE_GNR_NUM_UNCORE_TYPES] = { &gnr_uncore_ubox, &spr_uncore_imc,NULL , + &gnr_uncore_upi,NULL ,NULL ,NULL , + &spr_uncore_cxlcm, + &spr_uncore_cxldp,NULL , -NULL , -NULL , -NULL , -NULL , + &gnr_uncore_b2hot, &gnr_uncore_b2cmi, &gnr_uncore_b2cxl, -NULL , + &gnr_uncore_b2upi,NULL , &gnr_uncore_mdf_sbo, -NULL , - NULL, + &gnr_uncore_pciex16, + &gnr_uncore_pciex8, }; static struct freerunning_counters gnr_iio_freerunning[] = {
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 3f710be02ea648001ba18fb2c9fa7765e743dec2 Gitweb: https://git.kernel.org/tip/3f710be02ea648001ba18fb2c9fa7765e743dec2 Author: Kan Liang <[email protected]> AuthorDate: Wed, 08 Jan 2025 06:30:16 -08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 10 Jan 2025 18:16:50 +01:00
perf/x86/intel/uncore: Clean up func_id
The below warning may be triggered on GNR when the PCIE uncore units are exposed.
WARNING: CPU: 4 PID: 1 at arch/x86/events/intel/uncore.c:1169 uncore_pci_pmu_register+0x158/0x190
The current uncore driver assumes that all the devices in the same PMU have the exact same devfn. It's true for the previous platforms. But it doesn't work for the new PCIE uncore units on GNR.
The assumption doesn't make sense. There is no reason to limit the devices from the same PMU to the same devfn. Also, the current code just throws the warning, but still registers the device. The WARN_ON_ONCE() should be removed.
The func_id is used by the later event_init() to check if a event->pmu has valid devices. For cpu and mmio uncore PMUs, they are always valid. For pci uncore PMUs, it's set when the PMU is registered. It can be replaced by the pmu->registered. Clean up the func_id.
--- arch/x86/events/intel/uncore.c | 20 +++++++------------- arch/x86/events/intel/uncore.h | 1 - arch/x86/events/intel/uncore_snb.c | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-)
arch/x86/events/intel/uncore.c +7 -13
@@ -745,7 +745,7 @@ static int uncore_pmu_event_init(struct perf_event *event) pmu =uncore_event_to_pmu (event);/* no device found for this pmu */ -if (pmu->func_id <0 ) +if (!pmu->registered)return -ENOENT ;/* Sampling not supported yet */
@@ -992,7 +992,7 @@ static void uncore_types_exit(struct intel_uncore_type **types)uncore_type_exit (*types); } -static int __init uncore_type_init (struct intel_uncore_type *type,bool setid) +static int __init uncore_type_init (struct intel_uncore_type *type) {struct intel_uncore_pmu *pmus;size_t size;
@@ -1005,7 +1005,6 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) size =uncore_max_dies () *sizeof (struct intel_uncore_box *);for (i =0 ; i < type->num_boxes; i++) { - pmus[i].func_id = setid ? i :-1 ; pmus[i].pmu_idx = i; pmus[i].type = type; pmus[i].boxes =kzalloc (size,GFP_KERNEL );
@@ -1055,12 +1054,12 @@ err: }static int __init -uncore_types_init (struct intel_uncore_type **types,bool setid) +uncore_types_init (struct intel_uncore_type **types) {int ret;for (; *types; types++) { - ret =uncore_type_init (*types, setid); + ret =uncore_type_init (*types);if (ret)return ret; }
@@ -1160,11 +1159,6 @@ static int uncore_pci_pmu_register(struct pci_dev *pdev,if (!box)return -ENOMEM ; -if (pmu->func_id <0 ) - pmu->func_id = pdev->devfn; -else -WARN_ON_ONCE (pmu->func_id != pdev->devfn); -atomic_inc (&box->refcnt); box->dieid = die; box->pci_dev = pdev;
@@ -1410,7 +1404,7 @@ static int __init uncore_pci_init(void) goto err; } - ret =uncore_types_init (uncore_pci_uncores, false); + ret =uncore_types_init (uncore_pci_uncores);if (ret) goto errtype;
@@ -1678,7 +1672,7 @@ static int __init uncore_cpu_init(void) {int ret; - ret =uncore_types_init (uncore_msr_uncores, true); + ret =uncore_types_init (uncore_msr_uncores);if (ret) goto err;
@@ -1697,7 +1691,7 @@ static int __init uncore_mmio_init(void)struct intel_uncore_type **types = uncore_mmio_uncores;int ret; - ret =uncore_types_init (types, true); + ret =uncore_types_init (types);if (ret) goto err;
arch/x86/events/intel/uncore.h +0 -1
@@ -125,7 +125,6 @@ struct intel_uncore_pmu {struct pmu pmu;char name[UNCORE_PMU_NAME_LEN ];int pmu_idx; -int func_id;bool registered;atomic_t activeboxes;cpumask_t cpu_mask;
arch/x86/events/intel/uncore_snb.c +1 -1
@@ -910,7 +910,7 @@ static int snb_uncore_imc_event_init(struct perf_event *event) pmu =uncore_event_to_pmu (event);/* no device found for this pmu */ -if (pmu->func_id <0 ) +if (!pmu->registered)return -ENOENT ;/* Sampling not supported yet */