diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index 20255a477947..320fbd00f28b 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -68,7 +68,7 @@ DECLARE_RESTRICTED_HOOK(android_rvh_get_nohz_timer_target, TP_PROTO(int *cpu, bool *done), TP_ARGS(cpu, done), 1); -DECLARE_RESTRICTED_HOOK(android_rvh_set_user_nice, +DECLARE_RESTRICTED_HOOK(android_rvh_set_user_nice_locked, TP_PROTO(struct task_struct *p, long *nice, bool *allowed), TP_ARGS(p, nice, allowed), 1); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c54f4175c0c6..361be9a02436 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7303,12 +7303,11 @@ 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, allowed = false; + bool queued, running, allowed = true; struct rq *rq; int old_prio; - trace_android_rvh_set_user_nice(p, &nice, &allowed); - if ((task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE) && !allowed) + if (task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE) return; /* * We have to be careful, if called from sys_setpriority(), @@ -7319,6 +7318,10 @@ void set_user_nice(struct task_struct *p, long nice) update_rq_clock(rq); + trace_android_rvh_set_user_nice_locked(p, &nice, &allowed); + if (!allowed) + return; + /* * The RT priorities are set via sched_setscheduler(), but we still * allow the 'normal' nice value to be set - but as expected diff --git a/kernel/sched/vendor_hooks.c b/kernel/sched/vendor_hooks.c index 0838a1b58ac4..408a2a96f2a5 100644 --- a/kernel/sched/vendor_hooks.c +++ b/kernel/sched/vendor_hooks.c @@ -23,7 +23,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_lowest_rq); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_prepare_prio_fork); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_finish_prio_fork); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_rtmutex_prepare_setprio); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_user_nice); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_user_nice_locked); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_setscheduler); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_busiest_group); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dump_throttled_rt_tasks);