Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff5a7099 authored by Lianwei Wang's avatar Lianwei Wang Committed by Amit Pundir
Browse files

cpufreq: interactive: use deferrable timer by default



Avoid wakeups only to handle the governor timer when the system is otherwise
idle.

For platforms where the power cost of remaining in idle at higher CPU
speed may outweigh the cost of a governor wakeup from idle to lower the speed,
set parameter cpufreq_interactive.governidle=1.

Change-Id: Id6c43eb35caecf9b0574fcdd5b769711bc7e6de6
Signed-off-by: default avatarLianWei WANG <a22439@motorola.com>
Signed-off-by: default avatarTodd Poynor <toddpoynor@google.com>
parent b510d29e
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/cpumask.h>
#include <linux/cpufreq.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/sched/rt.h>
@@ -92,6 +93,11 @@ static unsigned long above_hispeed_delay_val;

static int boost_val;

static bool governidle;
module_param(governidle, bool, S_IWUSR | S_IRUGO);
MODULE_PARM_DESC(governidle,
	"Set to 1 to wake up CPUs from idle to reduce speed (default 0)");

static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
		unsigned int event);

@@ -240,10 +246,11 @@ static void cpufreq_interactive_timer(unsigned long data)
rearm:
	if (!timer_pending(&pcpu->cpu_timer)) {
		/*
		 * If already at min, cancel the timer if that CPU goes idle.
		 * We don't need to re-evaluate speed until the next idle exit.
		 * If governing speed in idle and already at min, cancel the
		 * timer if that CPU goes idle.  We don't need to re-evaluate
		 * speed until the next idle exit.
		 */
		if (pcpu->target_freq == pcpu->policy->min)
		if (governidle && pcpu->target_freq == pcpu->policy->min)
			pcpu->timer_idlecancel = 1;

		pcpu->time_in_idle = get_cpu_idle_time_us(
@@ -268,7 +275,6 @@ static void cpufreq_interactive_idle_start(void)
	pending = timer_pending(&pcpu->cpu_timer);

	if (pcpu->target_freq != pcpu->policy->min) {
#ifdef CONFIG_SMP
		/*
		 * Entering idle while not at lowest speed.  On some
		 * platforms this can hold the other CPU(s) at that speed
@@ -285,8 +291,7 @@ static void cpufreq_interactive_idle_start(void)
				&pcpu->cpu_timer,
				jiffies + usecs_to_jiffies(timer_rate));
		}
#endif
	} else {
	} else if (governidle) {
		/*
		 * If at min speed and entering idle after load has
		 * already been evaluated, and a timer has been set just in
@@ -708,7 +713,10 @@ static int __init cpufreq_interactive_init(void)
	/* Initalize per-cpu timers */
	for_each_possible_cpu(i) {
		pcpu = &per_cpu(cpuinfo, i);
		if (governidle)
			init_timer(&pcpu->cpu_timer);
		else
			init_timer_deferrable(&pcpu->cpu_timer);
		pcpu->cpu_timer.function = cpufreq_interactive_timer;
		pcpu->cpu_timer.data = i;
	}