From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752167AbcEKNOI (ORCPT ); Wed, 11 May 2016 09:14:08 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:38340 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751985AbcEKNOE (ORCPT ); Wed, 11 May 2016 09:14:04 -0400 X-Sasl-enc: cYmathhNL9/ZbH6wFl7BtntRg6Lu20p156TRwhg9rCXG 1462972442 Subject: Re: [RFC PATCH 0/2] net: threadable napi poll loop To: Peter Zijlstra , Eric Dumazet References: <1462890590.23934.68.camel@edumazet-glaptop3.roam.corp.google.com> <90f3db8c-c30c-b204-576a-454939ac93ce@stressinduktion.org> <94f323a9-515e-4d75-cac8-ef0214f0499e@stressinduktion.org> <1462920697.23934.113.camel@edumazet-glaptop3.roam.corp.google.com> <20160511065527.GD3193@twins.programming.kicks-ass.net> Cc: Eric Dumazet , Paolo Abeni , netdev , "David S. Miller" , Jiri Pirko , Daniel Borkmann , Alexei Starovoitov , Alexander Duyck , Tom Herbert , Ingo Molnar , Rik van Riel , LKML From: Hannes Frederic Sowa Message-ID: Date: Wed, 11 May 2016 15:13:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <20160511065527.GD3193@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11.05.2016 08:55, Peter Zijlstra wrote: > On Tue, May 10, 2016 at 03:51:37PM -0700, Eric Dumazet wrote: >> diff --git a/kernel/softirq.c b/kernel/softirq.c >> index 17caf4b63342..22463217e3cf 100644 >> --- a/kernel/softirq.c >> +++ b/kernel/softirq.c >> @@ -56,6 +56,7 @@ EXPORT_SYMBOL(irq_stat); >> static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp; >> >> DEFINE_PER_CPU(struct task_struct *, ksoftirqd); >> +DEFINE_PER_CPU(bool, ksoftirqd_scheduled); >> >> const char * const softirq_to_name[NR_SOFTIRQS] = { >> "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL", >> @@ -73,8 +74,10 @@ static void wakeup_softirqd(void) >> /* Interrupts are disabled: no need to stop preemption */ >> struct task_struct *tsk = __this_cpu_read(ksoftirqd); >> >> - if (tsk && tsk->state != TASK_RUNNING) >> + if (tsk && tsk->state != TASK_RUNNING) { >> + __this_cpu_write(ksoftirqd_scheduled, true); >> wake_up_process(tsk); > > Since we're already looking at tsk->state, and the wake_up_process() > ensures the thing becomes TASK_RUNNING, you could add: > > static inline bool ksoftirqd_running(void) > { > return __this_cpu_read(ksoftirqd)->state == TASK_RUNNING; > } This looks racy to me as the ksoftirqd could be in the progress to stop and we would miss another softirq invocation. Thanks, Hannes