Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp167346iob; Mon, 2 May 2022 16:07:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsEbOHOHo4Yn7VznOE8wkA1EitegtysF1KpbCRumqX67LNuD6/Ftsc6wvNKNP6fXSN+D1V X-Received: by 2002:a17:902:bb92:b0:153:4eae:c77e with SMTP id m18-20020a170902bb9200b001534eaec77emr13650329pls.93.1651532834853; Mon, 02 May 2022 16:07:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651532834; cv=none; d=google.com; s=arc-20160816; b=pArtBRinnFuyq+LRDv+oDsQ1HA06DdhDyxzeLNnyHTjm2buAHwJms+G6uwd+gWGfdG n6xSXvmhL4PKaFlmOg5ysh8DXlPzd1khOHUq7o+ZRJL+TOfvoeMdcckceDeFE+By7yfl 8Xad1QNI/62/oAae4nTvzcC/B31OxMl9pNCBG2U3TcSNTVWLbFgjk9Dd9w7jMOdL3oWM IaT+pC92tni43mvwCpTBJAkkLbz4r3La17v4ZWpIZPQlnQ1CTwVsF8JtCPhgAdpbBel8 6kYst9VCMRT2A/MiK/Iii1sPm5Fi8l8lJK1GB9SxPXraz9l6sxgM549h9rkJ5ihTk2dM ommA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date; bh=Dh3XtOgVOayhq2ZA55mrvJFkB0NfpVkoaveYyeCwgL8=; b=IrG74XX9pOhpkuL7QQLR01+EnRToujn7NKekzosqhzu96TzgB95GhsFrrEZGlsDf5L aEZUsaTxu02Ol6eXtZO0RbdQO5Hi2/KLYCAElDXVvsS44fdl3IGV/hzZFhHoPtYrJsFu NSHIBsUtM4fvzZ6XRZntz0qOPEe1AvGRbMlXSr1u9N2VvHA4ZYhA4CwBYthg+rnq/+aY 0QmkY+IiIzvZOnyoadPBzHHKXtj+RJVvv08X+jEevNCJ9J38sd9nUtfSqsnb0WOPR6Fh J+xW6vZRAtEl6I4q27U6LXeKnxLQt04CaNHuDeyj57EM73snhHqvln2hXC4lIVkdAHNQ KlOw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n11-20020a170902d2cb00b0015eab1c592dsi2946695plc.517.2022.05.02.16.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:07:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C2A822CCA0; Mon, 2 May 2022 16:07:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385860AbiEBPho (ORCPT + 99 others); Mon, 2 May 2022 11:37:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358130AbiEBPhm (ORCPT ); Mon, 2 May 2022 11:37:42 -0400 Received: from mail.pcs.gmbh (mail.pcs.gmbh [89.27.162.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B285BDF81; Mon, 2 May 2022 08:34:09 -0700 (PDT) Received: from mail.csna.de (mail.csna.de [89.27.162.50]) by mail.pcs.gmbh with ESMTPA ; Mon, 2 May 2022 17:34:03 +0200 Received: from EXCHANGE2019.pcs.ditec.de (mail.pcs.com [89.27.162.5]) by mail.csna.de with ESMTPA ; Mon, 2 May 2022 17:34:03 +0200 Received: from EXCHANGE2019.pcs.ditec.de (192.168.8.214) by EXCHANGE2019.pcs.ditec.de (192.168.8.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 2 May 2022 17:34:03 +0200 Received: from lxtpfaff.pcs.ditec.de (192.168.9.96) by EXCHANGE2019.pcs.ditec.de (192.168.8.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22 via Frontend Transport; Mon, 2 May 2022 17:34:03 +0200 Date: Mon, 2 May 2022 17:34:03 +0200 From: Thomas Pfaff To: Thomas Gleixner CC: , , Marc Zyngier , Lukas Wunner Subject: Re: [PATCH v3] irq/core: synchronize irq_thread startup In-Reply-To: <87mtg0m2jb.ffs@tglx> Message-ID: References: <552fe7b4-9224-b183-bb87-a8f36d335690@pcs.com> <87mtg0m2jb.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-KSE-ServerInfo: EXCHANGE2019.pcs.ditec.de, 9 X-KSE-AntiSpam-Interceptor-Info: white sender email list X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 02.05.2022 14:16:00 X-KSE-BulkMessagesFiltering-Scan-Result: protection disabled X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2 May 2022, Thomas Gleixner wrote: > But free_irq() stopped issuing synchronize_irq() with commit > 519cc8652b3a ("genirq: Synchronize only with single thread on > free_irq()"). And that turns out to be the root cause of the problem. > I should have caught that back then, but in hindsight .... > > While the proposed patch works, I think the real solution is to ensure > that both the hardware interrupt _and_ the interrupt threads which are > associated to the removed action are in quiescent state. This should > catch the case you observed. I can confirm that your patch works. And it also explains why I never had this issue on a 4.4 kernel with realtime patch ... > --- > Subject: genirq: Quiesce interrupt threads in free_irq() > From: Thomas Gleixner > Date: Mon, 02 May 2022 15:40:25 +0200 > > Fill void... > > Fixes: 519cc8652b3a ("genirq: Synchronize only with single thread on free_irq()") > Signed-off-by: Thomas Gleixner > --- > kernel/irq/manage.c | 25 +++++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > --- a/kernel/irq/manage.c > +++ b/kernel/irq/manage.c > @@ -1914,6 +1914,22 @@ static struct irqaction *__free_irq(stru > */ > __synchronize_hardirq(desc, true); > > + /* > + * Wait for associated interrupt threads to complete. This cannot > + * use synchronize_irq() due to interrupt sharing in the PCIe > + * layer. See 519cc8652b3a ("genirq: Synchronize only with single > + * thread on free_irq()") for further explanation. > + */ > + if (action->thread) { > + unsigned int thread_mask = action->thread_mask; > + > + if (action->secondary) > + thread_mask |= action->secondary->thread_mask; > + > + wait_event(desc->wait_for_threads, > + !(atomic_read(&desc->threads_active) & thread_mask)); > + } > + > #ifdef CONFIG_DEBUG_SHIRQ > /* > * It's a shared IRQ -- the driver ought to be prepared for an IRQ > @@ -1931,10 +1947,11 @@ static struct irqaction *__free_irq(stru > #endif > > /* > - * The action has already been removed above, but the thread writes > - * its oneshot mask bit when it completes. Though request_mutex is > - * held across this which prevents __setup_irq() from handing out > - * the same bit to a newly requested action. > + * The action has already been removed above and both the hardware > + * interrupt and the associated threads have been synchronized, > + * which means they are in quiescent state. request_mutex is still > + * held which prevents __setup_irq() from handing out action's > + * thread_mask to a newly requested action. > */ > if (action->thread) { > kthread_stop(action->thread); > > > Tested-by: Thomas Pfaff Thank you, Thomas