Re: [RFC 1/2] softirq: Defer net rx/tx processing to ksoftirqd context
From: Frederic Weisbecker
Date: Wed Jan 10 2018 - 22:22:45 EST
On Wed, Jan 10, 2018 at 06:13:01PM -0800, Linus Torvalds wrote:
> So just saying "hey, ksoftirq is runnable - but maybe not running
> _now"" and ignoring softirqs entirely is just stupid. Even if we could
> easily do another small bunch of them, at least the non-networking
> ones.
>
> So maybe that "ksoftirqd_running()" check should actually be something like
>
> static bool ksoftirqd_running(void)
> {
> struct task_struct *tsk = __this_cpu_read(ksoftirqd);
>
> return tsk == current;
> }
>
> which actually checks that ksoftirq is running right *now*, and not
> scheduled away because somebody is running a perl script.
Makes sense, but I think you need to keep the TASK_RUNNING check. In case
the hardirq is interrupting ksoftirqd in TASK_INTERRUPTIBLE state right before
it's going to sleep. In that case neither ksoftirqd nor the hardirq are going
to serve the poor pending softirqd. And if we are in nohz mode, it may not be
served before a while. So perhaps it should be:
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 2f5e87f..6e5d7bc 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -85,7 +85,7 @@ static bool ksoftirqd_running(void)
{
struct task_struct *tsk = __this_cpu_read(ksoftirqd);
- return tsk && (tsk->state == TASK_RUNNING);
+ return (tsk == current) && (tsk->state == TASK_RUNNING);
}
/*