Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp71477rwb; Wed, 9 Nov 2022 20:10:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf4aqwNCmFB2dW8JhN+FbqqH23gxgj0tKBw8IX4teISgTU0LLzNWO4qcTSwuWtwJxWwi+IOy X-Received: by 2002:a17:90b:709:b0:217:3ddc:3d39 with SMTP id s9-20020a17090b070900b002173ddc3d39mr30656911pjz.120.1668053453778; Wed, 09 Nov 2022 20:10:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668053453; cv=none; d=google.com; s=arc-20160816; b=FVBm6FNmpiNk9jSRX/kkBp+TZsZViMCSUULHdgO1owiYAKpMlfPJFwMWq2q+ToWvGN nYJWgJjnjWuMTu3alxSVR0TItDgmwvrKqS9Wv0uAdGyqVituH5o9FOiqoSjSALjzSPLs K/p9wlMzjjffD9Xvq7kI0s7bVHe3n2Se2QVbcf8VQWh7sDnGndyB+zen1z12lo4z5L+i TnvvJbj8ZCbHwMxirxba4A6oKmRlPA9e/qk8kmHkhRx3DkikxZTEJz+nz/T5zyiUMhAm QNSBPK5f+UM3vqzc8CtLQr6tVXBAsLk9bnWV2WMR0DvGoNNXhF5USNcdInvux0ipH7aR IMPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=l3dWBPDoB0ZUfUc2NPMRUPMvZHbfPQx8atm9DV2mCp4=; b=nwRK44i1r1wup3zi8+1LKg5hqJrWMRrDGKse8ojzAVV63oThy9sqbKO8bwcdNzop+J nE2LCFJ0EbVdbBKJjJ4Cav/hgvrmAGjUADMCrtGRoP2rsPlrznjy11r6RUIlX8jmV8bz /WpRgFf+shjoyAWhq40hVY7a2H+psKqr4AxwvjDAI2xwEeGCuJj9CbvgzIrDCMmYZ5Ex WzOyF1AL8Z2NjeRUYv39oQHMM262ancSJU15B1QiC/WKkSXWLJ0839hAfTemxx40RDxs por4+TlWP0kN3KJD/72+dEks/nFHSWrtvBRTtjJbXIL5uQE0yXudky7kVstQ9XlG/z9I BMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UOJct0+v; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Vad1AOb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p20-20020a056a000b5400b005633c373dcbsi20472422pfo.147.2022.11.09.20.10.42; Wed, 09 Nov 2022 20:10:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UOJct0+v; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Vad1AOb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232320AbiKJDBx (ORCPT + 92 others); Wed, 9 Nov 2022 22:01:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbiKJDBv (ORCPT ); Wed, 9 Nov 2022 22:01:51 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9114BB1F4 for ; Wed, 9 Nov 2022 19:01:50 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668049308; 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: in-reply-to:in-reply-to:references:references; bh=l3dWBPDoB0ZUfUc2NPMRUPMvZHbfPQx8atm9DV2mCp4=; b=UOJct0+vpWArP3xgfjcbihjiIqvQrxLzJ7PANf4CWcRwLU86Pw1XvlCPcAgXNr4RZ+yXWE gw8Mxxx9O9dxNXz8tsiPlJX5Re/wvgRsV1E3um0mrHecn2sMBGb2XTU/vAH5SCp78UnQf9 A0oXuL1awutGXlPxaX9Ls8vGtnL8HqubjUZoqs7AI/PugmpOZlmej4tX+h6N+UlNOfRDG8 weGOs5hmHOwzLZUxE0Z658g5rp4bFU4+pxJsj8v4zQNfKU0woOT3hAwSAWgdUCrPXNOsVX k5jreqeknpXKUAK5Pz/y8XcC2kkoBWCKLC6OQnD6CUUeD0YvoW1KfI++JKd1Bg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668049308; 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: in-reply-to:in-reply-to:references:references; bh=l3dWBPDoB0ZUfUc2NPMRUPMvZHbfPQx8atm9DV2mCp4=; b=Vad1AOb44F6L7Xpe2nnoNhtCD7SFBNucd2C2g8Gqxb/cRy7ZxXWbvvFMfgEWKY+NFEoF9S F5KeO+esaXjbn4AQ== To: Chen Lifu , linux-kernel@vger.kernel.org Cc: chenlifu@huawei.com Subject: Re: [PATCH -next] genirq: Add SPARSE_NR_IRQS Kconfig option In-Reply-To: <20220930085839.315461-1-chenlifu@huawei.com> References: <20220930085839.315461-1-chenlifu@huawei.com> Date: Thu, 10 Nov 2022 04:01:47 +0100 Message-ID: <87iljn8qck.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 30 2022 at 16:58, Chen Lifu wrote: > On a large-scale multi-core and NUMA platform, more than 1024 cores and > 16 NUMA nodes for example, even if SPASE_IRQ is selected to increase the > number of interrupt numbers by 8196 base on NR_IRQS, the interrupt numbers > requirement cannot be met. Therefore, make the number of sparse interrupt > numbers configurable. Why? Let me walk you through: # git grep '#define\sNR_IRQS' arch/x86 arch/x86/include/asm/irq_vectors.h:#define NR_IRQS_LEGACY 16 arch/x86/include/asm/irq_vectors.h:#define NR_IRQS \ arch/x86/include/asm/irq_vectors.h:#define NR_IRQS (NR_VECTORS + IO_APIC_VECTOR_LIMIT) arch/x86/include/asm/irq_vectors.h:#define NR_IRQS (NR_VECTORS + CPU_VECTOR_LIMIT) arch/x86/include/asm/irq_vectors.h:#define NR_IRQS NR_IRQS_LEGACY Versus: # git grep '#define\sNR_IRQS' arch/arm64 Empty. Oooops. Where does it get the define from on which the define you try to influence with your config knob depends on, i.e. # define IRQ_BITMAP_BITS (NR_IRQS + 8196) Good question, right? But not rocket science to answer. If there is no architecture specific definition then there is a close to 100% probability that there is a generic fallback define in include/asm-generic/. And indeed # git grep '#define\sNR_IRQS' include/ include/asm-generic/irq.h:#define NR_IRQS 64 So let's do the math: (64 + 8196) / 1024 ~= 8 Unsurprisingly enough this does barely cope for the per CPU requirements of an ARM64 system. Of course if you add a proper amount of periphery then you surely run out of interrupt numbers.... Now let me go back to the grep I did on x86. That matches on some lines w/o context, but let me show you the full context of the relevant configuration of a enterprisy machine with all bells and whistels here for illustration: #define NR_VECTORS 256 #define MAX_IO_APICS 128 #define CPU_VECTOR_LIMIT (64 * NR_CPUS) #define IO_APIC_VECTOR_LIMIT (32 * MAX_IO_APICS) So in the case of a NR_CPUS=1024 configuration this evaluates to: CPU_VECTOR_LIMIT 64*1024 = 65536 IO_APIC_VECTOR_LIMIT 32*128 = 4096 and then the relevant NR_IRQS define: #define NR_IRQS \ (CPU_VECTOR_LIMIT > IO_APIC_VECTOR_LIMIT ? \ (NR_VECTORS + CPU_VECTOR_LIMIT) : \ (NR_VECTORS + IO_APIC_VECTOR_LIMIT)) evaluates to: (65536 > 4096) ? (256 * 65536) : (256 * 4096) = 256 * 65536 = .... While the resulting number is silly large, you should be able to figure out the fundamental difference of the approach to limit the number of interrupts between the x86 and the arm64 case, right? There is no good reason to copy the insanely large numbers of x86 but you surely can figure out how the key component in that calculation which takes NR_CPUs into account avoids another random uncomprehensible configuration knob: # define IRQ_BITMAP_BITS (NR_IRQS + 8196) No? Thanks, tglx