@@ -225,6 +225,9 @@ struct global_params {
225
225
* @vid: Stores VID limits for this CPU
226
226
* @pid: Stores PID parameters for this CPU
227
227
* @last_sample_time: Last Sample time
228
+ * @aperf_mperf_shift: Number of clock cycles after aperf, merf is incremented
229
+ * This shift is a multiplier to mperf delta to
230
+ * calculate CPU busy.
228
231
* @prev_aperf: Last APERF value read from APERF MSR
229
232
* @prev_mperf: Last MPERF value read from MPERF MSR
230
233
* @prev_tsc: Last timestamp counter (TSC) value
@@ -259,6 +262,7 @@ struct cpudata {
259
262
260
263
u64 last_update ;
261
264
u64 last_sample_time ;
265
+ u64 aperf_mperf_shift ;
262
266
u64 prev_aperf ;
263
267
u64 prev_mperf ;
264
268
u64 prev_tsc ;
@@ -321,6 +325,7 @@ struct pstate_funcs {
321
325
int (* get_min )(void );
322
326
int (* get_turbo )(void );
323
327
int (* get_scaling )(void );
328
+ int (* get_aperf_mperf_shift )(void );
324
329
u64 (* get_val )(struct cpudata * , int pstate );
325
330
void (* get_vid )(struct cpudata * );
326
331
void (* update_util )(struct update_util_data * data , u64 time ,
@@ -1486,6 +1491,11 @@ static u64 core_get_val(struct cpudata *cpudata, int pstate)
1486
1491
return val ;
1487
1492
}
1488
1493
1494
+ static int knl_get_aperf_mperf_shift (void )
1495
+ {
1496
+ return 10 ;
1497
+ }
1498
+
1489
1499
static int knl_get_turbo_pstate (void )
1490
1500
{
1491
1501
u64 value ;
@@ -1543,6 +1553,9 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
1543
1553
cpu -> pstate .max_freq = cpu -> pstate .max_pstate * cpu -> pstate .scaling ;
1544
1554
cpu -> pstate .turbo_freq = cpu -> pstate .turbo_pstate * cpu -> pstate .scaling ;
1545
1555
1556
+ if (pstate_funcs .get_aperf_mperf_shift )
1557
+ cpu -> aperf_mperf_shift = pstate_funcs .get_aperf_mperf_shift ();
1558
+
1546
1559
if (pstate_funcs .get_vid )
1547
1560
pstate_funcs .get_vid (cpu );
1548
1561
@@ -1616,7 +1629,8 @@ static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu)
1616
1629
int32_t busy_frac , boost ;
1617
1630
int target , avg_pstate ;
1618
1631
1619
- busy_frac = div_fp (sample -> mperf , sample -> tsc );
1632
+ busy_frac = div_fp (sample -> mperf << cpu -> aperf_mperf_shift ,
1633
+ sample -> tsc );
1620
1634
1621
1635
boost = cpu -> iowait_boost ;
1622
1636
cpu -> iowait_boost >>= 1 ;
@@ -1675,7 +1689,8 @@ static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu)
1675
1689
sample_ratio = div_fp (pid_params .sample_rate_ns , duration_ns );
1676
1690
perf_scaled = mul_fp (perf_scaled , sample_ratio );
1677
1691
} else {
1678
- sample_ratio = div_fp (100 * cpu -> sample .mperf , cpu -> sample .tsc );
1692
+ sample_ratio = div_fp (100 * (cpu -> sample .mperf << cpu -> aperf_mperf_shift ),
1693
+ cpu -> sample .tsc );
1679
1694
if (sample_ratio < int_tofp (1 ))
1680
1695
perf_scaled = 0 ;
1681
1696
}
@@ -1807,6 +1822,7 @@ static const struct pstate_funcs knl_funcs = {
1807
1822
.get_max_physical = core_get_max_pstate_physical ,
1808
1823
.get_min = core_get_min_pstate ,
1809
1824
.get_turbo = knl_get_turbo_pstate ,
1825
+ .get_aperf_mperf_shift = knl_get_aperf_mperf_shift ,
1810
1826
.get_scaling = core_get_scaling ,
1811
1827
.get_val = core_get_val ,
1812
1828
.update_util = intel_pstate_update_util_pid ,
@@ -2403,6 +2419,7 @@ static void __init copy_cpu_funcs(struct pstate_funcs *funcs)
2403
2419
pstate_funcs .get_val = funcs -> get_val ;
2404
2420
pstate_funcs .get_vid = funcs -> get_vid ;
2405
2421
pstate_funcs .update_util = funcs -> update_util ;
2422
+ pstate_funcs .get_aperf_mperf_shift = funcs -> get_aperf_mperf_shift ;
2406
2423
2407
2424
intel_pstate_use_acpi_profile ();
2408
2425
}
0 commit comments