kernel-ark/drivers/cpuidle
Daniel Lezcano 442bf3aaf5 sched: Let the scheduler see CPU idle states
When the cpu enters idle, it stores the cpuidle state pointer in its
struct rq instance which in turn could be used to make a better decision
when balancing tasks.

As soon as the cpu exits its idle state, the struct rq reference is
cleared.

There are a couple of situations where the idle state pointer could be changed
while it is being consulted:

1. For x86/acpi with dynamic c-states, when a laptop switches from battery
   to AC that could result on removing the deeper idle state. The acpi driver
   triggers:
	'acpi_processor_cst_has_changed'
		'cpuidle_pause_and_lock'
			'cpuidle_uninstall_idle_handler'
				'kick_all_cpus_sync'.

All cpus will exit their idle state and the pointed object will be set to
NULL.

2. The cpuidle driver is unloaded. Logically that could happen but not
in practice because the drivers are always compiled in and 95% of them are
not coded to unregister themselves.  In any case, the unloading code must
call 'cpuidle_unregister_device', that calls 'cpuidle_pause_and_lock'
leading to 'kick_all_cpus_sync' as mentioned above.

A race can happen if we use the pointer and then one of these two scenarios
occurs at the same moment.

In order to be safe, the idle state pointer stored in the rq must be
used inside a rcu_read_lock section where we are protected with the
'rcu_barrier' in the 'cpuidle_uninstall_idle_handler' function. The
idle_get_state() and idle_put_state() accessors should be used to that
effect.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-pm@vger.kernel.org
Cc: linaro-kernel@lists.linaro.org
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/n/tip-@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-09-24 14:46:58 +02:00
..
governors More ACPI and power management updates for 3.17-rc1 2014-08-14 18:13:46 -06:00
coupled.c arch: Mass conversion of smp_mb__*() 2014-04-18 14:20:48 +02:00
cpuidle-at91.c ARM: at91: cpuidle: Move driver to drivers/cpuidle 2013-10-16 23:49:35 +02:00
cpuidle-big_little.c ARM: 8130/1: cpuidle/cpuidle-big_little: fix reading cpu id part number 2014-08-27 15:40:45 +01:00
cpuidle-calxeda.c ARM/cpuidle: remove __init tag from Calxeda cpuidle probe function 2013-12-30 11:55:20 +01:00
cpuidle-clps711x.c ARM: clps711x: Add cpuidle driver 2014-04-30 01:33:02 +02:00
cpuidle-cps.c cpuidle: cpuidle-cps: add MIPS CPS cpuidle driver 2014-05-28 16:20:36 +01:00
cpuidle-exynos.c ARM: EXYNOS: Fix suspend/resume sequences 2014-08-09 08:24:36 -07:00
cpuidle-kirkwood.c cpuidle-kirkwood.c: simplify use of devm_ioremap_resource() 2013-08-14 22:20:06 +02:00
cpuidle-mvebu-v7.c cpuidle: mvebu: add Armada 38x support 2014-07-24 11:47:29 +00:00
cpuidle-powernv.c powerpc/cpuidle: Fix parsing of idle state flags from device-tree 2014-08-05 15:40:45 +10:00
cpuidle-pseries.c cpuidle/pseries: Fix fallout caused due to cleanup in pseries cpuidle backend driver 2014-02-12 08:05:03 +01:00
cpuidle-ux500.c ARM: ux500: cpuidle: fix section mismatch 2013-10-07 16:47:07 +02:00
cpuidle-zynq.c ARM: zynq: cpuidle: convert to platform driver 2013-10-07 16:46:59 +02:00
cpuidle.c sched: Let the scheduler see CPU idle states 2014-09-24 14:46:58 +02:00
cpuidle.h cpuidle: support multiple drivers 2012-11-15 00:34:23 +01:00
driver.c cpuidle: Remove time measurement in poll state 2014-07-29 01:37:57 +02:00
governor.c cpuidle: remove cpuidle_unregister_governor() 2013-10-30 01:21:24 +01:00
Kconfig cpuidle: Remove manual selection of the multiple driver support 2014-07-29 01:35:29 +02:00
Kconfig.arm ARM: SoC platform changes for 3.17 2014-08-08 11:14:29 -07:00
Kconfig.mips cpuidle: cpuidle-cps: add MIPS CPS cpuidle driver 2014-05-28 16:20:36 +01:00
Kconfig.powerpc powerpc/powernv/cpuidle: Back-end cpuidle driver for powernv platform. 2014-01-29 17:02:24 +11:00
Makefile cpuidle: mvebu: rename the driver from armada-370-xp to mvebu-v7 2014-07-24 11:47:11 +00:00
sysfs.c cpuidle: fix permission for driver name sysfs node 2014-07-19 21:43:28 +02:00