From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3F80C4167D for ; Sun, 12 Nov 2023 15:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231709AbjKLPIT (ORCPT ); Sun, 12 Nov 2023 10:08:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjKLPIP (ORCPT ); Sun, 12 Nov 2023 10:08:15 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6DC32D62 for ; Sun, 12 Nov 2023 07:08:12 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8569FC433C7; Sun, 12 Nov 2023 15:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699801692; bh=9dF+0JI/eQhGfiqVoGiTOUqlLKlURi7RIuQwNfR8aFU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cIp05Og0NKsLWtH/DJ6TtFoxq8flmM2NWanVktsP4EJ5BX2x2qsdsF2M7YRDndts+ lnnNBQV+ADRqpS6DoUG++u0M2ohMktp204LWwBCbCXUMHnbQO/VGfDAOLyl+QTxagk ffpqf8A0pG4Wdcnne4ePXdT7KVhjRXnZDW8FLqgRR46m1sMdg0rLyXnbzHFjcxgpSW Exnk9jkJt1C6y+P+kIJgurcSje8VpHh35ezM0uKkMH29DU+AuNkLvsQu9yQRNumDS4 ljD5ww9ufGt7zUf6GlevCjA6pQGTgI3FlOHJku3q+LF14Jznx6/RsyDV4ON0fGjJbv pMkd5OKAZYsDQ== Received: from [185.201.63.253] (helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r2C4H-00CSPQ-U1; Sun, 12 Nov 2023 15:08:10 +0000 Date: Sun, 12 Nov 2023 15:08:05 +0000 Message-ID: <87edgvxb56.wl-maz@kernel.org> From: Marc Zyngier To: Paran Lee Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, shjy180909@gmail.com, austindh.kim@gmail.com Subject: Re: [PATCH] irqdesc: Fail check on early_irq_init allocation. In-Reply-To: <1f6e21c1-7340-ed40-f2a7-66c063b453cb@gmail.com> References: <20231111170035.10386-1-p4ranlee@gmail.com> <87fs1bxe9h.wl-maz@kernel.org> <1f6e21c1-7340-ed40-f2a7-66c063b453cb@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.201.63.253 X-SA-Exim-Rcpt-To: p4ranlee@gmail.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, shjy180909@gmail.com, austindh.kim@gmail.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 12 Nov 2023 14:19:28 +0000, Paran Lee wrote: > On 2023-11-12 =EC=98=A4=ED=9B=84 11:00, Marc Zyngier wrote: >=20 > Thanks for the code review Marc! >=20 > I think function alloc_descs() in irqdesc.c has also alloc_desc() fail > handling, and there's kernel-wide code consistency checking for > allocation failures, and I thought it would be nice to mark it. alloc_descs() and early_irq_init() are very different beasts. The former can be used *at any time* over the kernel's lifetime, while the latter is only used *once*. This makes a whole lot a difference, don't you think? > So that the code is aware of it. >=20 > Even if it panics with a null derefence reference. Don't you think it is a bit pointless to trade a fatal error for another one? >=20 > > A failing allocation already results in a massive splat describing how > > the allocation failed. Further use of the NULL pointer will also > > result in a terminal oops, particularly if this happens this early in > > the boot sequence. > >=20 > > So what do these BUG_ON() calls buy us? > >=20 > > M. > >=20 >=20 > If anyone has any ideas on how to get a little fancier with the allocatio= n, > I'll send a v2 patch in that direction. It's not about being fancy. It is about being useful. Your BUG_ON()s are not making things any better for early allocation failures. A much better idea would be to *get rid* of early allocation failures altogether, by moving all architectures to SPARSE_IRQ and making sure that NR_LEGAY_IRQ is always zero, meaning there is nothing to allocate. That would be something useful. But adding random BUG_ON() based on the dogma that all allocations must be checked doesn't bring value to the kernel as a whole. M. --=20 Without deviation from the norm, progress is not possible.