android_kernel_oneplus_msm8998/include
Syed Rameez Mustafa 7bd09f2441 sched: Add the mechanics of top task tracking for frequency guidance
The previous patches in this rewrite of scheduler guided frequency
selection reintroduces the part-picture problem that we addressed in
our initial implementation. In that, when tasks migrate across CPUs
within a cluster, we end up losing the complete picture of the
sequential nature of the workload.

This patch aims to solve that problem slightly differently. We track
the top task on every CPU within a window. Top task is defined as the
task that runs the most in a given window. This enhances our ability
to detect the sequential nature of workloads. A single migrating task
executing for an entire window will cause 100% load to be reported
for frequency guidance instead of the maximum footprint left on any
individual CPU in the task's trail. There are cases, that this new
approach does not address. Namely, cases where the sum of two or more
tasks accurately reflects the true sequential nature of the workload.
Future optimizations might aim to tackle that problem.

To track top tasks, we first realize that there is no strict need to
maintain the task struct itself as long as we know the load exerted by
the top task. We also realize that to maintain top tasks on every CPU
we have to track the execution of every single task that runs during
the window. The load associated with a task needs to be migrated when
the task migrates from one CPU to another. When the top task migrates
away, we need to locate the second top task and so on.

Given the above realizations, we use hashmaps to track top task load
both for the current and the previous window. This hashmap is
implemented as an array of fixed size. The key of the hashmap is given
by task_execution_time_in_a_window / array_size. The size of the array
(number of buckets in the hashmap) dictate the load granularity of each
bucket. The value stored in each bucket is a refcount of all the tasks
that executed long enough to be in that bucket.

This approach has a few benefits. Firstly, any top task stats update
now take O(1) time. While task migration is also O(1), it does still
involve going through up to the size of the array to find the second
top task. Further patches will aim to optimize this behavior. Secondly,
and more importantly, not having to store the task struct itself saves
a lot of memory usage in that 1) there is no need to retrieve task
structs later causing cache misses and 2) we don't have to unnecessarily
hold up task memory for up to 2 full windows by calling get_task_struct()
after a task exits.

Change-Id: I004dba474f41590db7d3f40d9deafe86e71359ac
Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>
2016-10-17 12:43:55 -07:00
..
acpi
asm-generic Revert "Merge remote-tracking branch 'msm-4.4/tmp-510d0a3f' into msm-4.4" 2016-08-26 14:34:05 -07:00
clocksource
crypto crypto: ice: split the config callback 2016-04-25 17:45:49 -07:00
drm Revert "Merge remote-tracking branch 'msm-4.4/tmp-510d0a3f' into msm-4.4" 2016-08-26 14:34:05 -07:00
dt-bindings clk: qcom: Add support for the turing vote clocks 2016-10-13 09:13:31 +05:30
keys
kvm
linux sched: Add per CPU load tracking for each task 2016-10-17 12:43:53 -07:00
math-emu
media msm: camera: Add a driver to control IR CUT device 2016-09-16 10:29:29 -07:00
memory
misc
net net: cnss: Add support to get fw files for QCA SDIO target 2016-09-27 00:13:45 -07:00
pcmcia
ras
rdma Revert "Merge remote-tracking branch 'msm-4.4/tmp-510d0a3f' into msm-4.4" 2016-08-26 14:34:05 -07:00
rxrpc
scsi
soc soc: qcom: smem: Update CDSP processor ID 2016-10-13 17:10:19 +05:30
sound ASoC: wcd-dsp-mgr: handle codec down and up events 2016-10-11 15:38:32 -07:00
target
trace sched: Add the mechanics of top task tracking for frequency guidance 2016-10-17 12:43:55 -07:00
uapi Merge "uapi: sound: add new ready packet type" 2016-10-07 12:20:01 -07:00
video Merge branch 'mdss-final-replay' into msm-4.4 2016-04-12 15:49:34 -07:00
xen Revert "Merge remote-tracking branch 'msm-4.4/tmp-510d0a3f' into msm-4.4" 2016-08-26 14:34:05 -07:00
Kbuild