From 68dfacdb44fcdf5b47fa93d064cd3bc3db0766f1 Mon Sep 17 00:00:00 2001 From: Satya Durga Srinivasu Prabhala Date: Mon, 18 Apr 2022 18:18:57 -0700 Subject: [PATCH] sched/walt: skip long running RT task detection for stopper tasks As stopper task's scheduling policy is set to FIFO and task may run long time depends on the number of tasks to be migrated etc., current long running RT task detection feature crashes system due to task's arrivial time stamp is taken when stopper task scheduled in during CPU hot-plug out operation and used it later when CPU gets hot-plugged in back. Fix this false positive issue by skipping update of arrivial time stamp for stopper tasks. Fixes: b429bee50fe2c8f ("sched/walt/rt: limit long running RT task detection to FIFO") Change-Id: I714494fee49b6e8e5d50885bd47b38ad0d535579 Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/walt/walt_rt.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/sched/walt/walt_rt.c b/kernel/sched/walt/walt_rt.c index b245bca00ae4..13926fcb5ab5 100644 --- a/kernel/sched/walt/walt_rt.c +++ b/kernel/sched/walt/walt_rt.c @@ -20,7 +20,7 @@ static void rt_task_arrival_marker(void *unused, bool preempt, { unsigned int cpu = raw_smp_processor_id(); - if (next->policy == SCHED_FIFO) + if (next->policy == SCHED_FIFO && next != cpu_rq(cpu)->stop) per_cpu(rt_task_arrival_time, cpu) = rq_clock_task(this_rq()); else per_cpu(rt_task_arrival_time, cpu) = 0; @@ -38,14 +38,12 @@ static void long_running_rt_task_notifier(void *unused, struct rq *rq) return; if (per_cpu(rt_task_arrival_time, cpu) && curr->policy != SCHED_FIFO) { - /* This should never happen, trying to avoid any false positives */ - printk_deferred("Long running RT false positive detected for task %s (%d) runtime > %u now=%llu task arrival time=%llu runtime=%llu\n", - curr->comm, curr->pid, - sysctl_sched_long_running_rt_task_ms * MSEC_TO_NSEC, - rq_clock_task(rq), - per_cpu(rt_task_arrival_time, cpu), - rq_clock_task(rq) - - per_cpu(rt_task_arrival_time, cpu)); + /* + * It is possible that the scheduling policy for the current + * task might get changed after task arrival time stamp is + * noted during sched_switch of RT task. To avoid such false + * positives, reset arrival time stamp. + */ per_cpu(rt_task_arrival_time, cpu) = 0; return; }