Skip to content

Commit 52ccc43

Browse files
spandruvadarafaeljw
authored andcommitted
cpufreq: intel_pstate: HWP boost performance on IO wakeup
This change uses SCHED_CPUFREQ_IOWAIT flag to boost HWP performance. Since SCHED_CPUFREQ_IOWAIT flag is set frequently, we don't start boosting steps unless we see two consecutive flags in two ticks. This avoids boosting due to IO because of regular system activities. To avoid synchronization issues, the actual processing of the flag is done on the local CPU callback. Reported-by: Mel Gorman <[email protected]> Tested-by: Giovanni Gherdovich <[email protected]> Signed-off-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e0efd5b commit 52ccc43

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ struct global_params {
223223
* operation
224224
* @hwp_req_cached: Cached value of the last HWP Request MSR
225225
* @hwp_cap_cached: Cached value of the last HWP Capabilities MSR
226+
* @last_io_update: Last time when IO wake flag was set
227+
* @sched_flags: Store scheduler flags for possible cross CPU update
226228
* @hwp_boost_min: Last HWP boosted min performance
227229
*
228230
* This structure stores per CPU instance data for all CPUs.
@@ -258,6 +260,8 @@ struct cpudata {
258260
s16 epp_saved;
259261
u64 hwp_req_cached;
260262
u64 hwp_cap_cached;
263+
u64 last_io_update;
264+
unsigned int sched_flags;
261265
u32 hwp_boost_min;
262266
};
263267

@@ -1460,9 +1464,44 @@ static inline void intel_pstate_hwp_boost_down(struct cpudata *cpu)
14601464
cpu->last_update = cpu->sample.time;
14611465
}
14621466

1467+
static inline void intel_pstate_update_util_hwp_local(struct cpudata *cpu,
1468+
u64 time)
1469+
{
1470+
cpu->sample.time = time;
1471+
1472+
if (cpu->sched_flags & SCHED_CPUFREQ_IOWAIT) {
1473+
bool do_io = false;
1474+
1475+
cpu->sched_flags = 0;
1476+
/*
1477+
* Set iowait_boost flag and update time. Since IO WAIT flag
1478+
* is set all the time, we can't just conclude that there is
1479+
* some IO bound activity is scheduled on this CPU with just
1480+
* one occurrence. If we receive at least two in two
1481+
* consecutive ticks, then we treat as boost candidate.
1482+
*/
1483+
if (time_before64(time, cpu->last_io_update + 2 * TICK_NSEC))
1484+
do_io = true;
1485+
1486+
cpu->last_io_update = time;
1487+
1488+
if (do_io)
1489+
intel_pstate_hwp_boost_up(cpu);
1490+
1491+
} else {
1492+
intel_pstate_hwp_boost_down(cpu);
1493+
}
1494+
}
1495+
14631496
static inline void intel_pstate_update_util_hwp(struct update_util_data *data,
14641497
u64 time, unsigned int flags)
14651498
{
1499+
struct cpudata *cpu = container_of(data, struct cpudata, update_util);
1500+
1501+
cpu->sched_flags |= flags;
1502+
1503+
if (smp_processor_id() == cpu->cpu)
1504+
intel_pstate_update_util_hwp_local(cpu, time);
14661505
}
14671506

14681507
static inline void intel_pstate_calc_avg_perf(struct cpudata *cpu)

0 commit comments

Comments
 (0)