Skip to content

Commit 15a4bd5

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/uncore: Cleanup unused unit structure
The unit control and ID information are retrieved from the unit control RB tree. No one uses the old structure anymore. Remove them. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Yunying Sun <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f76a842 commit 15a4bd5

File tree

4 files changed

+12
-112
lines changed

4 files changed

+12
-112
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ static inline int uncore_get_box_id(struct intel_uncore_type *type,
868868
if (type->boxes)
869869
return intel_uncore_find_discovery_unit_id(type->boxes, -1, pmu->pmu_idx);
870870

871-
return type->box_ids ? type->box_ids[pmu->pmu_idx] : pmu->pmu_idx;
871+
return pmu->pmu_idx;
872872
}
873873

874874
void uncore_get_alias_name(char *pmu_name, struct intel_uncore_pmu *pmu)
@@ -980,10 +980,7 @@ static void uncore_type_exit(struct intel_uncore_type *type)
980980
kfree(type->pmus);
981981
type->pmus = NULL;
982982
}
983-
if (type->box_ids) {
984-
kfree(type->box_ids);
985-
type->box_ids = NULL;
986-
}
983+
987984
kfree(type->events_group);
988985
type->events_group = NULL;
989986
}

arch/x86/events/intel/uncore.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ struct intel_uncore_type {
6262
unsigned fixed_ctr;
6363
unsigned fixed_ctl;
6464
unsigned box_ctl;
65-
u64 *box_ctls; /* Unit ctrl addr of the first box of each die */
6665
union {
6766
unsigned msr_offset;
6867
unsigned mmio_offset;
@@ -76,7 +75,6 @@ struct intel_uncore_type {
7675
u64 *pci_offsets;
7776
u64 *mmio_offsets;
7877
};
79-
unsigned *box_ids;
8078
struct event_constraint unconstrainted;
8179
struct event_constraint *constraints;
8280
struct intel_uncore_pmu *pmus;

arch/x86/events/intel/uncore_discovery.c

Lines changed: 10 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit)
8989
if (!type)
9090
return NULL;
9191

92-
type->box_ctrl_die = kcalloc(__uncore_max_dies, sizeof(u64), GFP_KERNEL);
93-
if (!type->box_ctrl_die)
94-
goto free_type;
95-
9692
type->units = RB_ROOT;
9793

9894
type->access_type = unit->access_type;
@@ -102,12 +98,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit)
10298
rb_add(&type->node, &discovery_tables, __type_less);
10399

104100
return type;
105-
106-
free_type:
107-
kfree(type);
108-
109-
return NULL;
110-
111101
}
112102

113103
static struct intel_uncore_discovery_type *
@@ -230,13 +220,10 @@ void uncore_find_add_unit(struct intel_uncore_discovery_unit *node,
230220

231221
static void
232222
uncore_insert_box_info(struct uncore_unit_discovery *unit,
233-
int die, bool parsed)
223+
int die)
234224
{
235225
struct intel_uncore_discovery_unit *node;
236226
struct intel_uncore_discovery_type *type;
237-
unsigned int *ids;
238-
u64 *box_offset;
239-
int i;
240227

241228
if (!unit->ctl || !unit->ctl_offset || !unit->ctr_offset) {
242229
pr_info("Invalid address is detected for uncore type %d box %d, "
@@ -253,79 +240,21 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit,
253240
node->id = unit->box_id;
254241
node->addr = unit->ctl;
255242

256-
if (parsed) {
257-
type = search_uncore_discovery_type(unit->box_type);
258-
if (!type) {
259-
pr_info("A spurious uncore type %d is detected, "
260-
"Disable the uncore type.\n",
261-
unit->box_type);
262-
kfree(node);
263-
return;
264-
}
265-
266-
uncore_find_add_unit(node, &type->units, &type->num_units);
267-
268-
/* Store the first box of each die */
269-
if (!type->box_ctrl_die[die])
270-
type->box_ctrl_die[die] = unit->ctl;
243+
type = get_uncore_discovery_type(unit);
244+
if (!type) {
245+
kfree(node);
271246
return;
272247
}
273248

274-
type = get_uncore_discovery_type(unit);
275-
if (!type)
276-
goto free_node;
277-
278-
box_offset = kcalloc(type->num_boxes + 1, sizeof(u64), GFP_KERNEL);
279-
if (!box_offset)
280-
goto free_node;
281-
282-
ids = kcalloc(type->num_boxes + 1, sizeof(unsigned int), GFP_KERNEL);
283-
if (!ids)
284-
goto free_box_offset;
285-
286249
uncore_find_add_unit(node, &type->units, &type->num_units);
287250

288251
/* Store generic information for the first box */
289-
if (!type->num_boxes) {
290-
type->box_ctrl = unit->ctl;
291-
type->box_ctrl_die[die] = unit->ctl;
252+
if (type->num_units == 1) {
292253
type->num_counters = unit->num_regs;
293254
type->counter_width = unit->bit_width;
294255
type->ctl_offset = unit->ctl_offset;
295256
type->ctr_offset = unit->ctr_offset;
296-
*ids = unit->box_id;
297-
goto end;
298257
}
299-
300-
for (i = 0; i < type->num_boxes; i++) {
301-
ids[i] = type->ids[i];
302-
box_offset[i] = type->box_offset[i];
303-
304-
if (unit->box_id == ids[i]) {
305-
pr_info("Duplicate uncore type %d box ID %d is detected, "
306-
"Drop the duplicate uncore unit.\n",
307-
unit->box_type, unit->box_id);
308-
goto free_ids;
309-
}
310-
}
311-
ids[i] = unit->box_id;
312-
box_offset[i] = unit->ctl - type->box_ctrl;
313-
kfree(type->ids);
314-
kfree(type->box_offset);
315-
end:
316-
type->ids = ids;
317-
type->box_offset = box_offset;
318-
type->num_boxes++;
319-
return;
320-
321-
free_ids:
322-
kfree(ids);
323-
324-
free_box_offset:
325-
kfree(box_offset);
326-
327-
free_node:
328-
kfree(node);
329258
}
330259

331260
static bool
@@ -404,7 +333,7 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
404333
if (uncore_ignore_unit(&unit, ignore))
405334
continue;
406335

407-
uncore_insert_box_info(&unit, die, *parsed);
336+
uncore_insert_box_info(&unit, die);
408337
}
409338

410339
*parsed = true;
@@ -474,7 +403,6 @@ void intel_uncore_clear_discovery_tables(void)
474403
rb_erase(node, &type->units);
475404
kfree(pos);
476405
}
477-
kfree(type->box_ctrl_die);
478406
kfree(type);
479407
}
480408
}
@@ -738,41 +666,23 @@ static bool uncore_update_uncore_type(enum uncore_access_type type_id,
738666
struct intel_uncore_discovery_type *type)
739667
{
740668
uncore->type_id = type->type;
741-
uncore->num_boxes = type->num_boxes;
742669
uncore->num_counters = type->num_counters;
743670
uncore->perf_ctr_bits = type->counter_width;
744-
uncore->box_ids = type->ids;
671+
uncore->perf_ctr = (unsigned int)type->ctr_offset;
672+
uncore->event_ctl = (unsigned int)type->ctl_offset;
673+
uncore->boxes = &type->units;
674+
uncore->num_boxes = type->num_units;
745675

746676
switch (type_id) {
747677
case UNCORE_ACCESS_MSR:
748678
uncore->ops = &generic_uncore_msr_ops;
749-
uncore->perf_ctr = (unsigned int)type->ctr_offset;
750-
uncore->event_ctl = (unsigned int)type->ctl_offset;
751-
uncore->box_ctl = (unsigned int)type->box_ctrl;
752-
uncore->msr_offsets = type->box_offset;
753-
uncore->boxes = &type->units;
754-
uncore->num_boxes = type->num_units;
755679
break;
756680
case UNCORE_ACCESS_PCI:
757681
uncore->ops = &generic_uncore_pci_ops;
758-
uncore->perf_ctr = (unsigned int)UNCORE_DISCOVERY_PCI_BOX_CTRL(type->box_ctrl) + type->ctr_offset;
759-
uncore->event_ctl = (unsigned int)UNCORE_DISCOVERY_PCI_BOX_CTRL(type->box_ctrl) + type->ctl_offset;
760-
uncore->box_ctl = (unsigned int)UNCORE_DISCOVERY_PCI_BOX_CTRL(type->box_ctrl);
761-
uncore->box_ctls = type->box_ctrl_die;
762-
uncore->pci_offsets = type->box_offset;
763-
uncore->boxes = &type->units;
764-
uncore->num_boxes = type->num_units;
765682
break;
766683
case UNCORE_ACCESS_MMIO:
767684
uncore->ops = &generic_uncore_mmio_ops;
768-
uncore->perf_ctr = (unsigned int)type->ctr_offset;
769-
uncore->event_ctl = (unsigned int)type->ctl_offset;
770-
uncore->box_ctl = (unsigned int)type->box_ctrl;
771-
uncore->box_ctls = type->box_ctrl_die;
772-
uncore->mmio_offsets = type->box_offset;
773685
uncore->mmio_map_size = UNCORE_GENERIC_MMIO_SIZE;
774-
uncore->boxes = &type->units;
775-
uncore->num_boxes = type->num_units;
776686
break;
777687
default:
778688
return false;

arch/x86/events/intel/uncore_discovery.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,13 @@ struct intel_uncore_discovery_unit {
124124
struct intel_uncore_discovery_type {
125125
struct rb_node node;
126126
enum uncore_access_type access_type;
127-
u64 box_ctrl; /* Unit ctrl addr of the first box */
128-
u64 *box_ctrl_die; /* Unit ctrl addr of the first box of each die */
129127
struct rb_root units; /* Unit ctrl addr for all units */
130128
u16 type; /* Type ID of the uncore block */
131129
u8 num_counters;
132130
u8 counter_width;
133131
u8 ctl_offset; /* Counter Control 0 offset */
134132
u8 ctr_offset; /* Counter 0 offset */
135-
u16 num_boxes; /* number of boxes for the uncore block */
136133
u16 num_units; /* number of units */
137-
unsigned int *ids; /* Box IDs */
138-
u64 *box_offset; /* Box offset */
139134
};
140135

141136
bool intel_uncore_has_discovery_tables(int *ignore);

0 commit comments

Comments
 (0)