sched: Fix sleep time double accounting in enqueue entity

The woken migrated task will __synchronize_entity_decay(se); in
migrate_task_rq_fair, then it needs to set
`se->avg.last_runnable_update -= (-se->avg.decay_count) << 20' before
update_entity_load_avg, in order to avoid sleep time is updated twice
for se.avg.load_avg_contrib in both __syncchronize and
update_entity_load_avg.

However if the sleeping task is woken up from the same cpu, it miss
the last_runnable_update before update_entity_load_avg(se, 0, 1), then
the sleep time was used twice in both functions.  So we need to remove
the double sleep time accounting.

Paul also contributed some code comments in this commit.

Signed-off-by: Alex Shi <alex.shi@intel.com>
Reviewed-by: Paul Turner <pjt@google.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1371694737-29336-5-git-send-email-alex.shi@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Revert "Merge branch 'arm-topology' into axdev-4.4"

Revert topology changes from deprecated branch; in an effort to use linaro's
topology/power driver implementation. May revisit some changes.

This reverts commit 79a73fb0e309c404f56a7b4a785b7eedf961e992, reversing
changes made to 73c62a1e71d324afb945ca6ee4f4a9df3cdef3cc.
ARM: topology: save cpu id of each core
ARM: topology: Update topology according to current sched_mc mode

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
ARM: topology: Add a cpu_power function
ARM: topology: Add a topology update notification
ARM: cpu topology: Add asym topology flag for using cpu0 1st

Modify the CPU sched_domain flags in powersave mode for using the cpu0 in ched_mc powersave mode

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
ARM: cpu topology: add debugfs
cpupower: Import Linaro topology cpupower driver for Cortex-A9

This driver updates the capacity of each core according to current
sched_mc level and cpu frequency (in fact current cpu load)

When the lowest frequencies are used, we are in a light load use case
and we increase the cpu capacity to keep these light tasks on CPU0

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
sched: use cpu capacity to decide if a ILB is needed

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
ARM: cpu topology: Enable ARCH_POWER

Conflicts:

	kernel/sched_features.h

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
ARM: M2: Initial cpu_power platform config

Based on Snowball's config used in Linaro (another 2x core Cortex-A9 device,
by the looks of it as well)

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
xsched: Optimize build_sched_domains() for saving first SD node for a cpu

Backport:

We are saving first scheduling domain for a cpu in build_sched_domains() by
iterating over the nested sd->child list. We don't actually need to do it this
way.

tl will be equal to sched_domain_topology for the first iteration and so we can
set *per_cpu_ptr(d.sd, i) based on that.  So, save pointer to first SD while
running the iteration loop over tl's.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/fc473527cbc4dfa0b8eeef2a59db74684eb59a83.1370436120.git.viresh.kumar@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Luis Cruz <ljc2491@gmail.com>
sched: Create for_each_sd_topology()

Backport:

For loop for traversing sched_domain_topology was used at multiple placed in
core.c. This patch removes code redundancy by creating for_each_sd_topology().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/e0e04542f54e9464bd9da54f5ccfe62ec6c4c0bc.1370861520.git.viresh.kumar@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Luis Cruz <ljc2491@gmail.com>
sched: Fix memory leakage in build_sched_groups()

In build_sched_groups() we don't need to call get_group() for cpus
which are already covered in previous iterations. Calling get_group()
would mark the group used and eventually leak it since we wouldn't
connect it and not find it again to free it.

This will happen only in cases where sg->cpumask contained more than
one cpu (For any topology level). This patch would free sg's memory
for all cpus leaving the group leader as the group isn't marked used
now.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/7a61e955abdcbb1dfa9fe493f11a5ec53a11ddd3.1370948150.git.viresh.kumar@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
d2: defconfig: Enable cpu power driver

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
Merge branch 'arm-topology2' into axdev-4.4
Makefile: Optimize for Krait a bit more

Since Krait seems to have started out Cortex-A9, but ended up resembling
A15 more; let's try optimizing for A15, while using A9 topology.
Krait also supports vfpv4. Let's go back to using that again.

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
Revert "d2: defconfig: Enable power efficient workqueues by default"

After some runtime and testing, this seems to do more harm than good
to our dual core devices in terms of power efficiency. I can see how this
would be very beneficial on a device with more cores though. So I'll just
ref this on another branch; just in case I end up with a cool new gadget
in the near future.

This reverts commit 0aa7b4fe75993424f4f3e2cde8c3d10b8a63dc5f.

Signed-off-by: Luis Cruz <ljc2491@gmail.com>