Skip to content

Commit 3f710be

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
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. Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Eric Hu <eric.hu@intel.com> Link: https://lkml.kernel.org/r/20250108143017.1793781-1-kan.liang@linux.intel.com
1 parent 0e45818 commit 3f710be

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ static int uncore_pmu_event_init(struct perf_event *event)
745745

746746
pmu = uncore_event_to_pmu(event);
747747
/* no device found for this pmu */
748-
if (pmu->func_id < 0)
748+
if (!pmu->registered)
749749
return -ENOENT;
750750

751751
/* Sampling not supported yet */
@@ -992,7 +992,7 @@ static void uncore_types_exit(struct intel_uncore_type **types)
992992
uncore_type_exit(*types);
993993
}
994994

995-
static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
995+
static int __init uncore_type_init(struct intel_uncore_type *type)
996996
{
997997
struct intel_uncore_pmu *pmus;
998998
size_t size;
@@ -1005,7 +1005,6 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
10051005
size = uncore_max_dies() * sizeof(struct intel_uncore_box *);
10061006

10071007
for (i = 0; i < type->num_boxes; i++) {
1008-
pmus[i].func_id = setid ? i : -1;
10091008
pmus[i].pmu_idx = i;
10101009
pmus[i].type = type;
10111010
pmus[i].boxes = kzalloc(size, GFP_KERNEL);
@@ -1055,12 +1054,12 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
10551054
}
10561055

10571056
static int __init
1058-
uncore_types_init(struct intel_uncore_type **types, bool setid)
1057+
uncore_types_init(struct intel_uncore_type **types)
10591058
{
10601059
int ret;
10611060

10621061
for (; *types; types++) {
1063-
ret = uncore_type_init(*types, setid);
1062+
ret = uncore_type_init(*types);
10641063
if (ret)
10651064
return ret;
10661065
}
@@ -1160,11 +1159,6 @@ static int uncore_pci_pmu_register(struct pci_dev *pdev,
11601159
if (!box)
11611160
return -ENOMEM;
11621161

1163-
if (pmu->func_id < 0)
1164-
pmu->func_id = pdev->devfn;
1165-
else
1166-
WARN_ON_ONCE(pmu->func_id != pdev->devfn);
1167-
11681162
atomic_inc(&box->refcnt);
11691163
box->dieid = die;
11701164
box->pci_dev = pdev;
@@ -1410,7 +1404,7 @@ static int __init uncore_pci_init(void)
14101404
goto err;
14111405
}
14121406

1413-
ret = uncore_types_init(uncore_pci_uncores, false);
1407+
ret = uncore_types_init(uncore_pci_uncores);
14141408
if (ret)
14151409
goto errtype;
14161410

@@ -1678,7 +1672,7 @@ static int __init uncore_cpu_init(void)
16781672
{
16791673
int ret;
16801674

1681-
ret = uncore_types_init(uncore_msr_uncores, true);
1675+
ret = uncore_types_init(uncore_msr_uncores);
16821676
if (ret)
16831677
goto err;
16841678

@@ -1697,7 +1691,7 @@ static int __init uncore_mmio_init(void)
16971691
struct intel_uncore_type **types = uncore_mmio_uncores;
16981692
int ret;
16991693

1700-
ret = uncore_types_init(types, true);
1694+
ret = uncore_types_init(types);
17011695
if (ret)
17021696
goto err;
17031697

arch/x86/events/intel/uncore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ struct intel_uncore_pmu {
125125
struct pmu pmu;
126126
char name[UNCORE_PMU_NAME_LEN];
127127
int pmu_idx;
128-
int func_id;
129128
bool registered;
130129
atomic_t activeboxes;
131130
cpumask_t cpu_mask;

arch/x86/events/intel/uncore_snb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ static int snb_uncore_imc_event_init(struct perf_event *event)
910910

911911
pmu = uncore_event_to_pmu(event);
912912
/* no device found for this pmu */
913-
if (pmu->func_id < 0)
913+
if (!pmu->registered)
914914
return -ENOENT;
915915

916916
/* Sampling not supported yet */

0 commit comments

Comments
 (0)