Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3409555pxf; Mon, 22 Mar 2021 05:57:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1QaO3KpW43wWDH2Ov+gvzZtUu1fmVr/Y6CGKJc5DqaY7S5VcaPVXHF9FfWoBYe1SivVtV X-Received: by 2002:a17:906:e16:: with SMTP id l22mr19094820eji.173.1616417839388; Mon, 22 Mar 2021 05:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616417839; cv=none; d=google.com; s=arc-20160816; b=bcGWDB3Th8tsw4rqVYv/KeXT1W+q9/ydkfK+YYPX3OoqmMvgCLIteUgyjWl0KY62pw pQVvDx4qNukMDxiquvLctSf0i7uhKPjdXlm4/uy8S2fIHBlgyKiUlsAFGGr6WqxOnJxR 2tK33EP5IR7dw1vlERVXS6YIirWCECblJpAfv+x6XL0odurcB7T2RlLI/WPiLTqFir1m eI0XsZhb/Z7j1+KTGLw7Vn+jb3C/Q6msCFHKLJddCLr7ML8R87ygGpY52+B5jwUxiHP9 wcqR3bCvWkAQXBRSqUKrM8lesK5YLYtqgqLz/Hp3jyc6/8VuextYoK5uCTJnExQk6Z6B HdYw== 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=swO/gu39VYEDStjUiExnA2L6cvTWLRB2QQi7m6QftSY=; b=vzAYnbaztxfNALT9kCTBwVPP2DL70K6H7vr9nZti7/Tm2mvzu8h4wZDSRKuDmS4eyk /MGRjl07br76PBeq9TwCWkWDGz4FGXSue5HARpspyXzT8vl2FQIRvEc+0f49v4TFBEmT 5PNam8K3DYJ0SzFI43HS5zuOqLmxOwlfgQB8UaUjeF97R29IMLwWk4Lteoy/g+9XBX9Y tih692xALBQCtTeSPKXXyvSHXQj5CGiJwCP12onrVV0uYBQY45ocN3N6uDNxKnWR0gZD zHZaxP7uFVWFTBUPeviaPeQ5aMMpVmfV++XvVck6GxLzusdQ0X3JD+XC9cmx/Qnz5QlE UFVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nNIzyqM9; 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 v5si10689561edr.596.2021.03.22.05.56.57; Mon, 22 Mar 2021 05:57:19 -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=nNIzyqM9; 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 S230055AbhCVMxt (ORCPT + 99 others); Mon, 22 Mar 2021 08:53:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:35514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232692AbhCVMnN (ORCPT ); Mon, 22 Mar 2021 08:43:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E1BED619D9; Mon, 22 Mar 2021 12:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616416872; bh=YdLyxp6fhlQYLz6pYfC/t2FkHexcokPN7Lb+Pp/CBDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nNIzyqM9eOjn/Orh3vdlC72gES/Kqp4vz25Qs0T5AxYbtQo2CqnrxGnkzrtJqucLR /0UOCVN9FGdmwRrJH8HuoqvUGjo5BVUAYLNALIaMmQsKqNdsplo6Y+ttz0zdLHZi17 I8i4p1yaDQko+7R7WH6YrAkM2hDDxPhlFuyvXhJs= 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 5.10 156/157] genirq: Disable interrupts for force threaded handlers Date: Mon, 22 Mar 2021 13:28:33 +0100 Message-Id: <20210322121938.687591951@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121933.746237845@linuxfoundation.org> References: <20210322121933.746237845@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 @@ -1072,11 +1072,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; }