Created
August 16, 2019 10:24
-
-
Save derkling/fb69274fa8787bdfa20c37edcd1c4fde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c | |
index 54b5dd8dd46d..3cc3e76de129 100644 | |
--- a/kernel/sched/fair.c | |
+++ b/kernel/sched/fair.c | |
@@ -6457,8 +6457,11 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, int sy | |
if (cpu_cap < uclamp_task_util(p)) | |
continue; | |
+ if (prefer_idle) | |
+ goto find_best_idle; | |
+ | |
/* Always use prev_cpu as a candidate. */ | |
- if (!prefer_idle && cpu == prev_cpu) { | |
+ if (cpu == prev_cpu) { | |
prev_energy = compute_energy(p, prev_cpu, head); | |
best_energy = min(best_energy, prev_energy); | |
continue; | |
@@ -6474,8 +6477,9 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, int sy | |
max_spare_cap_cpu = cpu; | |
} | |
- if (!prefer_idle) | |
- continue; | |
+ find_best_idle: | |
+ | |
+ /* Add comments here to explain the policy */ | |
if (idle_cpu(cpu)) { | |
cpu_cap = capacity_orig_of(cpu); | |
@@ -6484,22 +6488,30 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, int sy | |
if (!boosted && cpu_cap > target_cap) | |
continue; | |
idle = idle_get_state(cpu_rq(cpu)); | |
- if (idle && idle->exit_latency > min_exit_lat && | |
- cpu_cap == target_cap) | |
- continue; | |
- | |
- if (idle) | |
+ if (idle) { | |
+ if (idle->exit_latency > min_exit_lat && | |
+ cpu_cap == target_cap) { | |
+ continue; | |
+ } | |
min_exit_lat = idle->exit_latency; | |
+ } | |
target_cap = cpu_cap; | |
best_idle_cpu = cpu; | |
- } else if (spare_cap > highest_spare_cap) { | |
+ continue; | |
+ } | |
+ | |
+ spare_cap = cpu_cap - util; | |
+ if (spare_cap > highest_spare_cap) { | |
highest_spare_cap = spare_cap; | |
highest_spare_cap_cpu = cpu; | |
} | |
} | |
+ if (prefer_idle) | |
+ continue; | |
+ | |
/* Evaluate the energy impact of using this CPU. */ | |
- if (!prefer_idle && max_spare_cap_cpu >= 0) { | |
+ if (max_spare_cap_cpu >= 0) { | |
cur_energy = compute_energy(p, max_spare_cap_cpu, head); | |
if (cur_energy < best_energy) { | |
best_energy = cur_energy; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment