From e3fe80da05042802fc16f828919dfe3621a34d96 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Thu, 13 Mar 2014 20:54:47 -0700 Subject: [PATCH] sched: Call the notify_on_migrate notifier chain for wakeups as well Add a change to send notify_on_migrate hints on wakeups of foreground tasks from scheduler if their load is above wakeup_load_thresholds (default value is 60). These hints can be used to choose an appropriate CPU frequency corresponding to the load of the task being woken up. By default sched_wakeup_load_threshold is set to 60 and therefore wakeup hints are sent out for those tasks whose loads are higher that value. This might cause unnecessary wakeup boosts to happen when load based syncing is turned ON for cpu-boost. Disable the wake up hints by setting the sched_wakeup_load_threshold to a value higher than 100 so that wakeup boost doesnt happen unless it is explicitly turned ON from adb shell. Change-Id: Ieca413c1a8bd2b14a15a7591e8e15d22925c42ca Signed-off-by: Rohit Gupta [rameezmustafa@codeaurora.org: Squash "a26fcce sched: Disable wakeup hints for foreground tasks by default" into this patch and update commit text.] Signed-off-by: Syed Rameez Mustafa --- include/linux/sched/sysctl.h | 1 + kernel/sched/core.c | 14 ++++++++++++-- kernel/sysctl.c | 7 +++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h index 6ae7504665ad..5ccdf9c4eb13 100644 --- a/include/linux/sched/sysctl.h +++ b/include/linux/sched/sysctl.h @@ -41,6 +41,7 @@ extern unsigned int sysctl_sched_wakeup_granularity; extern unsigned int sysctl_sched_child_runs_first; extern unsigned int sysctl_sched_wake_to_idle; extern unsigned int sysctl_sched_ravg_window; +extern unsigned int sysctl_sched_wakeup_load_threshold; enum sched_tunable_scaling { SCHED_TUNABLESCALING_NONE, diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 1d71f326bc4e..b1d48c53bf7e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2058,6 +2058,7 @@ static void ttwu_queue(struct task_struct *p, int cpu) raw_spin_unlock(&rq->lock); } +__read_mostly unsigned int sysctl_sched_wakeup_load_threshold = 110; /** * try_to_wake_up - wake up a thread * @p: the thread to be awakened @@ -2156,7 +2157,7 @@ stat: out: raw_spin_unlock_irqrestore(&p->pi_lock, flags); - if (src_cpu != cpu && task_notify_on_migrate(p)) { + if (task_notify_on_migrate(p)) { struct migration_notify_data mnd; mnd.src_cpu = src_cpu; @@ -2166,7 +2167,16 @@ out: (u64)(sysctl_sched_ravg_window)); else mnd.load = 0; - atomic_notifier_call_chain(&migration_notifier_head, + /* + * Call the migration notifier with mnd for foreground task + * migrations as well as for wakeups if their load is above + * sysctl_sched_wakeup_load_threshold. This would prompt the + * cpu-boost to boost the CPU frequency on wake up of a heavy + * weight foreground task + */ + if ((src_cpu != cpu) || (mnd.load > + sysctl_sched_wakeup_load_threshold)) + atomic_notifier_call_chain(&migration_notifier_head, 0, (void *)&mnd); } return success; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ff8df5e6614e..1314618f07f8 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -299,6 +299,13 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, + { + .procname = "sched_wakeup_load_threshold", + .data = &sysctl_sched_wakeup_load_threshold, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, #ifdef CONFIG_SCHED_DEBUG { .procname = "sched_min_granularity_ns",