@@ -217,7 +217,8 @@ u64 uncore_shared_reg_config(struct intel_uncore_box *box, int idx)
217
217
return config ;
218
218
}
219
219
220
- static void uncore_assign_hw_event (struct intel_uncore_box * box , struct perf_event * event , int idx )
220
+ static void uncore_assign_hw_event (struct intel_uncore_box * box ,
221
+ struct perf_event * event , int idx )
221
222
{
222
223
struct hw_perf_event * hwc = & event -> hw ;
223
224
@@ -312,18 +313,19 @@ static void uncore_pmu_init_hrtimer(struct intel_uncore_box *box)
312
313
box -> hrtimer .function = uncore_pmu_hrtimer ;
313
314
}
314
315
315
- static struct intel_uncore_box * uncore_alloc_box (struct intel_uncore_type * type , int node )
316
+ static struct intel_uncore_box * uncore_alloc_box (struct intel_uncore_type * type ,
317
+ int node )
316
318
{
319
+ int i , size , numshared = type -> num_shared_regs ;
317
320
struct intel_uncore_box * box ;
318
- int i , size ;
319
321
320
- size = sizeof (* box ) + type -> num_shared_regs * sizeof (struct intel_uncore_extra_reg );
322
+ size = sizeof (* box ) + numshared * sizeof (struct intel_uncore_extra_reg );
321
323
322
324
box = kzalloc_node (size , GFP_KERNEL , node );
323
325
if (!box )
324
326
return NULL ;
325
327
326
- for (i = 0 ; i < type -> num_shared_regs ; i ++ )
328
+ for (i = 0 ; i < numshared ; i ++ )
327
329
raw_spin_lock_init (& box -> shared_regs [i ].lock );
328
330
329
331
uncore_pmu_init_hrtimer (box );
@@ -351,7 +353,8 @@ static bool is_uncore_event(struct perf_event *event)
351
353
}
352
354
353
355
static int
354
- uncore_collect_events (struct intel_uncore_box * box , struct perf_event * leader , bool dogrp )
356
+ uncore_collect_events (struct intel_uncore_box * box , struct perf_event * leader ,
357
+ bool dogrp )
355
358
{
356
359
struct perf_event * event ;
357
360
int n , max_count ;
@@ -412,7 +415,8 @@ uncore_get_event_constraint(struct intel_uncore_box *box, struct perf_event *eve
412
415
return & type -> unconstrainted ;
413
416
}
414
417
415
- static void uncore_put_event_constraint (struct intel_uncore_box * box , struct perf_event * event )
418
+ static void uncore_put_event_constraint (struct intel_uncore_box * box ,
419
+ struct perf_event * event )
416
420
{
417
421
if (box -> pmu -> type -> ops -> put_constraint )
418
422
box -> pmu -> type -> ops -> put_constraint (box , event );
@@ -592,7 +596,7 @@ static void uncore_pmu_event_del(struct perf_event *event, int flags)
592
596
if (event == box -> event_list [i ]) {
593
597
uncore_put_event_constraint (box , event );
594
598
595
- while (++ i < box -> n_events )
599
+ for (++ i ; i < box -> n_events ; i ++ )
596
600
box -> event_list [i - 1 ] = box -> event_list [i ];
597
601
598
602
-- box -> n_events ;
@@ -801,10 +805,8 @@ static void __init uncore_type_exit(struct intel_uncore_type *type)
801
805
802
806
static void __init uncore_types_exit (struct intel_uncore_type * * types )
803
807
{
804
- int i ;
805
-
806
- for (i = 0 ; types [i ]; i ++ )
807
- uncore_type_exit (types [i ]);
808
+ for (; * types ; types ++ )
809
+ uncore_type_exit (* types );
808
810
}
809
811
810
812
static int __init uncore_type_init (struct intel_uncore_type * type )
@@ -908,9 +910,11 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
908
910
* some device types. Hence PCI device idx would be 0 for all devices.
909
911
* So increment pmu pointer to point to an unused array element.
910
912
*/
911
- if (boot_cpu_data .x86_model == 87 )
913
+ if (boot_cpu_data .x86_model == 87 ) {
912
914
while (pmu -> func_id >= 0 )
913
915
pmu ++ ;
916
+ }
917
+
914
918
if (pmu -> func_id < 0 )
915
919
pmu -> func_id = pdev -> devfn ;
916
920
else
@@ -1170,44 +1174,45 @@ static int uncore_cpu_prepare(int cpu, int phys_id)
1170
1174
return 0 ;
1171
1175
}
1172
1176
1173
- static void
1174
- uncore_change_context ( struct intel_uncore_type * * uncores , int old_cpu , int new_cpu )
1177
+ static void uncore_change_type_ctx ( struct intel_uncore_type * type , int old_cpu ,
1178
+ int new_cpu )
1175
1179
{
1176
- struct intel_uncore_type * type ;
1177
- struct intel_uncore_pmu * pmu ;
1180
+ struct intel_uncore_pmu * pmu = type -> pmus ;
1178
1181
struct intel_uncore_box * box ;
1179
- int i , j ;
1180
-
1181
- for (i = 0 ; uncores [i ]; i ++ ) {
1182
- type = uncores [i ];
1183
- for (j = 0 ; j < type -> num_boxes ; j ++ ) {
1184
- pmu = & type -> pmus [j ];
1185
- if (old_cpu < 0 )
1186
- box = uncore_pmu_to_box (pmu , new_cpu );
1187
- else
1188
- box = uncore_pmu_to_box (pmu , old_cpu );
1189
- if (!box )
1190
- continue ;
1182
+ int i ;
1191
1183
1192
- if (old_cpu < 0 ) {
1193
- WARN_ON_ONCE (box -> cpu != -1 );
1194
- box -> cpu = new_cpu ;
1195
- continue ;
1196
- }
1184
+ for (i = 0 ; i < type -> num_boxes ; i ++ , pmu ++ ) {
1185
+ if (old_cpu < 0 )
1186
+ box = uncore_pmu_to_box (pmu , new_cpu );
1187
+ else
1188
+ box = uncore_pmu_to_box (pmu , old_cpu );
1189
+ if (!box )
1190
+ continue ;
1197
1191
1198
- WARN_ON_ONCE (box -> cpu != old_cpu );
1199
- if (new_cpu >= 0 ) {
1200
- uncore_pmu_cancel_hrtimer (box );
1201
- perf_pmu_migrate_context (& pmu -> pmu ,
1202
- old_cpu , new_cpu );
1203
- box -> cpu = new_cpu ;
1204
- } else {
1205
- box -> cpu = -1 ;
1206
- }
1192
+ if (old_cpu < 0 ) {
1193
+ WARN_ON_ONCE (box -> cpu != -1 );
1194
+ box -> cpu = new_cpu ;
1195
+ continue ;
1207
1196
}
1197
+
1198
+ WARN_ON_ONCE (box -> cpu != old_cpu );
1199
+ box -> cpu = -1 ;
1200
+ if (new_cpu < 0 )
1201
+ continue ;
1202
+
1203
+ uncore_pmu_cancel_hrtimer (box );
1204
+ perf_pmu_migrate_context (& pmu -> pmu , old_cpu , new_cpu );
1205
+ box -> cpu = new_cpu ;
1208
1206
}
1209
1207
}
1210
1208
1209
+ static void uncore_change_context (struct intel_uncore_type * * uncores ,
1210
+ int old_cpu , int new_cpu )
1211
+ {
1212
+ for (; * uncores ; uncores ++ )
1213
+ uncore_change_type_ctx (* uncores , old_cpu , new_cpu );
1214
+ }
1215
+
1211
1216
static void uncore_event_exit_cpu (int cpu )
1212
1217
{
1213
1218
int i , phys_id , target ;
@@ -1318,8 +1323,8 @@ static int __init uncore_msr_pmus_register(void)
1318
1323
struct intel_uncore_type * * types = uncore_msr_uncores ;
1319
1324
int ret ;
1320
1325
1321
- while ( * types ) {
1322
- ret = type_pmu_register (* types ++ );
1326
+ for (; * types ; types ++ ) {
1327
+ ret = type_pmu_register (* types );
1323
1328
if (ret )
1324
1329
return ret ;
1325
1330
}
0 commit comments