From: "Joel Fernandes (Google)" <joel(a)joelfernandes.org>
Here's a very rough patch just to discuss prevention of decay of
CPU/task's util_avg signal incase its preempted by RT or DL. Its
likely not correct and needs more work but it solves the issue I see
with my synthetic test.
To reproduce the issue, I wrote a synthetic rt-app test with RT task
preempting a 100% CFS task for 300ms. https://pastebin.com/raw/rXNmRUZY
I have seen in traces that the util_avg decays quickly even before the
RT task sleeps.
The idea is to mark the CFS class from put_prev_task_fair if the task
was running while the put_prev_task() happened and unmark it from
pick_next_task_fair. This approach also keeps the solution of this
within CFS without modification to other classes. What do you think?
Note:
- Just for demo/trial, I took a full int from sched_avg. I am open to
any ideas on a flag we can set, all that's needed is 1 bit.
- The current UTIL_EST design cannot prevent this issue because it
relies on task's sleeping and infact could be affect by this issue
itself incase task's util-est EWMA hasn't built up.
- Vincent's patches for PELT in DL/RT are still needed for correct OPP
selection and estimation of capacity_of etc. This patch solves a
different issue.
CC: "eas-dev" <eas-dev(a)lists.linaro.org>
CC: vincent.guittot(a)linaro.org
CC: patrick.bellasi(a)arm.com
CC: dietmar.eggemann(a)arm.com
CC: chris.redpath(a)arm.com
CC: juri.lelli(a)redhat.com
CC: tkjos(a)google.com
Signed-off-by: Joel Fernandes (Google) <joel(a)joelfernandes.org>
---
include/linux/sched.h | 1 +
kernel/sched/fair.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ca3f3eae8980..46b686192641 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -404,6 +404,7 @@ struct sched_avg {
unsigned long runnable_load_avg;
unsigned long util_avg;
struct util_est util_est;
+ int freeze_updates;
} ____cacheline_aligned;
struct sched_statistics {
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 09b7eb69802c..521656b05b22 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3103,6 +3103,13 @@ accumulate_sum(u64 delta, int cpu, struct sched_avg *sa,
u32 contrib = (u32)delta; /* p == 0 -> delta < 1024 */
u64 periods;
+ /*
+ * If an update is supposed to be skipped, then do nothing.
+ * sa->last_update_time should still moves forward.
+ */
+ if (sa->freeze_updates)
+ return 0;
+
scale_freq = arch_scale_freq_capacity(cpu);
scale_cpu = arch_scale_cpu_capacity(NULL, cpu);
@@ -6963,6 +6970,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
p = task_of(se);
done: __maybe_unused;
+
#ifdef CONFIG_SMP
/*
* Move the next running task to the front of
@@ -6975,6 +6983,8 @@ done: __maybe_unused;
if (hrtick_enabled(rq))
hrtick_start_fair(rq, p);
+ rq->cfs.avg.freeze_updates = 0;
+ p->se.avg.freeze_updates = 0;
return p;
idle:
@@ -6991,6 +7001,7 @@ done: __maybe_unused;
if (new_tasks > 0)
goto again;
+ rq->cfs.avg.freeze_updates = 0;
return NULL;
}
@@ -7006,6 +7017,18 @@ static void put_prev_task_fair(struct rq *rq, struct task_struct *prev)
cfs_rq = cfs_rq_of(se);
put_prev_entity(cfs_rq, se);
}
+
+ /*
+ * Task is being put because of preemption either by CFS or by a higher
+ * class. Make sure no util updates happen.
+ */
+ if (!prev->state) { /* Task is put while running */
+ rq->cfs.avg.freeze_updates = 1;
+ prev->se.avg.freeze_updates = 1;
+ } else {
+ rq->cfs.avg.freeze_updates = 0;
+ prev->se.avg.freeze_updates = 0;
+ }
}
/*
--
2.18.0.rc1.242.g61856ae69a-goog
Hi,
Joel was looking at something else in android-4.14 wakeup path and he
noticed that we have a difference in behavior for prefer_idle tasks when
we're using find_best_target, so he asked if we could discuss that here.
Behavior in android-4.9 and earlier
-----------------------------------
When we find an idle CPU for a task which has the prefer_idle attribute,
we immediately return that CPU from the energy-based wakeup CPU
selection. This happens in slightly different places over the EAS and
android versions but it is always true that we take the recommended idle
CPU for tasks in this class.
How that changed in android-4.14
--------------------------------
android-4.14 has two different wakeup paths, selected with a
sched_feature FIND_BEST_TARGET. This defaults to true with the intent of
preserving the previous behavior. Both paths are different, so I'll
describe them below separately.
The two paths however share some common code - the way we integrated EAS
with the regular wakeup code is different in android-4.14.
There were two reasons for doing this.
1. minimize the differences in select_task_rq_fair wrt mainline code
2. make better use of the per-sd overutilization flags
Since we have per-sd overutilised flags, we attempt to perform an EAS
wakeup at the highest non-overutilised sched_domain - meaning that we
can still perform an energy-aware wakeup for small tasks inside a
non-overutilized group of small CPUs while potentially other groups of
CPUs are overutilized.
The decision about attempting to use energy awareness is taken in
wake_energy function at the top of strf - all the cases where we can't
use energy-awareness are ruled out, and the decision about using
find_idlest_cpu/EAS for prefer_idle tasks is also done here.
If we are using energy aware wakeups, then we will find the highest
non-overutilised SD to wake in.
In all cases where we do an energy aware wakeup but don't find any
suitable candidate CPUs we will go on to use find_idlest_cpu.
android-4.14 sched_feat(FIND_BEST_TARGET) true wakeup path
----------------------------------------------------------
When FIND_BEST_TARGET sched feature is on (the default), we call
find_best_target to populate the energy_env structure. This takes note
of the prefer_idle flag and the task boost to change which task
placement strategy will be used - the algorithm is the same as in
previous versions of android.
However in android-4.14 (unintentionally) the prefer_idle task placement
is not immediately acted upon - when a prefer_idle task is placed, we
will select the first idle CPU we see *but* this will become the target
CPU and we will still perform an energy diff and select between
prev/target based upon energy requirement.
The open question is - now that we have realized that there is a
different strategy in place, should we change it to be the same as the
old version? I think that we should - it will be a simple change to use
the idle cpu selected immediately without the energy diff.
All we would need is to add something like this:
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7383,7 +7383,7 @@ static int find_energy_efficient_cpu(struct
sched_domain *sd,
}
} else {
int boosted = (schedtune_task_boost(p) > 0);
- int prefer_idle;
+ int prefer_idle, target_cpu;
/*
* give compiler a hint that if sched_features
@@ -7396,10 +7396,18 @@ static int find_energy_efficient_cpu(struct
sched_domain *sd,
eenv->max_cpu_count = EAS_CPU_BKP + 1;
/* Find a cpu with sufficient capacity */
- eenv->cpu[EAS_CPU_NXT].cpu_id = find_best_target(p,
+ target_cpu = find_best_target(p,
&eenv->cpu[EAS_CPU_BKP].cpu_id,
boosted, prefer_idle);
+ /* immediately select idle CPUs for prefer-idle tasks */
+ if (prefer_idle && target_cpu >= 0 &&
+ idle_cpu(target_cpu)))
+ return target_cpu;
+
+ /* place target into NEXT slot */
+ eenv->cpu[EAS_CPU_NXT].cpu_id = target_cpu;
+
/* take note if no backup was found */
if (eenv->cpu[EAS_CPU_BKP].cpu_id < 0)
eenv->max_cpu_count = EAS_CPU_BKP;
It could be the case that there are energy advantages to performing an
energy diff for prefer_idle tasks, we've tried a few times to come up
with a way to use lower-energy CPUs for these tasks where possible (for
cases like full-screen video playback or screen-off audio playback)
without harming the interactive response, but we haven't managed to come
up with anything which doesn't need per-platform tuning which isn't
really suitable. The underlying requirement for these prefer_idle tasks
is that they should ideally not be preempted as they are likely to be
part of the critical frame drawing path.
We should also note that the EAS_PREFER_IDLE sched_feature potentially
also has an effect on this - if we are using find_best_target and we do
not have EAS_PREFER_IDLE set to true (true is the default), then we
don't pass the prefer_idle status of the task to find_best_target -
however if EAS_PREFER_IDLE is not true, we should have avoided entering
find_energy_efficient_cpu in the first place.
To be complete, there is also a further sched_feat for task placement
which controls how we evaluate the energy requirement for a task. If
FBT_STRICT_ORDER is on (the default), we will select the first CPU we
find which saves energy compared to the prev_cpu. This matches previous
versions of android.
We have been experimenting with selecting the most efficient out of the
target/backup CPUs provided by find_best_target, if FBT_STRICT_ORDER is
false this is what the scheduler will do. In testing there isn't really
a clear winner out of these options, so I added the sched feature so
users could play with the options easily on their platforms without code
changes.
android-4.14 sched_feat(FIND_BEST_TARGET) false wakeup path
-----------------------------------------------------------
This uses the brute-force placement strategy from the pre-simplified-EM
mainline EAS patch set, inside the android energy diff algorithm.
In android, we collect all the potential CPU placement options in a data
structure, and then evaluate the energy for all of them at each
sched_domain traversal level. This is done to avoid visiting each domain
& group more than once.
Other than the switch to the new energy calculation method, the energy
required is still calculated for every allowable CPU and then the option
which has the lowest overall consumption is selected.
When it comes to dealing with prefer_idle tasks, there is another
optional behaviour in this mode. If you have sched_feat(EAS_PREFER_IDLE)
set to true (the default), then prefer_idle tasks have no special
treatment in the energy-aware wakeup path. This means they will get the
lowest-energy option with no regard to idleness.
However, if EAS_PREFER_IDLE is false (i.e. don't use EAS for prefer-idle
tasks) then we route these tasks through the slow path wakeup code - the
decision is made inside wake_energy, which propagates through to calling
find_idlest_cpu instead of find_energy_efficient_cpu.
If the find_best_target feature FBT_STRICT_ORDER is true (the default)
then the first CPU which saves energy compared to default will be
selected rather than the most efficient. When combined with the brute
force selection algorithm, this will result in the lowest-numbered cpu
which saves energy over the prev_cpu being selected.
This is not the way that the brute force (mainline-alike) placement is
intended to work, so when using brute force (FIND_BEST_TARGET=false) one
should also turn off strict ordering (FBT_STRICT_ORDER=false) *and* opt
out of using EAS for prefer_idle tasks (EAS_PREFER_IDLE=false).
--Chris
Hi,
Any updates to below emails,.?
Regards
Chris
From: Chris Samuel [mailto:chris.samuel@lead-marketings.com]
Sent: Thursday, April 05, 2018 10:16 AM
To: 'eas-dev(a)lists.linaro.org'
Subject: RE: IBM lotus-accounts
Hi,
Any updates to below emails,.?
Awaiting your kind response for regarding my previous email. If it makes
sense to talk, please let me know how your calendar looks.
I would appreciate if you could pass along my details to the appropriate
person if you don't handle this.
Do you have any other requirement kindly let me know your exact target
industry and target audience and target location, we will provide the exact
cost and counts with many more ....
Regards,
Chris
From: Chris Samuel [mailto:chris.samuel@lead-marketings.com]
Sent: Tuesday, April 03, 2018 4:28 PM
To: 'eas-dev(a)lists.linaro.org'
Subject: IBM lotus-accounts
Hi,
A quick check to see if you would you be interested to acquire updated
Slack, IBM Lotus Domino, IBM Lotus Notes, LogMeIn, Microsoft SharePoint,
Accounts with verified email and phone numbers.
kindly let me know your exact target industry and target audience and target
location, we will provide the exact database counts with cost and many
more....
Appreciate your time and look forward to your response.
Best Regards,
Chris,
Marketing Executive,
If you do not want to receive from us then reply back "Unsubscribe" as a
Subject Line.
Hi EAS-DEV,
We are fine tuning EAS and DVFS for our product, and use WA to do auto test.
In the presentation, http://connect.linaro.org.s3.amazonaws.com/hkg18/presentations/hkg18-210.pdf, it lists Test cases at Page 9 & 10.
Except Vellamo, can all the following test cases be verified via WA?
In addition, there are some questions to consult.
1) Temple run and Beach buggy blitz are games, how to evaluate the performance?
2) Is there any suitable benchmark for UIbench & Homescreen?
3) Currently, audio and video are real-time playback, how to check the improvement?
[cid:image001.png@01D3D58F.7F44EEE0]
[cid:image002.png@01D3D58F.7F44EEE0]
BR,
Erin
Hi,
Any updates to below emails,.?
Awaiting your kind response for regarding my previous email. If it makes
sense to talk, please let me know how your calendar looks.
I would appreciate if you could pass along my details to the appropriate
person if you don't handle this.
Do you have any other requirement kindly let me know your exact target
industry and target audience and target location, we will provide the exact
cost and counts with many more ....
Regards,
Chris
From: Chris Samuel [mailto:chris.samuel@lead-marketings.com]
Sent: Tuesday, April 03, 2018 4:28 PM
To: 'eas-dev(a)lists.linaro.org'
Subject: IBM lotus-accounts
Hi,
A quick check to see if you would you be interested to acquire updated
Slack, IBM Lotus Domino, IBM Lotus Notes, LogMeIn, Microsoft SharePoint,
Accounts with verified email and phone numbers.
kindly let me know your exact target industry and target audience and target
location, we will provide the exact database counts with cost and many
more....
Appreciate your time and look forward to your response.
Best Regards,
Chris,
Marketing Executive,
If you do not want to receive from us then reply back "Unsubscribe" as a
Subject Line.
Hi,
A quick check to see if you would you be interested to acquire updated
Slack, IBM Lotus Domino, IBM Lotus Notes, LogMeIn, Microsoft SharePoint,
Accounts with verified email and phone numbers.
kindly let me know your exact target industry and target audience and target
location, we will provide the exact database counts with cost and many
more....
Appreciate your time and look forward to your response.
Best Regards,
Chris,
Marketing Executive,
If you do not want to receive from us then reply back "Unsubscribe" as a
Subject Line.
Hi,
My first mail here, please tell me if this is not the right list for my queries. I have recently got myself a thundersoft s835 development kit and set it up for power measurement. I was looking at creating the energy model for this from scratch and measuring the impact. I stumbled across something which led me to write this mail. The eas integration document mentions no support currently exists for SMT. However, my kernel configuration for some reason has SCHED_SMT enabled. The s835 is not hyper-threaded and so I am thinking it's a mistake. My questions are:
1) Is disabling SCHED_SMT enough or are there any other configurations that need to be changed as well ?
2) I'd like to understand the technical difficulties with enabling SMT support since I have a mips device which has hyperthreading. Is it that the cpu-cluster energy model would not be enough to handle proper task placement when it comes to virtual cores ?
3) Is there any on-going work on adding SMT support or is it considered as not being worth the effort ?
Thanks for reading.
-Jason
This patch set is to optimize the energy computation on Android kernel
android-4.9-eas-dev branch [1];
Patches 0001-0012 are used to refactor the code and some minor optimization,
otherwise the task energy computation is hard to landed into current code;
Patch 0013 "sched/fair: Optimize energy computation with task oriented" is
the core patch in whole patch set, which is mainly used to implement energy
calculation for task. Patch 0014 is a sequential patch to use cached value
so we can get more benefit for performance by exchanging more memory.
Patch 0015 is a trival experiment patch to remove 'idle state estimation'.
The testing uses rt-app to generate synthetic workload, the workload duty
cycles are 1%/5%/10%/20%/30%/40%; the duration is measured interval for
func select_energy_cpu_idx(), which now is used to calculation three
candidates in single run. The result shows this patch set improve for
energy computation duration:
+----------------+-------+-------+-------+-------+-------+--------+
| workload | 1% | 5% | 10% | 20% | 30% | 40% |
+----------------+-------+-------+-------+-------+-------+--------+
| w/o patch set | 17267 | 21227 | 17019 | 13914 | 15002 | 23412 |
| w/t patch set | 10823 | 11924 | 10931 | 10785 | 11139 | 11223 |
+----------------+-------+-------+-------+-------+-------+--------+
| Opt percentage | 37% | 43% | 36% | 22% | 26% | 52% |
+----------------+-------+-------+-------+-------+-------+--------+
The detailed testing ipython notebook you could check [2][3].
[1] https://android.googlesource.com/kernel/common/+/android-4.9-eas-dev
[2] https://github.com/Leo-Yan/lisa/blob/2018_03_17_android_4.9_eas_dev_nrg_com…
[3] https://github.com/Leo-Yan/lisa/blob/2018_03_17_android_4.9_eas_dev_nrg_com…
Leo Yan (15):
sched/fair: Prepare energy env cpumask before energy calculation
sched/fair: Re-define return values for select_energy_cpu_idx()
sched/fair: Reduce indent in select_energy_cpu_brute()
sched/fair: Fix one minor typo
sched/fair: Use per cpu data to maintain energy environment
sched/fair: Use cpumask to track candidates for energy calculation
sched/fair: Lift CPU iteration out of calc_sg_energy()
sched/fair: Introduce new function compute_task_energy()
sched/fair: Decide 'eenv->sg_cap' ahead energy computation
sched/fair: Use eenv::sg_cap to select capacity index
sched/fair: Estimate capacity index ahead energy computation
sched/fair: Refactor compute_energy()
sched/fair: Optimize energy computation with task oriented
sched/fair: Optimize energy calculation with cached energy data
sched/fair: Remove idle state estimation
kernel/sched/fair.c | 542 +++++++++++++++++++++++++---------------------------
1 file changed, 256 insertions(+), 286 deletions(-)
--
1.9.1
hi Chris, Patrick, Quentin,
On android-4.9-eas-dev branch, after the commit of energy_diff
re-factor("sched/fair: re-factor energy_diff to use a single
(extensible) energy_env"), the calculation of group_idle_state for
previous cpu had changed.
Before the re-factor, for eenv_before, there is chance to continue
doing group_idle_state estimation(not "0goto end" directly);
After the re-factor, for cpu_idx=EAS_CPU_PRV, there is no chance to do
estimation("goto end" directly);
Is it deliberate for this change? If yes, do you have any test result for this?
-static int group_idle_state(struct energy_env *eenv, struct sched_group *sg)
+static int group_idle_state(struct energy_env *eenv, int cpu_idx)
{
+ struct sched_group *sg = eenv->sg;
int i, state = INT_MAX;
int src_in_grp, dst_in_grp;
long grp_util = 0;
@@ -5556,8 +5610,10 @@ static int group_idle_state(struct energy_env
*eenv, struct sched_group *sg)
/* Take non-cpuidle idling into account (active idle/arch_cpu_idle()) */
state++;
- src_in_grp = cpumask_test_cpu(eenv->src_cpu, sched_group_cpus(sg));
- dst_in_grp = cpumask_test_cpu(eenv->dst_cpu, sched_group_cpus(sg));
+ src_in_grp = cpumask_test_cpu(eenv->cpu[EAS_CPU_PRV].cpu_id,
+ sched_group_cpus(sg));
+ dst_in_grp = cpumask_test_cpu(eenv->cpu[cpu_idx].cpu_id,
+ sched_group_cpus(sg));
if (src_in_grp == dst_in_grp) {
/* both CPUs under consideration are in the same group or not in
* either group, migration should leave idle state the same.
@@ -5571,7 +5627,7 @@ static int group_idle_state(struct energy_env
*eenv, struct sched_group *sg)
*/
for_each_cpu(i, sched_group_cpus(sg)) {
grp_util += cpu_util_wake(i, eenv->p);
- if (unlikely(i == eenv->trg_cpu))
+ if (unlikely(i == eenv->cpu[cpu_idx].cpu_id))
grp_util += eenv->util_delta;
}
Thanks,
Ke Wang
Hi,
In an attempt to clarify and simplify find_best_target I've identified
four areas that I believe might benefit from
simplifications/clarifications/fixing.
Please consider the ideas below as proposals towards this purpose. Also,
consider these listed from narrow scope to broader scope.
1. Do not consider boost for !prefer_idle tasks, but always try to
minimize capacity_orig. This was more or less done already by not
having boosted and not-prefer idle tasks in typical Android
configurations, but was never enforced in find_best_target code. This
was discussed on this list as well in the "sched/fair: Prefer low
capacity idle-CPU for boosted non-prefer-idle tasks" thread.
Leo, Viresh, I would encourage you to push your patch to Gerrit and
continue the discussion there, as it is a valid point on its own, and
less controversial than the broader scope patch at 2.
2. Do not consider boost for prefer_idle tasks, but always try to
maximize capacity_orig.
This is the discussion that the patch at
https://android-review.googlesource.com/c/kernel/common/+/636583 is
trying to trigger, although in scope it touches on the point above as
well.
3. Make order of CPUs irrelevant for CPU selection in find_best_target.
This is a patch I'll try to push to Gerrit tomorrow after I have more
test results. This will not incorporate code for any of the points
above and it will try to mimic the selection of a CPU that is done now
in find_best target.
But if the points above are proven on their own, this fact will simplify
the code for this item and make the implementation of the item at 2.
unnecessary.
4. Remove the prefer_idle case from find_best_target.
https://android-review.googlesource.com/q/topic:%22strf-mainline%22+(status…
This has the broadest scope but it is more difficult to validate.
Although broader scope items would make some narrow scope items
unnecessary, they have value on their own if the boarder scope items
cannot be proven in a reasonable amount of time, as they will provide
fixes and support earlier than it takes to make a full re-factor of
code.
- 1 will provide valuable fixes now.
- 2 will simplify find_best_target decision logic to facilitate and
simplify 3.
- 3 will add support for tri-gear platforms for which the current order
of CPUs will be incorrect in some cases.
- 4 will bring us closer to the mainline behavior.
I'm adding the present of pretty pictures from what I call
"validation by storm": I've created some kernels with combinations of
the above items and tested them on a Pixel 2 device, just to make sure
there are no important regressions introduced by them. But I believe
all of these need to be validated independently to make sure we don't
miss important corner cases.
Results at https://gist.github.com/ionela-voinescu/f89815591c7f50864188094bb8c53ec4.
Given that it's difficult for all involved to keep up with discussions
on both gerrit and eas-dev, I'd suggest to discuss design and direction
ideas as part of this thread and push patches and individual test
references to android-review directly.
Let me know what you think. All comments are welcomed!
Best regards,
Ionela.
Currently energy calculation in EAS has missed to consider RT pressure,
it's quite possible to select CPU for CFS tasks which has high RT
pressure and finally accumulate total utilization; as result the other
low RT pressure CPUs lose chance to run CFS tasks and reduce contention
between CFS and RT tasks, from performance view this is not optimal;
furthermore this also harms power data due pack RT task and CFS task on
single one CPU is more easily to trigger CPU frequency increasing.
We can measure the summed CPU utilization and calculate the CPU freqency
standard deviation to get to if the tasks can be well spreading within
the same cluster for middle workload case. So below is the comparison
result for video playback on Hikey960 for before and after applied this
patch set (Using schedutil CPUFreq governor):
Without Patch Set: With Patch Set:
CPU Min(Util) Mean(Util) Mean(Util) | Min(Util) Mean(Util) Mean(Util)
0 7 67 205 | 8 52 170
1 4 53 227 | 9 47 188
2 4 57 191 | 8 38 192
3 4 35 165 | 16 47 146
s.d. 1.5 13.3 25.9 | 3.9 5.83 20.9
4 0 35 160 | 10 34 129
5 0 24 129 | 0 30 115
6 0 18 123 | 0 18 95
7 0 12 84 | 0 21 73
s.d. 0 9.8 31.2 | 5 7.5 24.4
The standard diviation for CPU utilization mean value has been decreased
after applying this patch set (Little cluster: 13.3 vs 5.83, big cluster:
9.8 vs 7.5). This also confirm from the average CPU frequency:
Without Patch Set: With Patch Set:
Average Frequency | Average Frequency
LITTLT Cluster 737MHz | 646MHz
big Cluster 916MHz | 922MHz
Leo Yan (4):
sched/fair: Select maximum spare capacity for idle candidate CPUs
sched: Introduce cpu_util_sum()/__cpu_util_sum() functions
sched/fair: Consider RT pressure for find_best_target()
sched/fair: Consider RT/DL pressure for energy calculation
kernel/sched/fair.c | 22 +++++++++++++++++++---
kernel/sched/sched.h | 29 +++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 3 deletions(-)
--
1.9.1
Hi Patrick,
I am reading the code for eas-4.9-dev branch [1], and found
schedtune_accept_deltas() has been removed from fair.c. I think this
is not purposed and might be wrongly removed by some optimization
patch and should add back?
Not sure if there have following patch to fix this. FYI.
[1] https://android.googlesource.com/kernel/common/+/android-4.9-eas-dev/kernel…
Thanks,
Leo Yan
From: Leo Yan <leo.yan(a)linaro.org>
The homescreen test-case shows unwanted disturbance on the big CPUs on
the Hikey620 platform with Android 4.9. There are multiple reasons for
that though.
By default boost and prefer_idle are enabled for both top-app and
foreground tasks and find_best_target() always (intentionally) prefers
the big CPUs if prefer_idle is enabled. And some of the foreground tasks
(like: DispSync, PowerManagerSer and PhotonicModulat) for the homescreen
test-case get placed on the big CPUs eventually because of that.
Even if prefer_idle is disabled for such foreground tasks, they don't
end up on the little CPUs. The reason being that find_best_target()
still prefers big CPUs if the task is boosted, though some of the
comments in find_best_target() routine say the exact opposite of that.
It eventually depends on the order in which CPUs are processed, which is
from big to little for boosted tasks.
This patch updates the find_best_target() routine to select low capacity
idle-CPU if the task is boosted but doesn't have prefer_idle enabled.
This would be the same for non-boosted tasks as well.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
---
kernel/sched/fair.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e45047bdd245..4534d8620989 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6998,8 +6998,11 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
int idle_idx = idle_get_state_idx(cpu_rq(i));
/* Select idle CPU with lower cap_orig */
- if (capacity_orig > best_idle_min_cap_orig)
+ if (capacity_orig < best_idle_min_cap_orig)
+ goto found_best_idle_cpu;
+ else if (capacity_orig > best_idle_min_cap_orig)
continue;
+
/* Favor CPUs that won't end up running at a
* high OPP.
*/
@@ -7017,6 +7020,7 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
best_idle_cstate <= idle_idx)
continue;
+found_best_idle_cpu:
/* Keep track of best idle CPU */
best_idle_min_cap_orig = capacity_orig;
target_idle_max_spare_cap = capacity_orig -
--
2.15.0.194.g9af6a3dea062
find_best_target() tries to find the target CPU where the task should be
placed, based on how much would be the utilization of the CPU after the
task is placed on it. This is represented by 'new_util' in the routine.
Currently it adds task_util(p) to the wake_util of the CPU to find that
out, while it should really be adding the boosted task's util to
wake_util, as that's how much the cpu utilization would be.
This is how we used to do it before commit 3bfde3b4f848 ("ANDROID:
sched/fair: Change cpu iteration order in find_best_target()"), was
merged and the commit doesn't describe the rational behind this change.
This patch reverts to the earlier formula to calculate the new_util.
Fixes: 3bfde3b4f848 ("ANDROID: sched/fair: Change cpu iteration order in find_best_target()")
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
---
Just wanted to get some review done over the list before posting it to
gerrit. Not sure if this commit is doing the right thing, but I couldn't
understand why it should be done this way.
This is for the Android 4.9 EAS dev kernel.
kernel/sched/fair.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 88abd5de69ce..1c33a2ddd39c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6860,14 +6860,13 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
* accounting. However, the blocked utilization may be zero.
*/
wake_util = cpu_util_wake(i, p);
- new_util = wake_util + task_util(p);
/*
* Ensure minimum capacity to grant the required boost.
* The target CPU can be already at a capacity level higher
* than the one required to boost the task.
*/
- new_util = max(min_util, new_util);
+ new_util = wake_util + min_util;
/*
* Include minimum capacity constraint:
--
2.15.0.194.g9af6a3dea062