这东西不能独立运行,必须依靠cpu-boost或者cpu_input_boost驱动来决定何时触发、触发时长和boost的值
From c68ead66acd07be4775c3bbb3f6b8d0049fe1183 Mon Sep 17 00:00:00 2001
From: joshuous <joshuous@gmail.com>
Date: Fri, 9 Feb 2018 22:52:10 +0800
Subject: [PATCH] cpu_input_boost: Implement Dynamic SchedTune Boost v3
Dynamic SchedTune Boost occurs on-the-fly during interactions, such
as touch input. This idea was conceived because of an existing battery
drain issue whereby setting a permanent schedtune boost would cause
boosting to occur even when the phone was idling. For example, if a user
sets the /dev/stune/top-app/schedtune.boost to 10, the device may not
idle at the lowest frequency step, which can lead to higher idle and
active drain rates. Thus it should consume less power to boost only
during interactions.
v1 worked by changing the value returned by schedtune_cpu_boost(), but
did not change the true boost value of the top-app cgroup. In comparison,
v2 modifies the value in /dev/stune/top-app/schedtune.boost directly.
v3 reworks the entire Dynamic SchedTune Boost code and improves detection
of top-app or any other SchedTune group.
The tunable can be found in /sys/module/cpu_boost/parameters/dynamic_stune_boost.
Signed-off-by: joshuous <joshuous@gmail.com>
[nc: Adapted from cpu-boost.c to cpu_input_boost.c]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: LibXZR <xzr467706992@163.com>
---
drivers/cpufreq/cpu_input_boost.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/cpufreq/cpu_input_boost.c b/drivers/cpufreq/cpu_input_boost.c
index 2f0535af3505..03565fe66253 100644
--- a/drivers/cpufreq/cpu_input_boost.c
+++ b/drivers/cpufreq/cpu_input_boost.c
@@ -51,6 +51,8 @@ static unsigned short input_boost_duration __read_mostly =
static unsigned short wake_boost_duration __read_mostly =
CONFIG_WAKE_BOOST_DURATION_MS;
+static unsigned short dynamic_stune_boost __read_mostly = 1;
+
static bool dynamic_sched_boost __read_mostly = true;
module_param(input_boost_freq_little, uint, 0644);
@@ -69,6 +71,8 @@ module_param(cpu_freq_idle_prime, uint, 0644);
module_param(input_boost_duration, short, 0644);
module_param(wake_boost_duration, short, 0644);
+module_param(dynamic_stune_boost, short, 0644);
+
module_param(dynamic_sched_boost, bool, 0644);
unsigned long last_input_time;
@@ -179,6 +183,11 @@ static void __cpu_input_boost_kick(struct boost_drv *b)
return;
set_bit(INPUT_BOOST, &b->state);
+
+ #ifdef CONFIG_DYNAMIC_STUNE_BOOST
+ do_stune_boost("top-app", dynamic_stune_boost);
+ #endif
+
if (dynamic_sched_boost)
sched_set_boost(2);
if (!mod_delayed_work(system_unbound_wq, &b->input_unboost,
@@ -221,6 +230,10 @@ static void __cpu_input_boost_kick_max(struct boost_drv *b,
void cpu_input_boost_kick_max(unsigned int duration_ms)
{
struct boost_drv *b = &boost_drv_g;
+
+ #ifdef CONFIG_DYNAMIC_STUNE_BOOST
+ do_stune_boost("top-app", dynamic_stune_boost);
+ #endif
__cpu_input_boost_kick_max(b, duration_ms);
}
@@ -234,6 +247,10 @@ static void input_unboost_worker(struct work_struct *work)
if (dynamic_sched_boost)
sched_set_boost(0);
wake_up(&b->boost_waitq);
+
+ #ifdef CONFIG_DYNAMIC_STUNE_BOOST
+ reset_stune_boost("top-app");
+ #endif
}
static void max_unboost_worker(struct work_struct *work)
@@ -243,6 +260,10 @@ static void max_unboost_worker(struct work_struct *work)
clear_bit(MAX_BOOST, &b->state);
wake_up(&b->boost_waitq);
+
+ #ifdef CONFIG_DYNAMIC_STUNE_BOOST
+ reset_stune_boost("top-app");
+ #endif
}
static int cpu_boost_thread(void *data)
@@ -391,6 +412,10 @@ static int cpu_input_boost_input_connect(struct input_handler *handler,
static void cpu_input_boost_input_disconnect(struct input_handle *handle)
{
+ #ifdef CONFIG_DYNAMIC_STUNE_BOOST
+ reset_stune_boost("top-app");
+ #endif
+
if (dynamic_sched_boost)
sched_set_boost(0);
input_close_device(handle);