diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2014-06-24 19:16:21 +0200 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2015-01-15 13:38:08 +0100 |
commit | e503d833d5f3dd32399edac7d7a7bf72a0ee2a69 (patch) | |
tree | f10911ba5baac23ba9560f6cd007a2cd05482fcc | |
parent | aa8ac0efa27b2d4f7480bd53a60b435c14b8cb84 (diff) |
cpuidle: Add a simple irq governor
This simple governor takes into account the predictable events: the timer sleep
duration and the next expected irq sleep duration. By mixing both it deduced
what idle state fits better.
The main purpose of this governor is to handle the guessed next events in a
categorized way:
1. deterministic events : timers
2. guessed events : IOs
3. predictable events : keystroke, incoming network packet, ...
This governor is aimed to be moved later near the scheduler, so this one
can inspect/inject more informations and act proactively rather than
reactively.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Conflicts:
drivers/cpuidle/Kconfig
-rw-r--r-- | drivers/cpuidle/Kconfig | 4 | ||||
-rw-r--r-- | drivers/cpuidle/governors/Makefile | 1 | ||||
-rw-r--r-- | drivers/cpuidle/governors/irq.c | 33 |
3 files changed, 38 insertions, 0 deletions
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index c5029c1209b4..1aae78bc9d95 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -25,6 +25,10 @@ config CPU_IDLE_GOV_MENU bool "Menu governor (for tickless system)" default y +config CPU_IDLE_GOV_IRQ + bool "Irq governor (for tickless system)" + default y + config DT_IDLE_STATES bool diff --git a/drivers/cpuidle/governors/Makefile b/drivers/cpuidle/governors/Makefile index 1b512722689f..8804ee2f550c 100644 --- a/drivers/cpuidle/governors/Makefile +++ b/drivers/cpuidle/governors/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o obj-$(CONFIG_CPU_IDLE_GOV_MENU) += menu.o +obj-$(CONFIG_CPU_IDLE_GOV_IRQ) += irq.o diff --git a/drivers/cpuidle/governors/irq.c b/drivers/cpuidle/governors/irq.c new file mode 100644 index 000000000000..cb7a0bfbd133 --- /dev/null +++ b/drivers/cpuidle/governors/irq.c @@ -0,0 +1,33 @@ +/* + * irq.c - the irq governor + * + * Copyright (C) 2014 Daniel Lezcano <daniel.lezcano@linaro.org> + * +*/ +#include <linux/ktime.h> +#include <linux/irq.h> +#include <linux/cpuidle.h> + +static int select(struct cpuidle_driver *drv, struct cpuidle_device *dev, + int latency_req, s64 next_timer_event) +{ + s64 next_irq_event = irqt_get_next_prediction(dev->cpu); + s64 next_event = next_irq_event ? + min(next_irq_event, next_timer_event) : next_timer_event; + + return cpuidle_find_state(drv, dev, next_event, latency_req); +} + +static struct cpuidle_governor irq_governor = { + .name = "irq", + .rating = 10, + .select = select, + .owner = THIS_MODULE, +}; + +static int __init irq_init(void) +{ + return cpuidle_register_governor(&irq_governor); +} + +postcore_initcall(irq_init); |