From c646ea5a5fd9f1dad83111fbb5362418b36899a4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Dec 2020 14:36:57 +0100 Subject: [PATCH] Revert "ANDROID: Revert "softirq: Let ksoftirqd do its job"" This reverts commit 1bcefd388369ad819aa9175b8fb6ad583594b9d1 as the softirq code is rewritten in 5.11-rc1 and massive merge conflicts are happening. If this change is still needed, please work with upstream to get the patches accepted so they can then come into this tree automatically. Bug: 168521633 Cc: Lingutla Chandrasekhar Cc: Satya Durga Srinivasu Prabhala Cc: J. Avila Signed-off-by: Greg Kroah-Hartman Change-Id: Idb615a68b4e892b1b0391a8511c9338f6202368b --- kernel/softirq.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kernel/softirq.c b/kernel/softirq.c index a04000169623..a5ddc66d341d 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -86,6 +86,18 @@ static void wakeup_softirqd(void) wake_up_process(tsk); } +/* + * If ksoftirqd is scheduled, we do not want to process pending softirqs + * right now. Let ksoftirqd handle this at its own rate, to get fairness. + */ +static bool ksoftirqd_running(void) +{ + struct task_struct *tsk = __this_cpu_read(ksoftirqd); + + return tsk && (tsk->state == TASK_RUNNING) && + !__kthread_should_park(tsk); +} + /* * preempt_count and SOFTIRQ_OFFSET usage: * - preempt_count is changed by SOFTIRQ_OFFSET on entering or leaving @@ -350,7 +362,7 @@ asmlinkage __visible void do_softirq(void) pending = local_softirq_pending(); - if (pending) + if (pending && !ksoftirqd_running()) do_softirq_own_stack(); local_irq_restore(flags); @@ -384,6 +396,9 @@ void irq_enter(void) static inline void invoke_softirq(void) { + if (ksoftirqd_running()) + return; + if (!force_irqthreads) { #ifdef CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK /*