firefly-linux-kernel-4.4.55.git
10 years agoMerge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big...
Mark Brown [Wed, 7 May 2014 13:52:11 +0000 (14:52 +0100)]
Merge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big.LITTLE

10 years agosched: hmp: Change small task packing defaults for all platforms
Chris Redpath [Tue, 6 May 2014 18:46:50 +0000 (19:46 +0100)]
sched: hmp: Change small task packing defaults for all platforms

All platforms other than TC2 default to enabling packing. Since TC2
shows no performance or energy degradation with this feature enabled
make it default enabled the same as everyone else.
Likewise, vendors have been including TC2 support in multi-machine
kernel builds so they expect the default thresholds to remain the
same when the TC2 #ifdef is removed.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoMerge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big...
Mark Brown [Tue, 8 Apr 2014 17:45:58 +0000 (18:45 +0100)]
Merge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big.LITTLE

10 years agoRevert "hmp: sched: Clean up hmp_up_threshold checks into a utility fn"
Jon Medhurst [Tue, 8 Apr 2014 15:43:25 +0000 (16:43 +0100)]
Revert "hmp: sched: Clean up hmp_up_threshold checks into a utility fn"

This reverts commit 765aae26e6e296333c3a5f7a02360f5389dc439a.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoRevert "sched: hmp: unify active migration code"
Jon Medhurst [Tue, 8 Apr 2014 15:43:24 +0000 (16:43 +0100)]
Revert "sched: hmp: unify active migration code"

This reverts commit 0baa5811bacf15b0e76ee85ce29fedffb5136313.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoRevert "hmp: Use idle pull to perform forced up-migrations"
Jon Medhurst [Tue, 8 Apr 2014 15:43:23 +0000 (16:43 +0100)]
Revert "hmp: Use idle pull to perform forced up-migrations"

This reverts commit aae7721f20f2520d24a149408a74f18e58f56472.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoRevert "hmp: dont attempt to pull tasks if affinity doesn't allow it"
Jon Medhurst [Tue, 8 Apr 2014 15:43:19 +0000 (16:43 +0100)]
Revert "hmp: dont attempt to pull tasks if affinity doesn't allow it"

This reverts commit 5a570cfc01b06906faa8ac67ad7c0c6f278761c4.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agohmp: dont attempt to pull tasks if affinity doesn't allow it
Chris Redpath [Mon, 24 Mar 2014 13:47:30 +0000 (13:47 +0000)]
hmp: dont attempt to pull tasks if affinity doesn't allow it

When looking for a task to be idle-pulled, don't consider tasks
where the affinity does not allow that task to be placed on the
target CPU. Also ensure that tasks with restricted affinity
do not block selecting other unrestricted busy tasks.

Use the knowledge of target CPU more effectively in idle pull
by passing to hmp_get_heaviest_task when we know it, otherwise
only checking for general affinity matches with any of the CPUs
in the bigger HMP domain.

We still need to explicitly check affinity is allowed in idle pull
since if we find no match in hmp_get_heaviest_task we will return
the current one, which may not be affine to the new CPU despite
having high enough load. In this case, there is nothing to move.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agohmp: Use idle pull to perform forced up-migrations
Chris Redpath [Mon, 24 Mar 2014 13:47:29 +0000 (13:47 +0000)]
hmp: Use idle pull to perform forced up-migrations

When a normal forced up-migration takes place we stop the task to
be migrated while the target CPU becomes available. This delay can
range from 80us to 1500us on TC2 if the target CPU is in a deep idle
state.

Instead, interrupt the target CPU and ask it to pull a task.
This lets the current eligible task continue executing on the
original CPU while the target CPU wakes. Use a pinned timer to
prevent the pulling CPU going back into power-down with pending
up-migrations.

If we trigger for a nohz kick, it doesn't matter about triggering
for an idle pull since the idle_pull flag will be set when we
execute the softirq and we'll still do the idle pull.

If the target CPU is busy, we will not pull any tasks.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: hmp: unify active migration code
Chris Redpath [Mon, 24 Mar 2014 13:47:28 +0000 (13:47 +0000)]
sched: hmp: unify active migration code

The HMP active migration code is functionally identical to the CFS
active migration code apart from one flag check. Share the code
and make the flag check optional.

Two wrapper functions allow the flag check to be present or not.

Thanks to tixy@linaro.org for pointing out the build break and a
good solution in an earlier version.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agohmp: sched: Clean up hmp_up_threshold checks into a utility fn
Chris Redpath [Mon, 24 Mar 2014 13:47:27 +0000 (13:47 +0000)]
hmp: sched: Clean up hmp_up_threshold checks into a utility fn

In anticipation of modifying the up_threshold handling, make all
instances use the same utility fn to check if a task is eligible
for up-migration. This also removes the previous difference in
threshold comparison where up-migration used '!<threshold' and
idle pull used '>threshold' to decide up-migration eligibility.
Make them both use '!<threshold' instead for consistency, although
this is unlikely to change any results.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoMerge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big...
Mark Brown [Wed, 22 Jan 2014 12:33:23 +0000 (12:33 +0000)]
Merge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big.LITTLE

Conflicts:
kernel/irq/irqdesc.c
linaro/configs/big-LITTLE-MP.conf

10 years agoHMP: Drop "sched: Fix sleep time double accounting in enqueue entity"
Mark Brown [Wed, 22 Jan 2014 11:18:53 +0000 (11:18 +0000)]
HMP: Drop "sched: Fix sleep time double accounting in enqueue entity"

This reverts commit f0862cb749c537c32de82912d30110098ddc6cd6.  Analysis
from Vincent Guittot:

With the current implementation, the load average statistics of a sched entity
change according to other activity on the CPU even if this activity is done
between the running window of the sched entity and have no influence on the
running duration of the task.

When a task wakes up on the same CPU, we currently update last_runnable_update
with the return  of __synchronize_entity_decay without updating the
runnable_avg_sum and runnable_avg_period accordingly. In fact, we have to sync
the load_contrib of the se with the rq's blocked_load_contrib before removing
it from the latter (with __synchronize_entity_decay) but we must keep
last_runnable_update unchanged for updating runnable_avg_sum/period during the
next update_entity_load_avg.

Signed-off-by: Mark Brown <broonie@linaro.org>
10 years agoHMP: Fix rt task allowed cpu mask restriction code on 1x1 system
Dietmar Eggemann [Thu, 16 Jan 2014 11:53:14 +0000 (11:53 +0000)]
HMP: Fix rt task allowed cpu mask restriction code on 1x1 system

There is an error scenario where on a 1x1 HMP system (weight of the
hmp_slow_cpu_mask is 1) the short-cut of restricting the allowed cpu mask
of an rt tasks leads to triggering a kernel bug in the rt sched class
set_cpus_allowed function set_cpus_allowed_rt().

In case the task is on the run-queue and the weight of the required cpu mask
is 1 and this is different to the p->nr_cpus_allowed value, this back-end
function interprets this in such a way that a task changed from being
migratable to not migratable anymore and decrements the rt_nr_migratory
counter.  There is a BUG_ON(!rq->rt.rt_nr_migratory) check in this code
path which triggers in this situation.

To circumvent this issue, set the number of allowed cpus for a task p to
the weight of the hmp_slow_cpu_mask before calling do_set_cpus_allowed()
in __setscheduler(). It will be set to this value in do_set_cpus_allowed()
after the call to the sched class related backend function any way.  By
doing this, set_cpus_allowed_rt() returns without trying to update the
rt_nr_migratory counter.

This patch has been tested with a test device driver requiring a threaded
irq handler on a TC2 system with a reduced cpu mask (1 Cortex A15, 1
Cortex A7).

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Restrict irq_default_affinity to hmp_slow_cpu_mask
Dietmar Eggemann [Thu, 16 Jan 2014 19:44:10 +0000 (19:44 +0000)]
HMP: Restrict irq_default_affinity to hmp_slow_cpu_mask

This patch limits the default affinity mask for all irqs to the cluster of
the little cpus.

This patch has the positive side effect that an irq thread which has its
IRQTF_RUNTHREAD set inside irq_thread() -> irq_wait_for_interrupt() will
not overwrite its struct task_struct->cpus_allowed with a full cpu mask of
desc->irq_data.affinity in irq_thread_check_affinity() essentially reverting
patch "HMP: experimental: Force all rt tasks to start on little domain."
for this irq thread.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: hmp: Fix potential task_struct memory leak
Chris Redpath [Fri, 10 Jan 2014 10:34:08 +0000 (10:34 +0000)]
sched: hmp: Fix potential task_struct memory leak

We use get_task_struct to increment the ref count on a task_struct
so that even if the task dies with a pending migration we are still
able to read the memory without causing a fault.

In the case of non-running tasks, we forgot to decrement the ref
count when we are done with the task.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoconfig: Make packing present on TC2
Chris Redpath [Thu, 9 Jan 2014 10:41:13 +0000 (10:41 +0000)]
config: Make packing present on TC2

The scheduler will default packing to disabled, but this includes the
feature so that we can test it more easily.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: hmp: Change TC2 packing config to disabled default if present
Chris Redpath [Thu, 9 Jan 2014 10:40:30 +0000 (10:40 +0000)]
sched: hmp: Change TC2 packing config to disabled default if present

Since TC2 power curves don't really have a utilisation hotspot where
packing makes sense, if it is present for a TC2 system at least make
it default to disabled.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: hmp: Make idle balance behaviour normal when packing disabled
Chris Redpath [Thu, 9 Jan 2014 10:38:54 +0000 (10:38 +0000)]
sched: hmp: Make idle balance behaviour normal when packing disabled

The presence of packing permanently changed the idle balance
behaviour. Do not restrict idle balance on the smallest CPUs when
packing is present but disabled.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: update runqueue clock before migrations away
Chris Redpath [Thu, 5 Dec 2013 17:57:46 +0000 (17:57 +0000)]
sched: update runqueue clock before migrations away

If we migrate a sleeping task away from a CPU which has the
tick stopped, then both the clock_task and decay_counter will
be out of date for that CPU and we will not decay load correctly
regardless of how often we update the blocked load.

This is only an issue for tasks which are not on a runqueue
(because otherwise that CPU would be awake) and simultaneously
the CPU the task previously ran on has had the tick stopped.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: reset blocked load decay_count during synchronization
Chris Redpath [Thu, 5 Dec 2013 15:49:32 +0000 (15:49 +0000)]
sched: reset blocked load decay_count during synchronization

If an entity happens to sleep for less than one tick duration
the tracked load associated with that entity can be decayed by an
unexpectedly large amount if it is later migrated to a different
CPU. This can interfere with correct scheduling when entity load
is used for decision making.

The reason for this is that when an entity is dequeued and enqueued
quickly, such that se.avg.decay_count and cfs_rq.decay_counter
do not differ when that entity is enqueued again,
__synchronize_entity_decay skips the calculation step and also skips
clearing the decay_count. At a later time that entity may be
migrated and its load will be decayed incorrectly.

All users of this function expect decay_count to be zero'ed after
use.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agogenirq: Add default affinity mask command line option
Thomas Gleixner [Fri, 25 May 2012 14:59:47 +0000 (16:59 +0200)]
genirq: Add default affinity mask command line option

If we isolate CPUs, then we don't want random device interrupts on
them. Even w/o the user space irq balancer enabled we can end up with
irqs on non boot cpus.

Allow to restrict the default irq affinity mask.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoconfig: Add config fragments for big LITTLE MP
Jon Medhurst [Tue, 21 Jan 2014 09:48:55 +0000 (09:48 +0000)]
config: Add config fragments for big LITTLE MP

This patch adds config fragments used to enable most of the features
used by big LITTLE MP.

This patch is the result of merging the following commits from the
Linaro Stable Kernel (LSK) 3.10 tree...

Commit 313c69010ed52a7bd52095708049e16c380c8e15
Commit 83952e566d1c41b2e0a70321e9d56cb8162f9a6d
Commit c4a782d985da03016e2b15aaef90bfc5cfe426f6
Commit 2732b0467a356e7cc08bf1e0f33481330335657a
Commit 7c88e2bd50fc093c96c912090b712b682ae72641
Commit 3231c8ce4b005f79ad27309907adc3de319e341c

Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched/debug: Add load-tracking statistics to task
Kamalesh Babulal [Tue, 25 Jun 2013 08:03:36 +0000 (13:33 +0530)]
sched/debug: Add load-tracking statistics to task

At present we print per-entity load-tracking statistics for
cfs_rq of cgroups/runqueues. Given that per task statistics
is maintained, it can be used to know the contribution made
by the task to its parenting cfs_rq level.

This patch adds per-task load-tracking statistics to /proc/<PID>/sched.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20130625080336.GA20175@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from commit 939fd731eb88a0cdd9058d0b0143563172a217d7)

Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched/debug: Add load-tracking statistics to task
Kamalesh Babulal [Tue, 25 Jun 2013 08:03:36 +0000 (13:33 +0530)]
sched/debug: Add load-tracking statistics to task

At present we print per-entity load-tracking statistics for
cfs_rq of cgroups/runqueues. Given that per task statistics
is maintained, it can be used to know the contribution made
by the task to its parenting cfs_rq level.

This patch adds per-task load-tracking statistics to /proc/<PID>/sched.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20130625080336.GA20175@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
10 years agosched: Fix sleep time double accounting in enqueue entity
Alex Shi [Thu, 20 Jun 2013 02:18:48 +0000 (10:18 +0800)]
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>
10 years agosched: hmp: Fix build breakage when not using CONFIG_SCHED_HMP
Chris Redpath [Fri, 22 Nov 2013 13:19:18 +0000 (13:19 +0000)]
sched: hmp: Fix build breakage when not using CONFIG_SCHED_HMP

hmp_variable_scale_convert was used without guards in
__update_entity_runnable_avg. Guard it.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: hmp: Fix build breakage when not using CONFIG_SCHED_HMP
Chris Redpath [Fri, 22 Nov 2013 13:19:18 +0000 (13:19 +0000)]
sched: hmp: Fix build breakage when not using CONFIG_SCHED_HMP

hmp_variable_scale_convert was used without guards in
__update_entity_runnable_avg. Guard it.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
10 years agoMerge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big...
Mark Brown [Thu, 21 Nov 2013 11:58:31 +0000 (11:58 +0000)]
Merge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big.LITTLE

10 years agoDocumentation: HMP: Small Task Packing explanation
Chris Redpath [Wed, 20 Nov 2013 14:14:44 +0000 (14:14 +0000)]
Documentation: HMP: Small Task Packing explanation

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: hmp: add read-only hmp domain sysfs file
Chris Redpath [Mon, 11 Nov 2013 16:29:29 +0000 (16:29 +0000)]
sched: hmp: add read-only hmp domain sysfs file

In order to allow userspace to restrict known low-load tasks to
little CPUs, we must export this knowledge from the kernel or
expect userspace to make their own attempts at figuring it out.

Since we now have a userspace requirement for an HMP implementation
to always have at least some sysfs files, change the integration
so that it only depends upon CONFIG_SCHED_HMP rather than
CONFIG_HMP_VARIABLE_SCALE. Fix Kconfig text to match.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Avoid using the cpu stopper to stop runnable tasks
Mathieu Poirier [Wed, 20 Nov 2013 14:20:42 +0000 (14:20 +0000)]
HMP: Avoid using the cpu stopper to stop runnable tasks

When migrating a runnable task, we use the CPU stopper on
the source CPU to ensure that the task to be moved is not
currently running. Before this patch, all forced migrations
(up, offload, idle pull) use the stopper for every migration.

Using the CPU stopper is mandatory only when a task is currently
running on a CPU.  Otherwise tasks can be moved by locking the
source and destination run queues.

This patch checks to see if the task to be moved are currently
running.  If not the task is moved directly without using the
stopper thread.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoarm64: Fix build due to HMP tracepoints
Mark Brown [Mon, 14 Oct 2013 12:37:36 +0000 (13:37 +0100)]
arm64: Fix build due to HMP tracepoints

Commit 2353c1f800 (arm: ipi raise/start/end tracing) added tracepoints for
IPIs in the generic GIC driver but only added definitions for them on ARM,
causing build failures on ARM64. Fix this by adding equivalent definitions
for arm64.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>
10 years agosmp: Don't use typedef to work around compiler issue with tracepoints
Mark Brown [Mon, 14 Oct 2013 11:38:19 +0000 (12:38 +0100)]
smp: Don't use typedef to work around compiler issue with tracepoints

Having the typedef in place for the tracepoints causes compiler crashes
in some situations.  Just using void * directly avoids triggering the
issue and should have no effect on the trace.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>
10 years agoarm64: Fix build due to HMP tracepoints
Mark Brown [Mon, 14 Oct 2013 12:37:36 +0000 (13:37 +0100)]
arm64: Fix build due to HMP tracepoints

Commit 2353c1f800 (arm: ipi raise/start/end tracing) added tracepoints for
IPIs in the generic GIC driver but only added definitions for them on ARM,
causing build failures on ARM64. Fix this by adding equivalent definitions
for arm64.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>
10 years agosmp: Don't use typedef to work around compiler issue with tracepoints
Mark Brown [Mon, 14 Oct 2013 11:38:19 +0000 (12:38 +0100)]
smp: Don't use typedef to work around compiler issue with tracepoints

Having the typedef in place for the tracepoints causes compiler crashes
in some situations.  Just using void * directly avoids triggering the
issue and should have no effect on the trace.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>
10 years agoMerge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big...
Mark Brown [Fri, 11 Oct 2013 18:25:24 +0000 (19:25 +0100)]
Merge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big.LITTLE

10 years agoMerge tag 'big-LITTLE-MP-13.10' into for-lsk
Jon Medhurst [Fri, 11 Oct 2013 16:12:02 +0000 (17:12 +0100)]
Merge tag 'big-LITTLE-MP-13.10' into for-lsk

10 years agoHMP: Implement task packing for small tasks in HMP systems
Chris Redpath [Fri, 11 Oct 2013 10:45:04 +0000 (11:45 +0100)]
HMP: Implement task packing for small tasks in HMP systems

If we wake up a task on a little CPU, fill CPUs rather than
spread. Adds 2 new files to sys/kernel/hmp to control packing
behaviour.

packing_enable: task packing enabled (1) or disabled (0)
packing_limit: Runqueues will be filled up to this load ratio.

This functionality is disabled by default on TC2 as it lacks per-cpu
power gating so packing small tasks there doesn't make sense.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agohmp: Remove potential for task_struct access race
Chris Redpath [Fri, 11 Oct 2013 10:45:03 +0000 (11:45 +0100)]
hmp: Remove potential for task_struct access race

Accessing the task_struct can be racy in certain conditions, so
we need to only acquire the data when needed.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: HMP: fix potential logical errors
Chris Redpath [Fri, 11 Oct 2013 10:45:02 +0000 (11:45 +0100)]
sched: HMP: fix potential logical errors

The previous API for hmp_up_migration reset the destination
CPU every time, regardless of if a migration was desired. The code
using it assumed that the value would not be changed unless
a migration was required. In one rare circumstance, this could
have lead to a task migrating to a little CPU at the wrong time.

Fixing that lead to a slight logical tweak to make the surrounding
APIs operate a bit more obviously.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Robin Randhawa <robin.randhawa@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosmp: smp_cross_call function pointer tracing
Chris Redpath [Fri, 11 Oct 2013 10:45:01 +0000 (11:45 +0100)]
smp: smp_cross_call function pointer tracing

generic tracing for smp_cross_call function calls

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoarm: ipi raise/start/end tracing
Chris Redpath [Fri, 11 Oct 2013 10:45:00 +0000 (11:45 +0100)]
arm: ipi raise/start/end tracing

Add tracepoints for IPI raise events, and start and end of the
ipi handler.

Used to inspect the source of CPU wake-ups which are not already
traced - all other reasons for a CPU to wake-up are already
covered.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: HMP: Additional trace points for debugging HMP behaviour
Chris Redpath [Fri, 11 Oct 2013 10:44:59 +0000 (11:44 +0100)]
sched: HMP: Additional trace points for debugging HMP behaviour

1. Replace magic numbers in code for migration trace.
   Trace points still emit a number as force=<n> field:
     force=0 : wakeup migration
     force=1 : forced migration
     force=2 : offload migration
     force=3 : idle pull migration

2. Add trace to expose offload decision-making.
   Also adds tracing rq->nr_running so that you can
   look back to see what state the RQ was in at the time.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: HMP: Change default HMP thresholds
Chris Redpath [Fri, 11 Oct 2013 10:44:58 +0000 (11:44 +0100)]
sched: HMP: Change default HMP thresholds

When the up-threshold is at 512 on TC2, behaviour looks OK since
the graphic-related tasks are very heavy due to lack of a GPU.
Increasing the up-threshold does not reduce power consumption.

When a GPU is present, graphic tasks are much less CPU-heavy and
so additional power may be saved by having a higher threshold.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoMerge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big...
Mark Brown [Tue, 10 Sep 2013 09:51:00 +0000 (10:51 +0100)]
Merge branch 'for-lsk' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big.LITTLE

10 years agoMerge tag 'big-LITTLE-MP-13.08' into for-lsk
Jon Medhurst [Thu, 5 Sep 2013 17:17:48 +0000 (18:17 +0100)]
Merge tag 'big-LITTLE-MP-13.08' into for-lsk

This merge is intended to tidyup the history of the big.LITTLE MP
patchset to enable ongoing maintenance of a standalone MP branch.

The only code change introduce by this merge is to add commit
0d5ddd14 (HMP: select 'best' task for migration rather than 'current')
This change is already in the Linaro Stable Kernel as commit
c5021c1eb9c73f38209180c65bd074ac70c97587

10 years agoHMP: Update migration timer when we fork-migrate
Chris Redpath [Tue, 23 Jul 2013 13:56:45 +0000 (14:56 +0100)]
HMP: Update migration timer when we fork-migrate

Prevents fork-migration adversely interacting with normal
migration (i.e. runqueues containing forked tasks being
selected as migration targets when there is a better
choice available)

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Access runqueue task clocks directly.
Chris Redpath [Mon, 22 Jul 2013 14:56:28 +0000 (15:56 +0100)]
HMP: Access runqueue task clocks directly.

Avoids accesses through cfs_rq going bad when the cpu_rq doesn't
have a cfs member.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Implement idle pull for HMP
Chris Redpath [Thu, 8 Aug 2013 15:41:26 +0000 (16:41 +0100)]
HMP: Implement idle pull for HMP

When an A15 goes idle, we should up-migrate anything which is
above the threshold and running on an A7.

Reuses the HMP force-migration spinlock, but adds its own new
cpu stopper client.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: HMP change nr_running offload metric
Chris Redpath [Thu, 8 Aug 2013 15:10:39 +0000 (16:10 +0100)]
sched: HMP change nr_running offload metric

rq->nr_running was better than cfs.nr_running, since it includes
all tasks actually on the CPU. However, it includes RT tasks which
we would rather ignore at this point.

Switching to cfs.h_nr_running includes all the CFS tasks but no
RT tasks.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Explicitly implement all-load-is-max-load policy for HMP targets
Chris Redpath [Mon, 15 Jul 2013 15:06:44 +0000 (16:06 +0100)]
HMP: Explicitly implement all-load-is-max-load policy for HMP targets

Experimentally, one of the best policies for HMP migration CPU
selection is to completely ignore part-loaded CPUs and only look
for idle ones. If there are no idle ones, we will choose the one
which was least-recently-disturbed.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Modify the runqueue stats to add a new child stat
Chris Redpath [Thu, 8 Aug 2013 15:32:31 +0000 (16:32 +0100)]
HMP: Modify the runqueue stats to add a new child stat

The original intent here was to track unweighted runqueue load
with less resolution so we could use the least-recently-disturbed
runqueue to choose between 'closely related' load levels.

However, after experimenting with the resolution it turns out
that the following algorithm is highly beneficial for mobile
workloads.

In hmp_domain_min_load:

  * If any CPU is zero, the overall load is zero
  * If no CPUs are idle, the domain is 'fully loaded'

Additionally, the time since last migration count is used to
discriminate between idle CPUs.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: track per-rq 'last migration time'
Chris Redpath [Thu, 8 Aug 2013 15:31:07 +0000 (16:31 +0100)]
sched: track per-rq 'last migration time'

Track when migrations were performed to runqueues.

Use this to decide between runqueues as migration targets when run
queues in an hmp domain have equal load.

Intention is to spread migration load amongst CPUs more fairly.

When all CPUs in an hmp domain are fully loaded, the existing code
always selects the last CPU as a migration target - this is unfair
and little better than doing no selection.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: HMP fix traversing the rb-tree from the curr pointer
Morten Rasmussen [Tue, 6 Aug 2013 15:14:19 +0000 (16:14 +0100)]
sched: HMP fix traversing the rb-tree from the curr pointer

The hmp_get_{lightest,heaviest}_task() need to use
__pick_first_entity() to get a pointer to a sched_entity on the rq.
The current is not kept on the rq while running, so its rb-tree node
pointers are no longer valid.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: select 'best' task for migration rather than 'current'
Chris Redpath [Thu, 8 Aug 2013 15:27:34 +0000 (16:27 +0100)]
HMP: select 'best' task for migration rather than 'current'

When we are looking for a task to migrate up, select the heaviest
one in the first 5 runnable on the runqueue.

Likewise, when looking for a task to offload, select the lightest
one in the first 5 runnable on the runqueue.

Ensure task selected is runnable in the target domain.

This change is necessary in order to implement idle pull in a
sensible manner, but here is used in up-migration and offload to
select the correct target task.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Check the system has little cpus before forcing rt tasks onto them
Jon Medhurst (Tixy) [Fri, 2 Aug 2013 17:45:33 +0000 (18:45 +0100)]
HMP: Check the system has little cpus before forcing rt tasks onto them

It is sometimes desirable to run a kernel with HMP scheduling enabled
on a system which is not big.LITTLE, e.g. when building a multi-platform
kernel, or when testing a big.LITTLE system with one cluster disabled.

We should therefore allow for the situation where is no little domain.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
10 years agoMerge branch 'master' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big...
Mark Brown [Tue, 20 Aug 2013 09:46:40 +0000 (10:46 +0100)]
Merge branch 'master' of git://git.linaro.org/arm/big.LITTLE/mp into lsk-v3.10-big.LITTLE

10 years agoHMP: Update migration timer when we fork-migrate
Chris Redpath [Mon, 19 Aug 2013 14:06:23 +0000 (15:06 +0100)]
HMP: Update migration timer when we fork-migrate

Prevents fork-migration adversely interacting with normal
migration (i.e. runqueues containing forked tasks being
selected as migration targets when there is a better
choice available)

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Access runqueue task clocks directly.
Chris Redpath [Mon, 19 Aug 2013 14:06:22 +0000 (15:06 +0100)]
HMP: Access runqueue task clocks directly.

Avoids accesses through cfs_rq going bad when the cpu_rq doesn't
have a cfs member.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Implement idle pull for HMP
Chris Redpath [Mon, 19 Aug 2013 14:06:21 +0000 (15:06 +0100)]
HMP: Implement idle pull for HMP

When an A15 goes idle, we should up-migrate anything which is
above the threshold and running on an A7.

Reuses the HMP force-migration spinlock, but adds its own new
cpu stopper client.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: HMP change nr_running offload metric
Chris Redpath [Mon, 19 Aug 2013 14:06:20 +0000 (15:06 +0100)]
sched: HMP change nr_running offload metric

rq->nr_running was better than cfs.nr_running, since it includes
all tasks actually on the CPU. However, it includes RT tasks which
we would rather ignore at this point.

Switching to cfs.h_nr_running includes all the CFS tasks but no
RT tasks.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Explicitly implement all-load-is-max-load policy for HMP targets
Chris Redpath [Mon, 19 Aug 2013 14:06:19 +0000 (15:06 +0100)]
HMP: Explicitly implement all-load-is-max-load policy for HMP targets

Experimentally, one of the best policies for HMP migration CPU
selection is to completely ignore part-loaded CPUs and only look
for idle ones. If there are no idle ones, we will choose the one
which was least-recently-disturbed.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Modify the runqueue stats to add a new child stat
Chris Redpath [Mon, 19 Aug 2013 14:06:18 +0000 (15:06 +0100)]
HMP: Modify the runqueue stats to add a new child stat

The original intent here was to track unweighted runqueue load
with less resolution so we could use the least-recently-disturbed
runqueue to choose between 'closely related' load levels.

However, after experimenting with the resolution it turns out
that the following algorithm is highly beneficial for mobile
workloads.

In hmp_domain_min_load:

  * If any CPU is zero, the overall load is zero
  * If no CPUs are idle, the domain is 'fully loaded'

Additionally, the time since last migration count is used to
discriminate between idle CPUs.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: track per-rq 'last migration time'
Chris Redpath [Mon, 19 Aug 2013 14:06:17 +0000 (15:06 +0100)]
sched: track per-rq 'last migration time'

Track when migrations were performed to runqueues.

Use this to decide between runqueues as migration targets when run
queues in an hmp domain have equal load.

Intention is to spread migration load amongst CPUs more fairly.

When all CPUs in an hmp domain are fully loaded, the existing code
always selects the last CPU as a migration target - this is unfair
and little better than doing no selection.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: HMP fix traversing the rb-tree from the curr pointer
Morten Rasmussen [Mon, 19 Aug 2013 14:06:16 +0000 (15:06 +0100)]
sched: HMP fix traversing the rb-tree from the curr pointer

The hmp_get_{lightest,heaviest}_task() need to use
__pick_first_entity() to get a pointer to a sched_entity on the rq.
The current is not kept on the rq while running, so its rb-tree node
pointers are no longer valid.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: select 'best' task for migration rather than 'current'
Chris Redpath [Mon, 19 Aug 2013 14:06:15 +0000 (15:06 +0100)]
HMP: select 'best' task for migration rather than 'current'

When we are looking for a task to migrate up, select the heaviest
one in the first 5 runnable on the runqueue.

Likewise, when looking for a task to offload, select the lightest
one in the first 5 runnable on the runqueue.

Ensure task selected is runnable in the target domain.

This change is necessary in order to implement idle pull in a
sensible manner, but here is used in up-migration and offload to
select the correct target task.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agoHMP: Check the system has little cpus before forcing rt tasks onto them
Jon Medhurst (Tixy) [Fri, 2 Aug 2013 17:45:33 +0000 (18:45 +0100)]
HMP: Check the system has little cpus before forcing rt tasks onto them

It is sometimes desirable to run a kernel with HMP scheduling enabled
on a system which is not big.LITTLE, e.g. when building a multi-platform
kernel, or when testing a big.LITTLE system with one cluster disabled.

We should therefore allow for the situation where is no little domain.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
10 years agoMerge branches 'master-arm-multi_pmu_v2', 'master-config-fragments', 'master-hw-bkpt...
Jon Medhurst [Thu, 18 Jul 2013 10:49:27 +0000 (11:49 +0100)]
Merge branches 'master-arm-multi_pmu_v2', 'master-config-fragments', 'master-hw-bkpt-fix', 'master-misc-patches' and 'master-task-placement-v2-updates' into big-LITTLE-MP-master-v19

Updates:
 -------
 - Rebased over 3.10 final
 - Differences from big-LITTLE-MP-master-v18
   - New Patches:
     - master-config-fragments: 1 new patch
       - "config: Disable priority filtering for HMP Scheduler"
     - master-misc-patches: 1 new patch
       - "mm: make vmstat_update periodic run conditional"
   - New Branches:
     - master-task-placement-v2-updates: 7 patches
       New patches from ARM added in a new topic branch stacked on top
       of master-task-placement-v2-sysfs...
       - Revert "sched: Enable HMP priority filter by default"
       - "HMP: Use unweighted load for hmp migration decisions"
       - "HMP: Select least-loaded CPU when performing HMP Migrations"
       - "HMP: Avoid multiple calls to hmp_domain_min_load in fast path"
       - "HMP: Force new non-kernel tasks onto big CPUs until load stabilises"
       - "sched: Restrict nohz balance kicks to stay in the HMP domain"
       - "HMP: experimental: Force all rt tasks to start on little domain."

 Commands used for merge:
 -----------------------
 $ git checkout -b big-LITTLE-MP-master-v19 v3.10
 $ git merge master-arm-multi_pmu_v2 master-config-fragments \
     master-hw-bkpt-fix master-misc-patches master-task-placement-v2 \
     master-task-placement-v2-sysfs master-task-placement-v2-updates

10 years agoHMP: experimental: Force all rt tasks to start on little domain.
Dietmar Eggemann [Fri, 21 Jun 2013 16:50:08 +0000 (17:50 +0100)]
HMP: experimental: Force all rt tasks to start on little domain.

This patch restricts the allowed cpu mask for rt tasks initially started
with a full cpu mask to the little domain.

An rt task is specified as real time in __setscheduler() which is finally
called for all rt tasks (kernel and user land). In this function we
restrict the allowed cpu mask to the little domain.

This also prevents that a rt tasks can later be pushed to the big domain
because the function find_lowest_rq() will only recognize the allowed cpu
mask of a task to find the new cpu the task runs on.

Current kludges of the patch:

* Since we do not have an API to get the cpu mask of the A7 cluster,
hmp_slow_cpu_mask is made global in arm/kernel/topology.c for now.

* The watchdog_enable() function calls sched_setscheduler() before
kthread_bind() for the cpu specific watchdog kernel threads. The order of
these two calls has to be changed to make this patch work.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
10 years agosched: Restrict nohz balance kicks to stay in the HMP domain
Chris Redpath [Mon, 17 Jun 2013 15:20:37 +0000 (16:20 +0100)]
sched: Restrict nohz balance kicks to stay in the HMP domain

There is little point in doing a nohz balance kick on a CPU from a
different HMP domain, since the unset SD_LOAD_BALANCE flag on the CPU
domain level prevents tasks from being balanced across clusters
except through the per-task load driven hmp_migrate/hmp_offload paths.

Further, the nohz balance kick is actively harmful to power usage if
all the tasks fit into the little domain since it causes the big
domain to wake up and do a lot of calculation to determine that
there is nothing to do.

A more generic solution is to walk the sched domain tree and determine
the intersection of potential idle balance cpus with visibility of
tasks on the current CPU, however HMP domains are more easily
accessible.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agoHMP: Force new non-kernel tasks onto big CPUs until load stabilises
Chris Redpath [Mon, 17 Jun 2013 15:08:40 +0000 (16:08 +0100)]
HMP: Force new non-kernel tasks onto big CPUs until load stabilises

Initialise the load stats for new tasks so that they do not
see the instability in early task life which makes it so hard to
decide which CPU is appropriate.

Also, change the fork balance algorithm so that the least loaded of
the CPUs in the big cluster is chosen regardless of the bigness of
the parent task.

This is intended to help performance for applications which use
many short-lived tasks. Although best practise is usually to use
a thread pool, apps which do not do this should not be subject to
the randomness of the early stats.

We should ignore real-time threads for forking on big CPUs, but
it is not possible to figure out if a new thread is real-time or
not at the fork stage. Instead, we prevent kernel threads from
getting the initial boost - when they later become real-time they
will only be on big if their compute requirements demand it.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agoHMP: Avoid multiple calls to hmp_domain_min_load in fast path
Chris Redpath [Thu, 9 May 2013 15:21:29 +0000 (16:21 +0100)]
HMP: Avoid multiple calls to hmp_domain_min_load in fast path

When evaluating a migration we make two calls to hmp_domain_min_load.
This is unnecessary if we pass on the target CPU information from the
hmp_up_migration path.

In hmp_down_migration, we don't consider the load of the target CPUS.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agoHMP: Select least-loaded CPU when performing HMP Migrations
Chris Redpath [Thu, 9 May 2013 15:21:15 +0000 (16:21 +0100)]
HMP: Select least-loaded CPU when performing HMP Migrations

The reference patch set always selects the first CPU in an HMP
domain as a migration target. In busy situations, this means that
the migrated thread cannot make immediate use of an idle CPU but
must share a busy one until the load balancer runs across the big
domain.

This patch uses the hmp_domain_min_load function introduced in
global balancing to figure out which of the CPUs is the least busy
and selects that as a migration target - in both directions.

This essentially implements a task-spread strategy and is intended
to maximise performance of migrated threads but is likely
to use more power than the packing strategy previously employed.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agoHMP: Use unweighted load for hmp migration decisions
Chris Redpath [Mon, 17 Jun 2013 14:48:15 +0000 (15:48 +0100)]
HMP: Use unweighted load for hmp migration decisions

Normal task and runqueue loading is scaled according to priority
to end up with a weighted load, known as the contribution.

We want the CPU time to be allotted according to priority, but
we also want to make big/little decisions based upon raw load.

It is common, for example, for Android apps following the dev
guide to end up with all their long-running or async action
threads as low priority unless they override the AsyncThread
constructor. All these threads are such low priority that they
become invisible to the hmp_offload routine.

Using unweighted load here allows us to maximise CPU usage in busy
situations.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agoRevert "sched: Enable HMP priority filter by default"
Chris Redpath [Mon, 17 Jun 2013 14:22:58 +0000 (15:22 +0100)]
Revert "sched: Enable HMP priority filter by default"

This reverts commit 68315334e32932739145ddb41a46cc86b8b056b3.

Having the priority filter enabled prevents proper operation
on Android systems where a wider range of priorities are used
by userspace to partition types of tasks. Those tasks should still
be able to benefit from the use of big CPUs when required.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agomm: make vmstat_update periodic run conditional
Gilad Ben-Yossef [Wed, 26 Jun 2013 16:24:59 +0000 (17:24 +0100)]
mm: make vmstat_update periodic run conditional

vmstat_update runs every second from the work queue to update statistics
and drain per cpu pages back into the global page allocator.

This is useful in most circumstances but is wasteful if the CPU doesn't
actually make any VM activity. This can happen in the situtation that
the CPU is idle or running a CPU bound long term task (e.g. CPU
isolation), in which case the periodic vmstate_update timer needlessly
itnerrupts the CPU.

This patch tries to make vmstat_update schedule itself for the next
round only if there was any work for it to do in the previous run.
The assumption is that if for a whole second we didn't see any VM
activity it is reasnoable to assume that the CPU is not using the
VM because it is idle or runs a long term single CPU bound task.

A new single unbound system work queue item is scheduled periodically
to monitor CPUs that have their vmstat_update work stopped and
re-schedule them if VM activity is detected.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Tejun Heo <tj@kernel.org>
CC: John Stultz <johnstul@us.ibm.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Mel Gorman <mel@csn.ul.ie>
CC: Mike Frysinger <vapier@gentoo.org>
CC: David Rientjes <rientjes@google.com>
CC: Hugh Dickins <hughd@google.com>
CC: Minchan Kim <minchan.kim@gmail.com>
CC: Konstantin Khlebnikov <khlebnikov@openvz.org>
CC: Christoph Lameter <cl@linux.com>
CC: Chris Metcalf <cmetcalf@tilera.com>
CC: Hakan Akkan <hakanakkan@gmail.com>
CC: Max Krasnyansky <maxk@qualcomm.com>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: linux-kernel@vger.kernel.org
CC: linux-mm@kvack.org
10 years agoconfig: Disable priority filtering for HMP Scheduler
Chris Redpath [Mon, 17 Jun 2013 14:25:51 +0000 (15:25 +0100)]
config: Disable priority filtering for HMP Scheduler

Android uses threads with very low priority by default to implement
AsyncTask APIs. This means that applications making use of these
APIs to produce multithreaded code are penalised by not allowing
use of big CPUs as necessary.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agosched: cfs.nr_running does not contain the intended metric
Chris Redpath [Thu, 16 May 2013 16:48:41 +0000 (17:48 +0100)]
sched: cfs.nr_running does not contain the intended metric

rq->nr_running is the actual number of runnable tasks we wish to use
to determine if a task is alone on a CPU.

Change-Id: Icaf3022e02924ecdc94e14d4146c6fadd9580e2b
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agosched: Basic global balancing support for HMP
Morten Rasmussen [Thu, 29 Nov 2012 15:41:50 +0000 (15:41 +0000)]
sched: Basic global balancing support for HMP

This patch introduces an extra-check at task up-migration to
prevent overloading the cpus in the faster hmp_domain while the
slower hmp_domain is not fully utilized. The patch also introduces
a periodic balance check that can down-migrate tasks if the faster
domain is oversubscribed and the slower is under-utilized.

Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com>
10 years agoARM: Fix build breakage when big.LITTLE.conf is not used.
Chris Redpath [Tue, 20 Nov 2012 05:34:49 +0000 (11:04 +0530)]
ARM: Fix build breakage when big.LITTLE.conf is not used.

Change-Id: I8641f5e930c65b5672130bd4a18d9868bb3ca594
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
10 years agoARM: Experimental Frequency-Invariant Load Scaling Patch
Chris Redpath [Fri, 16 Nov 2012 10:03:00 +0000 (10:03 +0000)]
ARM: Experimental Frequency-Invariant Load Scaling Patch

Evaluation Patch to investigate using load as a representation of the
amount of POTENTIAL cpu compute capacity used rather than a representation
of the CURRENT cpu compute capacity.

If CPUFreq is enabled, scales load in accordance with frequency.

Powersave/performance CPUFreq governors are detected and scaling is
disabled while these governors are in use. This is because when a
single-frequency governor is in use, potential CPU capacity is static.

So long as the governors and CPUFreq subsystem correctly report the
frequencies available, the scaling should self tune.

Adds an additional file to sysfs to allow this feature to be disabled
for experimentation.

/sys/kernel/hmp/frequency_invariant_load_scale

write 0 to disable, 1 to enable.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agoARM: Change load tracking scale using sysfs
Olivier Cozette [Wed, 17 Oct 2012 13:30:30 +0000 (14:30 +0100)]
ARM: Change load tracking scale using sysfs

These functions allow to change the load average period used
in the task load average computation through
/sys/kernel/hmp/load_avg_period_ms. This period is the time
in ms to go from 0 to 0.5 load average while running or the
time from 1 to 0.5 while sleeping.

The default one used is 32 and gives the same load_avg_ratio
computation than without this patch. These functions also allow
to change the up and down threshold of HMP using
/sys/kernel/hmp/{up,down}_threshold. Both must be between 0 and
1024. The thresholds are divided by 1024 before being compared
to the load_avg_ratio.

If /sys/kernel/hmp/load_avg_period_ms is 128 and
/sys/kernel/hmp/up_threshold is 512, a task will be migrated
to a bigger cluster after running for 128ms. Because after
load_avg_period_ms the load average is 0.5 and real up_threshold
us 512 / 1024 = 0.5.

Signed-off-by: Olivier Cozette <olivier.cozette@arm.com>
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agosched: Ignore offline CPUs in HMP migration & load stats
Chris Redpath [Thu, 16 May 2013 16:48:24 +0000 (17:48 +0100)]
sched: Ignore offline CPUs in HMP migration & load stats

Previously, an offline CPU would always appear to have a zero load
and this would distort the offload functionality used for balancing
big and little domains.

Maintain a mask of online CPUs in each domain and use this instead.

Change-Id: I639b564b2f40cb659af8ceb8bd37f84b8a1fe323
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agosched: Do not ignore grouped tasks during HMP forced migration.
Chris Redpath [Thu, 16 May 2013 16:48:01 +0000 (17:48 +0100)]
sched: Do not ignore grouped tasks during HMP forced migration.

If the entity is not a task, it is a cfs group rq. Iterate up to
find the task entity.

Change-Id: I7cab7aba0798f6f14e38ad32e566d90e5937ffbc
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
10 years agosched: fix arch_get_fast_and_slow_cpus to get logical cpumask correctly
Sudeep KarkadaNagesha [Mon, 24 Sep 2012 13:07:20 +0000 (14:07 +0100)]
sched: fix arch_get_fast_and_slow_cpus to get logical cpumask correctly

The patch "sched: Use device-tree to provide fast/slow CPU list for HMP"
depends on the ordering of CPU's in the device tree. It breaks to determine
the logical mask correctly if the logical mask of the CPUs differ from
physical ordering in the device tree.

This patch fix the logic by depending on the mpidr in the device tree
and mapping that mpidr to the logical cpu.

Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
10 years agosched: Only down migrate low priority tasks if allowed by affinity mask
Morten Rasmussen [Fri, 12 Oct 2012 14:25:02 +0000 (15:25 +0100)]
sched: Only down migrate low priority tasks if allowed by affinity mask

Adds an extra check intersection of the task affinity mask and the slower
hmp_domain cpumask before down migrating low priority tasks.

Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com>
10 years agoARM: sched: Avoid empty 'slow' HMP domain
Jon Medhurst [Fri, 12 Oct 2012 12:45:35 +0000 (13:45 +0100)]
ARM: sched: Avoid empty 'slow' HMP domain

On homogeneous (non-heterogeneous) systems all CPUs will be declared
'fast' and the slow cpu list will be empty. In this situation we need to
avoid adding an empty slow HMP domain otherwise the scheduler code will
blow up when it attempts to move a task to the slow domain.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
10 years agosched: Enable HMP priority filter by default
Morten Rasmussen [Wed, 10 Oct 2012 13:51:25 +0000 (14:51 +0100)]
sched: Enable HMP priority filter by default

This updates the ARM Kconfig to enable the HMP priority filter by default.

Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com>
10 years agosched: SCHED_HMP multi-domain task migration control
Morten Rasmussen [Fri, 14 Sep 2012 13:38:17 +0000 (14:38 +0100)]
sched: SCHED_HMP multi-domain task migration control

We need a way to prevent tasks that are migrating up and down the
hmp_domains from migrating straight on through before the load has
adapted to the new compute capacity of the CPU on the new hmp_domain.
This patch adds a next up/down migration delay that prevents the task
from doing another migration in the same direction until the delay
has expired.

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agosched: Add HMP task migration ftrace event
Morten Rasmussen [Fri, 14 Sep 2012 13:38:16 +0000 (14:38 +0100)]
sched: Add HMP task migration ftrace event

Adds ftrace event for tracing task migrations using HMP
optimized scheduling.

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agosched: Add ftrace events for entity load-tracking
Morten Rasmussen [Fri, 14 Sep 2012 13:38:15 +0000 (14:38 +0100)]
sched: Add ftrace events for entity load-tracking

Adds ftrace events for key variables related to the entity
load-tracking to help debugging scheduler behaviour. Allows tracing
of load contribution and runqueue residency ratio for both entities
and runqueues as well as entity CPU usage ratio.

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agoARM: sched: Setup SCHED_HMP domains
Morten Rasmussen [Fri, 14 Sep 2012 13:38:14 +0000 (14:38 +0100)]
ARM: sched: Setup SCHED_HMP domains

SCHED_HMP requires the different cpu types to be represented by an
ordered list of hmp_domains. Each hmp_domain represents all cpus of
a particular type using a cpumask.

The list is platform specific and therefore must be generated by
platform code by implementing arch_get_hmp_domains().

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agoARM: sched: Use device-tree to provide fast/slow CPU list for HMP
Morten Rasmussen [Fri, 14 Sep 2012 13:38:13 +0000 (14:38 +0100)]
ARM: sched: Use device-tree to provide fast/slow CPU list for HMP

We can't rely on Kconfig options to set the fast and slow CPU lists for
HMP scheduling if we want a single kernel binary to support multiple
devices with different CPU topology. E.g. TC2 (ARM's Test-Chip-2
big.LITTLE system), Fast Models, or even non big.LITTLE devices.

This patch adds the function arch_get_fast_and_slow_cpus() to generate
the lists at run-time by parsing the CPU nodes in device-tree; it
assumes slow cores are A7s and everything else is fast. The function
still supports the old Kconfig options as this is useful for testing the
HMP scheduler on devices without big.LITTLE.

This patch is reuse of a patch by Jon Medhurst <tixy@linaro.org> with a
few bits left out.

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agoARM: Add HMP scheduling support for ARM architecture
Morten Rasmussen [Fri, 14 Sep 2012 13:38:12 +0000 (14:38 +0100)]
ARM: Add HMP scheduling support for ARM architecture

Adds Kconfig entries to enable HMP scheduling on ARM platforms.
Currently, it disables CPU level sched_domain load-balacing in order
to simplify things. This needs fixing in a later revision. HMP
scheduling will do the load-balancing at this level instead.

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agosched: Introduce priority-based task migration filter
Morten Rasmussen [Fri, 14 Sep 2012 13:38:11 +0000 (14:38 +0100)]
sched: Introduce priority-based task migration filter

Introduces a priority threshold which prevents low priority task
from migrating to faster hmp_domains (cpus). This is useful for
user-space software which assigns lower task priority to background
task.

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agosched: Forced task migration on heterogeneous systems
Morten Rasmussen [Fri, 14 Sep 2012 13:38:10 +0000 (14:38 +0100)]
sched: Forced task migration on heterogeneous systems

This patch introduces forced task migration for moving suitable
currently running tasks between hmp_domains. Task behaviour is likely
to change over time. Tasks running in a less capable hmp_domain may
change to become more demanding and should therefore be migrated up.
They are unlikely go through the select_task_rq_fair() path anytime
soon and therefore need special attention.

This patch introduces a period check (SCHED_TICK) of the currently
running task on all runqueues and sets up a forced migration using
stop_machine_no_wait() if the task needs to be migrated.

Ideally, this should not be implemented by polling all runqueues.

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agosched: Task placement for heterogeneous systems based on task load-tracking
Morten Rasmussen [Fri, 14 Sep 2012 13:38:09 +0000 (14:38 +0100)]
sched: Task placement for heterogeneous systems based on task load-tracking

This patch introduces the basic SCHED_HMP infrastructure. Each class of
cpus is represented by a hmp_domain and tasks will only be moved between
these domains when their load profiles suggest it is beneficial.

SCHED_HMP relies heavily on the task load-tracking introduced in Paul
Turners fair group scheduling patch set:

<https://lkml.org/lkml/2012/8/23/267>

SCHED_HMP requires that the platform implements arch_get_hmp_domains()
which should set up the platform specific list of hmp_domains. It is
also assumed that the platform disables SD_LOAD_BALANCE for the
appropriate sched_domains.
Tasks placement takes place every time a task is to be inserted into
a runqueue based on its load history. The task placement decision is
based on load thresholds.

There are no restrictions on the number of hmp_domains, however,
multiple (>2) has not been tested and the up/down migration policy is
rather simple.

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agosched: entity load-tracking load_avg_ratio
Morten Rasmussen [Fri, 14 Sep 2012 13:38:08 +0000 (14:38 +0100)]
sched: entity load-tracking load_avg_ratio

This patch adds load_avg_ratio to each task. The load_avg_ratio is a
variant of load_avg_contrib which is not scaled by the task priority. It
is calculated like this:

runnable_avg_sum * NICE_0_LOAD / (runnable_avg_period + 1).

Signed-off-by: Morten Rasmussen <Morten.Rasmussen@arm.com>
10 years agosched: implement usage tracking
Paul Turner [Fri, 21 Sep 2012 20:27:51 +0000 (13:27 -0700)]
sched: implement usage tracking

With the frame-work for runnable tracking now fully in place.  Per-entity usage
tracking is a simple and low-overhead addition.

Signed-off-by: Paul Turner <pjt@google.com>
Reviewed-by: Ben Segall <bsegall@google.com>