From 4e77c99cd7bf3a038b0143e962985d0ba508ae2a Mon Sep 17 00:00:00 2001 From: Frankie Chang Date: Tue, 12 Jan 2021 12:32:54 +0800 Subject: [PATCH] ANDROID: sched: move vendor hook to check scheduling nice value move hook to collect scheduling information and apply vendor's tuning before task's scheduling priority is changed Bug: 163431711 Signed-off-by: Frankie Chang Change-Id: I61a7ab663316c0fbcb28d1b6e523649a6374b492 (cherry picked from commit 5cf5bc7523bd5608590de487de896c1026161a18) --- include/trace/hooks/sched.h | 4 ++-- kernel/sched/core.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index 8173569953ba..99641b8d3c1a 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -58,8 +58,8 @@ DECLARE_RESTRICTED_HOOK(android_rvh_rtmutex_prepare_setprio, TP_ARGS(p, pi_task), 1); DECLARE_RESTRICTED_HOOK(android_rvh_set_user_nice, - TP_PROTO(struct task_struct *p, long *nice), - TP_ARGS(p, nice), 1); + TP_PROTO(struct task_struct *p, long *nice, bool *allowed), + TP_ARGS(p, nice, allowed), 1); DECLARE_RESTRICTED_HOOK(android_rvh_setscheduler, TP_PROTO(struct task_struct *p), diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 58a4f6a63547..e57809458da0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5743,12 +5743,13 @@ static inline int rt_effective_prio(struct task_struct *p, int prio) void set_user_nice(struct task_struct *p, long nice) { - bool queued, running; + bool queued, running, allowed = false; int old_prio; struct rq_flags rf; struct rq *rq; - if (task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE) + trace_android_rvh_set_user_nice(p, &nice, &allowed); + if ((task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE) && !allowed) return; /* * We have to be careful, if called from sys_setpriority(), @@ -5756,7 +5757,6 @@ void set_user_nice(struct task_struct *p, long nice) */ rq = task_rq_lock(p, &rf); update_rq_clock(rq); - trace_android_rvh_set_user_nice(p, &nice); /* * The RT priorities are set via sched_setscheduler(), but we still