Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3420336pxf; Mon, 22 Mar 2021 06:10:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU9V+A8VMugoCIWYReCpRExgpbjGfa4izhbJRgqU+O3c3icrGIq8nOkoxckFnEib0idIZd X-Received: by 2002:a17:906:b288:: with SMTP id q8mr19095546ejz.210.1616418604439; Mon, 22 Mar 2021 06:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616418604; cv=none; d=google.com; s=arc-20160816; b=0HYdcIk6zv/4ymP9/Q+bPngkpmDi8fuH3f52Vwca4Rx/ps8KYF3Xq1Gkw3TubqzNTf w/GMSoBty0qQ/tLLhgmqa+rVUtgzP7QiJe2/HSW1/h/35rLpvsdOOnHAsIVrEKkN3ltI G21ILbQLHn013dQ9ZGmL5BHHupjnAuuWB4vijpNoG7MeUNHLr/xgOl/DjIaUVX9BxB2L 17zL2BYXo2KYDxJRNGpHVHggxV0wS18ioIrXS2SvF1wNJFognJP0H/7OGy9art0KLvmP 2lnBtX5TM1UHv0H+ArxiqwgfOtVMu7DnIJDmHqwHBraeWCDR7cLkL08KwnH0GenTb2zD L4yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GGpRg+PmDh6h2iGKEd10bPonqP4Uvbyjhll2MO69h+4=; b=SjSAPRu+PokrAhDqF1IvK1jAEN9tu9mq4L+WahClARD/ZqouGmHGCtTgn+o2gyudB4 H7MUgty3o+0yCI1p5gnhLJEjCpofYTZKjuZjgJTxzMHUjyXD1MS3d4rahqLm8VexLzeL s7dCAmGXSitDV8garj0zQ5FUPv6K0KyhkCbqtjRR9VCpG+TYnE0kiZqhFzYuMaeHfTgI Fx3WATfJpEJnicd1+Yrfm0RZI5t2rgJ1ma5NSBLC/tZia3W5h6WADwYTbvJH9gtzwt99 CSHkBUPCS8Z18nuGbmdmalWttVH0aOaNEc+1VG6BGpmcRlcVsTxzjeqav0u7qW9lzmyF rNdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i+1QYtN7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p10si11070963edw.62.2021.03.22.06.09.40; Mon, 22 Mar 2021 06:10:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i+1QYtN7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233468AbhCVNIO (ORCPT + 99 others); Mon, 22 Mar 2021 09:08:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:47874 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbhCVMxm (ORCPT ); Mon, 22 Mar 2021 08:53:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6AD8D60C41; Mon, 22 Mar 2021 12:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616417246; bh=U6ZfX6nV1Hzo6GM4uM/Mqb54Q3FHy7Fx7i4GHRuP1TA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i+1QYtN7c+Vj3Bp0icNrqpHnuadNMzY+XLklWaIpvwmahOUquWh1VPFZwMcGqQi0C 4D6wEWi5tiERLWenyMUZWk5tAw/2X4NEt+VNDV9gfA3JFNDjBIAgRQneQ6VTKCaKjW zIg48pNyHyWzHDIqGd2XpvszwoNhB7qhGP7dIdy4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH 4.9 25/25] genirq: Disable interrupts for force threaded handlers Date: Mon, 22 Mar 2021 13:29:15 +0100 Message-Id: <20210322121921.197695032@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121920.399826335@linuxfoundation.org> References: <20210322121920.399826335@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner commit 81e2073c175b887398e5bca6c004efa89983f58d upstream. 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 Reviewed-by: Johan Hovold Acked-by: Sebastian Andrzej Siewior Link: https://lore.kernel.org/r/20210317143859.513307808@linutronix.de Signed-off-by: Greg Kroah-Hartman --- kernel/irq/manage.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -886,11 +886,15 @@ irq_forced_thread_fn(struct irq_desc *de irqreturn_t ret; local_bh_disable(); + if (!IS_ENABLED(CONFIG_PREEMPT_RT_BASE)) + 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_BASE)) + local_irq_enable(); local_bh_enable(); return ret; }