Skip to content

Commit 36b533b

Browse files
Roman SudarikovPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Wrap the max dies calculation into an accessor
The accessor to return number of dies on the platform. Signed-off-by: Alexander Antonov <[email protected]> Signed-off-by: Roman Sudarikov <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Kan Liang <[email protected]> Reviewed-by: Alexander Shishkin <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 19a3981 commit 36b533b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct pci_driver *uncore_pci_driver;
1616
DEFINE_RAW_SPINLOCK(pci2phy_map_lock);
1717
struct list_head pci2phy_map_head = LIST_HEAD_INIT(pci2phy_map_head);
1818
struct pci_extra_dev *uncore_extra_pci_dev;
19-
static int max_dies;
19+
int __uncore_max_dies;
2020

2121
/* mask of cpus that collect uncore events */
2222
static cpumask_t uncore_cpu_mask;
@@ -108,7 +108,7 @@ struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu
108108
* The unsigned check also catches the '-1' return value for non
109109
* existent mappings in the topology map.
110110
*/
111-
return dieid < max_dies ? pmu->boxes[dieid] : NULL;
111+
return dieid < uncore_max_dies() ? pmu->boxes[dieid] : NULL;
112112
}
113113

114114
u64 uncore_msr_read_counter(struct intel_uncore_box *box, struct perf_event *event)
@@ -882,7 +882,7 @@ static void uncore_free_boxes(struct intel_uncore_pmu *pmu)
882882
{
883883
int die;
884884

885-
for (die = 0; die < max_dies; die++)
885+
for (die = 0; die < uncore_max_dies(); die++)
886886
kfree(pmu->boxes[die]);
887887
kfree(pmu->boxes);
888888
}
@@ -923,7 +923,7 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
923923
if (!pmus)
924924
return -ENOMEM;
925925

926-
size = max_dies * sizeof(struct intel_uncore_box *);
926+
size = uncore_max_dies() * sizeof(struct intel_uncore_box *);
927927

928928
for (i = 0; i < type->num_boxes; i++) {
929929
pmus[i].func_id = setid ? i : -1;
@@ -1123,7 +1123,7 @@ static int __init uncore_pci_init(void)
11231123
size_t size;
11241124
int ret;
11251125

1126-
size = max_dies * sizeof(struct pci_extra_dev);
1126+
size = uncore_max_dies() * sizeof(struct pci_extra_dev);
11271127
uncore_extra_pci_dev = kzalloc(size, GFP_KERNEL);
11281128
if (!uncore_extra_pci_dev) {
11291129
ret = -ENOMEM;
@@ -1552,7 +1552,8 @@ static int __init intel_uncore_init(void)
15521552
if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
15531553
return -ENODEV;
15541554

1555-
max_dies = topology_max_packages() * topology_max_die_per_package();
1555+
__uncore_max_dies =
1556+
topology_max_packages() * topology_max_die_per_package();
15561557

15571558
uncore_init = (struct intel_uncore_init_fun *)id->driver_data;
15581559
if (uncore_init->pci_init) {

arch/x86/events/intel/uncore.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ int uncore_pcibus_to_physid(struct pci_bus *bus);
182182
ssize_t uncore_event_show(struct kobject *kobj,
183183
struct kobj_attribute *attr, char *buf);
184184

185+
extern int __uncore_max_dies;
186+
#define uncore_max_dies() (__uncore_max_dies)
187+
185188
#define INTEL_UNCORE_EVENT_DESC(_name, _config) \
186189
{ \
187190
.attr = __ATTR(_name, 0444, uncore_event_show, NULL), \

0 commit comments

Comments
 (0)