@@ -1223,10 +1223,10 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb
1223
1223
u32 low , high ;
1224
1224
int err ;
1225
1225
1226
- if ((bank >= per_cpu (mce_num_banks , cpu )) || (block >= NR_BLOCKS ))
1226
+ if ((bank >= this_cpu_read (mce_num_banks )) || (block >= NR_BLOCKS ))
1227
1227
return 0 ;
1228
1228
1229
- if (rdmsr_safe_on_cpu ( cpu , address , & low , & high ))
1229
+ if (rdmsr_safe ( address , & low , & high ))
1230
1230
return 0 ;
1231
1231
1232
1232
if (!(high & MASK_VALID_HI )) {
@@ -1316,9 +1316,10 @@ static int __threshold_add_blocks(struct threshold_bank *b)
1316
1316
return err ;
1317
1317
}
1318
1318
1319
- static int threshold_create_bank (unsigned int cpu , unsigned int bank )
1319
+ static int threshold_create_bank (struct threshold_bank * * bp , unsigned int cpu ,
1320
+ unsigned int bank )
1320
1321
{
1321
- struct device * dev = per_cpu (mce_device , cpu );
1322
+ struct device * dev = this_cpu_read (mce_device );
1322
1323
struct amd_northbridge * nb = NULL ;
1323
1324
struct threshold_bank * b = NULL ;
1324
1325
const char * name = get_name (bank , NULL );
@@ -1338,7 +1339,7 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank)
1338
1339
if (err )
1339
1340
goto out ;
1340
1341
1341
- per_cpu ( threshold_banks , cpu ) [bank ] = b ;
1342
+ bp [bank ] = b ;
1342
1343
refcount_inc (& b -> cpus );
1343
1344
1344
1345
err = __threshold_add_blocks (b );
@@ -1374,8 +1375,7 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank)
1374
1375
if (err )
1375
1376
goto out_kobj ;
1376
1377
1377
- per_cpu (threshold_banks , cpu )[bank ] = b ;
1378
-
1378
+ bp [bank ] = b ;
1379
1379
return 0 ;
1380
1380
1381
1381
out_kobj :
@@ -1487,35 +1487,33 @@ int mce_threshold_remove_device(unsigned int cpu)
1487
1487
*/
1488
1488
int mce_threshold_create_device (unsigned int cpu )
1489
1489
{
1490
- unsigned int bank ;
1490
+ unsigned int numbanks , bank ;
1491
1491
struct threshold_bank * * bp ;
1492
1492
int err ;
1493
1493
1494
1494
if (!mce_flags .amd_threshold )
1495
1495
return 0 ;
1496
1496
1497
- bp = per_cpu (threshold_banks , cpu );
1497
+ bp = this_cpu_read (threshold_banks );
1498
1498
if (bp )
1499
1499
return 0 ;
1500
1500
1501
- bp = kcalloc ( per_cpu ( mce_num_banks , cpu ), sizeof ( struct threshold_bank * ),
1502
- GFP_KERNEL );
1501
+ numbanks = this_cpu_read ( mce_num_banks );
1502
+ bp = kcalloc ( numbanks , sizeof ( * bp ), GFP_KERNEL );
1503
1503
if (!bp )
1504
1504
return - ENOMEM ;
1505
1505
1506
- per_cpu (threshold_banks , cpu ) = bp ;
1507
-
1508
- for (bank = 0 ; bank < per_cpu (mce_num_banks , cpu ); ++ bank ) {
1509
- if (!(per_cpu (bank_map , cpu ) & (1 << bank )))
1506
+ for (bank = 0 ; bank < numbanks ; ++ bank ) {
1507
+ if (!(this_cpu_read (bank_map ) & (1 << bank )))
1510
1508
continue ;
1511
- err = threshold_create_bank (cpu , bank );
1509
+ err = threshold_create_bank (bp , cpu , bank );
1512
1510
if (err )
1513
1511
goto out_err ;
1514
1512
}
1513
+ this_cpu_write (threshold_banks , bp );
1515
1514
1516
1515
if (thresholding_irq_en )
1517
1516
mce_threshold_vector = amd_threshold_interrupt ;
1518
-
1519
1517
return 0 ;
1520
1518
out_err :
1521
1519
mce_threshold_remove_device (cpu );
0 commit comments