From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: axboe@kernel.dk, rafael.j.wysocki@intel.com, mingo@kernel.org,
peterz@infradead.org, preeti@linux.vnet.ibm.com,
Morten.Rasmussen@arm.com, mturquette@linaro.org,
tuukka.tikkanen@linaro.org, nicolas.pitre@linaro.org,
patches@linaro.org
Subject: [RFD PATCH 07/10] cpuidle: Add a simple select governor
Date: Wed, 22 Oct 2014 15:57:50 +0200 [thread overview]
Message-ID: <1413986273-28522-8-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1413986273-28522-1-git-send-email-daniel.lezcano@linaro.org>
This simple governor takes into account the predictable events: the timer sleep
duration and the next expected IO sleep duration. By mixing both it deduced
what idle state fits better. This governor must be extended to a statistical
approach to predict all the other events.
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>
---
drivers/cpuidle/Kconfig | 4 +++
drivers/cpuidle/governors/Makefile | 1 +
drivers/cpuidle/governors/select.c | 55 ++++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+)
create mode 100644 drivers/cpuidle/governors/select.c
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index 32748c3..11e9781 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_SELECT
+ bool "Select governor (for tickless system)"
+ default y
+
menu "ARM CPU Idle Drivers"
depends on ARM
source "drivers/cpuidle/Kconfig.arm"
diff --git a/drivers/cpuidle/governors/Makefile b/drivers/cpuidle/governors/Makefile
index 1b51272..fa45520 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_SELECT) += select.o
diff --git a/drivers/cpuidle/governors/select.c b/drivers/cpuidle/governors/select.c
new file mode 100644
index 0000000..0de7095
--- /dev/null
+++ b/drivers/cpuidle/governors/select.c
@@ -0,0 +1,55 @@
+/*
+ * select.c - the select governor
+ *
+ * Copyright (C) 2014 Daniel Lezcano <daniel.lezcano@linaro.org>
+ *
+*/
+
+#include <linux/cpuidle.h>
+
+static int select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
+ struct cpuidle_times *times)
+{
+ int i, index = 0, latency_req = times->latency_req;
+ unsigned int next_event;
+
+ /*
+ * If the guessed IO next event is zero, that means there is no IO
+ * pending, so we ignore it in the equation
+ */
+ next_event = times->next_io_event ?
+ min(times->next_io_event, times->next_timer_event) :
+ times->next_timer_event;
+
+ for (i = 0; i < drv->state_count; i++) {
+
+ struct cpuidle_state *s = &drv->states[i];
+ struct cpuidle_state_usage *su = &dev->states_usage[i];
+
+ if (s->disabled || su->disable)
+ continue;
+ if (s->target_residency > next_event)
+ continue;
+ if (s->exit_latency > latency_req)
+ continue;
+
+ index = i;
+ }
+
+ return index;
+}
+
+static struct cpuidle_governor select_governor = {
+ .name = "select",
+ .rating = 10,
+ .select = select,
+ .owner = THIS_MODULE,
+};
+
+static int __init select_init(void)
+{
+ return cpuidle_register_governor(&select_governor);
+}
+
+postcore_initcall(select_init);
+
--
1.9.1
next prev parent reply other threads:[~2014-10-22 13:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-22 13:57 [RFD PATCH 00/10] cpuidle: Predict the next events with the IO latencies Daniel Lezcano
2014-10-22 13:57 ` [RFD PATCH 01/10] sched: add io latency framework Daniel Lezcano
2014-10-28 3:19 ` Len Brown
2014-10-30 14:44 ` Peter Zijlstra
2014-10-22 13:57 ` [RFD PATCH 02/10] cpuidle: Checking the zero latency inside the governors does not make sense Daniel Lezcano
2014-10-28 3:11 ` Len Brown
2014-10-22 13:57 ` [RFD PATCH 03/10] sched: idle: cpudidle: Pass the latency req from idle.c Daniel Lezcano
2014-10-22 13:57 ` [RFD PATCH 04/10] sched: idle: Compute next timer event and pass it the cpuidle framework Daniel Lezcano
2014-10-22 13:57 ` [RFD PATCH 05/10] cpuidle: Remove unused headers for tick Daniel Lezcano
2014-10-22 13:57 ` [RFD PATCH 06/10] sched: idle: Add io latency information for the next event Daniel Lezcano
2014-10-22 13:57 ` Daniel Lezcano [this message]
2014-10-22 13:57 ` [RFD PATCH 08/10] cpuidle: select: hack - increase rating to have this governor as default Daniel Lezcano
2014-10-22 13:57 ` [RFD PATCH 09/10] cpuidle: sysfs: Add per cpu idle state prediction statistics Daniel Lezcano
2014-10-22 13:57 ` [RFD PATCH 10/10] sched: io_latency: Tracking via buckets Daniel Lezcano
2014-10-30 14:46 ` Peter Zijlstra
2014-10-30 15:07 ` Nicolas Pitre
2014-10-30 14:38 ` [RFD PATCH 00/10] cpuidle: Predict the next events with the IO latencies Peter Zijlstra
2014-10-30 15:14 ` Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1413986273-28522-8-git-send-email-daniel.lezcano@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=Morten.Rasmussen@arm.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mturquette@linaro.org \
--cc=nicolas.pitre@linaro.org \
--cc=patches@linaro.org \
--cc=peterz@infradead.org \
--cc=preeti@linux.vnet.ibm.com \
--cc=rafael.j.wysocki@intel.com \
--cc=tuukka.tikkanen@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome