From patchwork Wed Mar 17 14:38:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 403768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17D87C2BA2B for ; Wed, 17 Mar 2021 14:41:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9C0164F50 for ; Wed, 17 Mar 2021 14:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232042AbhCQOlA (ORCPT ); Wed, 17 Mar 2021 10:41:00 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:50684 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbhCQOkn (ORCPT ); Wed, 17 Mar 2021 10:40:43 -0400 Message-Id: <20210317143859.513307808@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1615992042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8QMGgYnI70uugMofu3OLkpYTvIgYFZIdrl1oEimDU2o=; b=rmgC+l+KeJUNxw7DayqAHUq9NF4ItzQL4kWBGhC0Blnj6lOs0ihHR0KopYyOUd5vb/KOvx zPNQAfPKO5lC4/eiC3idrqjeA1ENh4sWv7IRnlv5/KTmnACRTW8pNJhZhTIGVxFcZwnYEk 5WCU1lSPTYinnQ84+mmluEIIKxdFiRwbQ4VRGuvnIgMGRZjoFDvMxR8Vz4HA1pPalDco97 5xL1Umdr3qjxfNSeAIR8z1haObrJBE3PmqCqx66/+ZZ5CTSS+kjvAQprMBiqOQAPjRumeI kw+d9PNB6SX20f++KsknCyZttPjMCFdYM535vFiBHmGPu6eOLdUrhPizN2y05Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1615992042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8QMGgYnI70uugMofu3OLkpYTvIgYFZIdrl1oEimDU2o=; b=OBk0pWKATGPe0cnOU+iBZDG8oGm/nxdWDLtvPEsrsVytfpKq8sAidYOKW5xPy/oatjv9ki zClOj1w65s0FXnDg== Date: Wed, 17 Mar 2021 15:38:52 +0100 From: Thomas Gleixner To: LKML Cc: Johan Hovold , Eric Dumazet , Sebastian Andrzej Siewior , netdev , "David S. Miller" , Krzysztof Kozlowski , Greg Kroah-Hartman , Andy Shevchenko , Peter Zijlstra , linux-serial@vger.kernel.org Subject: [patch 1/1] genirq: Disable interrupts for force threaded handlers MIME-Version: 1.0 Content-transfer-encoding: 8-bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org With interrupt force threading all device interrupt handlers are invoked from kernel threads. Contrary to hard interrupt context the invocation only disables bottom halfs, but not interrupts. This was an oversight back then because any code like this will have an issue: thread(irq_A) irq_handler(A) spin_lock(&foo->lock); interrupt(irq_B) irq_handler(B) spin_lock(&foo->lock); This has been triggered with networking (NAPI vs. hrtimers) and console drivers where printk() happens from an interrupt which interrupted the force threaded handler. Now people noticed and started to change the spin_lock() in the handler to spin_lock_irqsave() which affects performance or add IRQF_NOTHREAD to the interrupt request which in turn breaks RT. Fix the root cause and not the symptom and disable interrupts before invoking the force threaded handler which preserves the regular semantics and the usefulness of the interrupt force threading as a general debugging tool. For not RT this is not changing much, except that during the execution of the threaded handler interrupts are delayed until the handler returns. Vs. scheduling and softirq processing there is no difference. For RT kernels there is no issue. Fixes: 8d32a307e4fa ("genirq: Provide forced interrupt threading") Reported-by: Johan Hovold Signed-off-by: Thomas Gleixner Cc: Eric Dumazet Cc: Sebastian Andrzej Siewior Cc: netdev Cc: "David S. Miller" Cc: Krzysztof Kozlowski Cc: Greg Kroah-Hartman Cc: Andy Shevchenko CC: Peter Zijlstra Cc: linux-serial@vger.kernel.org Cc: netdev --- kernel/irq/manage.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1142,11 +1142,15 @@ irq_forced_thread_fn(struct irq_desc *de irqreturn_t ret; local_bh_disable(); + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + local_irq_disable(); ret = action->thread_fn(action->irq, action->dev_id); if (ret == IRQ_HANDLED) atomic_inc(&desc->threads_handled); irq_finalize_oneshot(desc, action); + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + local_irq_enable(); local_bh_enable(); return ret; }