From 0fe8be6276933e28fd5ca11536f0e519d7250fd7 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Thu, 26 Nov 2020 14:14:29 +0530 Subject: [PATCH] sched/walt: Improve the scheduler This change is for general scheduler improvement. Change-Id: I8f521dfd31ff1c8cc1f16805e4e0ac78228d9383 Signed-off-by: Pavankumar Kondeti --- drivers/android/binder.c | 11 +++++++---- fs/proc/base.c | 7 +++++-- include/linux/sched.h | 5 ++++- kernel/sched/sched.h | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index aa614bd4c622..2602bfecbbf2 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -965,7 +965,8 @@ static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc, if (thread->task && current->signal && (current->signal->oom_score_adj == 0) && (current->prio < DEFAULT_PRIO)) - thread->task->wts.low_latency = true; + thread->task->wts.low_latency |= + WALT_LOW_LATENCY_BINDER; #endif if (sync) wake_up_interruptible_sync(&thread->wait); @@ -1030,7 +1031,8 @@ static void binder_wakeup_thread_ilocked(struct binder_proc *proc, if (thread->task && current->signal && (current->signal->oom_score_adj == 0) && (current->prio < DEFAULT_PRIO)) - thread->task->wts.low_latency = true; + thread->task->wts.low_latency |= + WALT_LOW_LATENCY_BINDER; #endif if (sync) wake_up_interruptible_sync(&thread->wait); @@ -4690,8 +4692,9 @@ retry: trace_binder_transaction_received(t); #ifdef CONFIG_SCHED_WALT - if (current->wts.low_latency) - current->wts.low_latency = false; + if (current->wts.low_latency & WALT_LOW_LATENCY_BINDER) + thread->task->wts.low_latency &= + ~WALT_LOW_LATENCY_BINDER; #endif binder_stat_br(proc, thread, cmd); binder_debug(BINDER_DEBUG_TRANSACTION, diff --git a/fs/proc/base.c b/fs/proc/base.c index 913ba3363fcf..72c001f28699 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1497,7 +1497,7 @@ static int sched_low_latency_show(struct seq_file *m, void *v) if (!p) return -ESRCH; - low_latency = p->wts.low_latency; + low_latency = p->wts.low_latency & WALT_LOW_LATENCY_PROCFS; seq_printf(m, "%d\n", low_latency); put_task_struct(p); @@ -1520,7 +1520,10 @@ sched_low_latency_write(struct file *file, const char __user *buf, if (err) goto out; - p->wts.low_latency = low_latency; + if (low_latency) + p->wts.low_latency |= WALT_LOW_LATENCY_PROCFS; + else + p->wts.low_latency &= ~WALT_LOW_LATENCY_PROCFS; out: put_task_struct(p); return err < 0 ? err : count; diff --git a/include/linux/sched.h b/include/linux/sched.h index 5622a249e75a..60e0efb408f3 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -562,6 +562,9 @@ extern void walt_update_cluster_topology(void); #define RAVG_HIST_SIZE_MAX 5 #define NUM_BUSY_BUCKETS 10 +#define WALT_LOW_LATENCY_PROCFS BIT(0) +#define WALT_LOW_LATENCY_BINDER BIT(1) + struct walt_task_struct { /* * 'mark_start' marks the beginning of an event (task waking up, task @@ -611,7 +614,7 @@ struct walt_task_struct { bool wake_up_idle; bool misfit; bool rtg_high_prio; - bool low_latency; + u8 low_latency; u64 boost_period; u64 boost_expires; u64 last_sleep_ts; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 165369e4acf9..4ca1397de876 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3004,6 +3004,7 @@ static inline struct walt_related_thread_group return rcu_dereference(p->wts.grp); } +/* applying the task threshold for all types of low latency tasks. */ static inline bool walt_low_latency_task(struct task_struct *p) { return p->wts.low_latency &&