Messages in this thread Patch in this message | | | From | Petr Malat <> | Subject | [PATCH] softirq: Do not loop if running under a real-time task | Date | Mon, 6 Mar 2023 16:45:48 +0100 |
| |
Softirq processing can be a source of a scheduling jitter if it executes in a real-time task as in that case need_resched() is false unless there is another runnable task with a higher priority. This is especially bad if the softirq processing runs in a migration thread, which has priority 99 and usually runs for a short time.
One option would be to not restart the softirq processing if there is another runnable task to allow the high prio task to finish and yield the CPU, the second one is to not restart if softirq executes in a real-time task. Usually, real-time tasks don't want to be interrupted, so implement the second option.
Signed-off-by: Petr Malat <oss@malat.biz> --- kernel/softirq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/softirq.c b/kernel/softirq.c index c8a6913c067d..6a66d28bf020 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -478,7 +478,8 @@ asmlinkage __visible void do_softirq(void) /* * We restart softirq processing for at most MAX_SOFTIRQ_RESTART times, - * but break the loop if need_resched() is set or after 2 ms. + * but break the loop after 2 ms or if need_resched() is set or if we + * execute in a real-time task. * The MAX_SOFTIRQ_TIME provides a nice upper bound in most cases, but in * certain cases, such as stop_machine(), jiffies may cease to * increment and so we need the MAX_SOFTIRQ_RESTART limit as @@ -589,6 +590,7 @@ asmlinkage __visible void __softirq_entry __do_softirq(void) pending = local_softirq_pending(); if (pending) { if (time_before(jiffies, end) && !need_resched() && + (current->prio >= MAX_RT_PRIO || current == __this_cpu_read(ksoftirqd)) && --max_restart) goto restart; -- 2.30.2
| |