Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753632AbeAKDWj (ORCPT + 1 other); Wed, 10 Jan 2018 22:22:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:34994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753169AbeAKDWi (ORCPT ); Wed, 10 Jan 2018 22:22:38 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15C952173F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=frederic@kernel.org Date: Thu, 11 Jan 2018 04:22:34 +0100 From: Frederic Weisbecker To: Linus Torvalds Cc: Dmitry Safonov , Eric Dumazet , LKML , Dmitry Safonov <0x7f454c46@gmail.com>, Andrew Morton , David Miller , Frederic Weisbecker , Hannes Frederic Sowa , Ingo Molnar , "Levin, Alexander (Sasha Levin)" , Paolo Abeni , "Paul E. McKenney" , Peter Zijlstra , Radu Rendec , Rik van Riel , Stanislaw Gruszka , Thomas Gleixner , Wanpeng Li Subject: Re: [RFC 1/2] softirq: Defer net rx/tx processing to ksoftirqd context Message-ID: <20180111032232.GA11633@lerouge> References: <20180109133623.10711-1-dima@arista.com> <20180109133623.10711-2-dima@arista.com> <1515620880.3350.44.camel@arista.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 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); } /*