Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3298635pxb; Fri, 12 Feb 2021 14:51:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoqu3MdrkHtK6rvvd+PvUX11flDnlBRRUgCbHIYHsPhdjTuAzPLiMgQpM1ma3xaTtaWx8+ X-Received: by 2002:a05:6402:3508:: with SMTP id b8mr5577908edd.341.1613170284411; Fri, 12 Feb 2021 14:51:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613170284; cv=none; d=google.com; s=arc-20160816; b=LT2oIuYLjQTVZVAkTWKm6XfRG3c+Yvbb0CdAzcBxgQtwJ6zACTzEyxs+xnPIUqJTpj a4LK2C7J7I7h3cvQHWnomFdTFz7YC/d5i4EYDuV1l6OyaMD+KLhxF6GjpvleMAzsLgzs DSlIw0ZEEsFST6L+uTGyR4ZEs0ckMHbdlYMuNyDTnUcWbcaOPFgxwRH1wWSIwNe+FY9J Wq0HV2N2SRQhIQoWGsHPUwGulF2xBBO2aB1E4EJBBAKZAkD59J0XxZfLEutPzhrunnsm jt9PMPMI7lPRsYIuwOI5KwJjX7oZfxERiVg1nQ+UlGUPSrKJtDgzFV+XJnAbYNE2/574 k9Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Veo7dH+E7GrTa6sxxyAyT+mApImggrUqFBu4gbPkY6o=; b=DzIErwvTde0itg4Qr9UQO4aNelifckB3HffdpMjB8keKYpiQk4xDwyWTmKoyEeCjwH k5dbbckcDHPg398ScjFSZZwZGTHSG3gXSuCvzRkqzWBgl16FkC0dJe75A05CodhnvSwf Q3EoQtpJ2VUcrzYbdV0rAMSLXnltaBYEAUc0/CLGgK5Yo1U5q2mf8qMQbQe48hf4UdOZ O2L838X1xKm/T5hfa3Faxb1p3kjRZJr7stiUscrr0TpOTtO+Ase63VczgLf7r1cZ1RzH SmiyACuqhJLinEb5/kogEtk/U/gAy5ndxbglCDMpwcPwLrWH1vSJ9HIWrjRd/R7Nt5t2 4wNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sGNJ1Fzw; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si7304768edr.61.2021.02.12.14.51.01; Fri, 12 Feb 2021 14:51:24 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=sGNJ1Fzw; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232159AbhBLWr0 (ORCPT + 99 others); Fri, 12 Feb 2021 17:47:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:45330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232235AbhBLWfS (ORCPT ); Fri, 12 Feb 2021 17:35:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 407A964EA0 for ; Fri, 12 Feb 2021 22:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613169278; bh=WDyM20Jkx5Lw2bXDBhtM/Wh7714B42NhueKvph+Nmws=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sGNJ1FzwLlsK9G9bklHujIthTsFGFY/yIAcdMaLkUTYUHn4Y+F3epfaRcd2ld94+w 7ub8pmFQERVj0RUZ1n10vEfBhPFGzTBG3VfX1tnqFijvhG+HiUMgyQDtMhFbbiJVTt KpdlMALtH7f/zCeoAjlR75nryl/MSpTaFohmPuhXogJk+ZFNg+cdLlytfMATL0sQF3 DZgaRs9NEVnnvhynihRM2njK6ZFQu9dJikBwLErLfH3zCAo2uwhy5uQLyBTnz1XySE Y624LG46WeKxU2s4fdYsIlwOPEYox2lbjKw30gz8M0Q0qZiwgOYhsqLZdF4YTxjD5s PiUQRdppEV+pA== Received: by mail-oi1-f172.google.com with SMTP id k204so1371769oih.3 for ; Fri, 12 Feb 2021 14:34:38 -0800 (PST) X-Gm-Message-State: AOAM530rBKdDJFREpXqJ3jkNvbF9+fXMRZi1LOplR5G7DlDHiq4a+XOB 60YyvdhT1mo+ybWxF4Vf4D5dKEp8j4AdFjiuB5E= X-Received: by 2002:aca:e103:: with SMTP id y3mr1198690oig.11.1613169277530; Fri, 12 Feb 2021 14:34:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Arnd Bergmann Date: Fri, 12 Feb 2021 23:34:21 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC] IRQ handlers run with some high-priority interrupts(not NMI) enabled on some platform To: "Song Bao Hua (Barry Song)" Cc: "tglx@linutronix.de" , "gregkh@linuxfoundation.org" , "arnd@arndb.de" , "geert@linux-m68k.org" , "funaho@jurai.org" , "philb@gnu.org" , "corbet@lwn.net" , "mingo@redhat.com" , "linux-m68k@lists.linux-m68k.org" , "fthain@telegraphics.com.au" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 12, 2021 at 2:18 AM Song Bao Hua (Barry Song) wrote: > So I am requesting comments on: > 1. are we expecting all interrupts except NMI to be disabled in irq handler, > or do we actually allow some high-priority interrupts between low and NMI to > come in some platforms? I tried to come to an answer but this does not seem particularly well-defined. There are a few things I noticed: - going through the local_irq_save()/restore() implementations on all architectures, I did not find any other ones besides m68k that leave high-priority interrupts enabled. I did see that at least alpha and openrisc are designed to support that in hardware, but the code just leaves the interrupts disabled. - The generic code is clearly prepared to handle nested hardirqs, and the irq_enter()/irq_exit() functions have a counter in preempt_count for the nesting level, using a 4-bit number for hardirq, plus another 4-bit number for NMI. - There are a couple of (ancient) drivers that enable interrupts in their interrupt handlers, see the four callers of local_irq_enable_in_hardirq() (all in the old drivers/ide stack) and arch/ia64/kernel/time.c, which enables interupts in its timer function (I recently tried removing this and my patch broke ia64 timers, but I'm not sure if the cause was the local_irq_enable() or something else). - The local_irq_enable_in_hardirq() function itself turns into a nop when lockdep is enabled, since d7e9629de051 ("[PATCH] lockdep: add local_irq_enable_in_hardirq() API"). According to the comment in there, lockdep already enforces the behavior you suggest. Note that lockdep support is missing on m68k (and also alpha, h8300, ia64, nios2, and parisc). > 2. If either side is true, I think we need to document it somewhere as there > is always confusion about this. > > Personally, I would expect all interrupts to be disabled and I like the way > of ARM64 to only use high-priority interrupt as pseudo NMI: > https://lwn.net/Articles/755906/ > Though Finn argued that this will contribute to lose hardware feature of m68k. Regardless of what is documented, I would argue that any platform that relies on this is at the minimum doing something risky because at the minimum this runs into hard to debug code paths that are not exercised on any of the common architectures. Arnd