Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3605942rwd; Mon, 29 May 2023 13:33:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6OreSAeAnRMQsRlztoyztEPu1xOj613wLU0ORCtDwAWdTVW1Gc2h0oETOWEqiBkej5KXjF X-Received: by 2002:a05:6a00:140b:b0:64f:764e:bbd9 with SMTP id l11-20020a056a00140b00b0064f764ebbd9mr861588pfu.3.1685392387572; Mon, 29 May 2023 13:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685392387; cv=none; d=google.com; s=arc-20160816; b=eBTvx2J7AC6DI1PVikxvEsOf0jwqqJjvpv+Rn79XfHor2/YbY4wRlcUe5LydNXqASp hMCPG5A7G1CaO5F2J9ifzhf7Kd0vozn3RH1RpkTl8BcAAp25DSNwsVD1X73ssFfmThW+ x1E2Q0iMyis3vnIaBjxJHf01VMDKhXc7YWGz648EELoYCFXPTYEsKv8BDFzjPRcgqAG3 wS8H9ayUneUuKfD6S5bstkTnprJ3Aowra4CXv0vJPu8XL3HW+LrfHRPUCClWYYCB38oe QIBxl7GCrdLD+f9pGpv6HI2y47wZ9Mt4tUYUxL+jATWdO505xWYeGaekVcOAW/hvfqyV cjVg== 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 :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=aLTlfptI5P4dBPx3/ykp9SW+K0hdhL8BSFcrWJbpq1o=; b=d6QPZ94XUXa3p8kiZRhZuOmCFMCKA9NZ/nywi57hiEB6Do4NsGOYMLQndwGd/R+SDX IwJh+SYVhfBVMShCvcjhXJKPraD76ydS7xiA7jU83j/0HoxI5vUrtt0mStEJAas7Z7tX YOvacStuagQD/kiSoUw1lezy3W9dN2BXDxM1wb6vuXsnBADIlAlGweD90zTgo210EnVN 7RGrwxN7Z+z5vWhxKfHnD3UyC0eIJrhEh4c9SRhO+RCp+VsTwZtRY/YCMIMLEcQN/hqR EPBeNb2Dn2P1C1t+lS955iafphN/RFSPNwcMg9B2S/HkV5XqC71fXpQIhtXlcOJodPtV QPxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="iwr+Q/ML"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=02KjXCeR; 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 bs185-20020a6328c2000000b0052c2b1efee2si4132962pgb.339.2023.05.29.13.32.55; Mon, 29 May 2023 13:33:07 -0700 (PDT) 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="iwr+Q/ML"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=02KjXCeR; 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 S229513AbjE2UTL (ORCPT + 99 others); Mon, 29 May 2023 16:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjE2UTK (ORCPT ); Mon, 29 May 2023 16:19:10 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A8DBB7 for ; Mon, 29 May 2023 13:19:09 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685391547; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aLTlfptI5P4dBPx3/ykp9SW+K0hdhL8BSFcrWJbpq1o=; b=iwr+Q/ML/D8d8O5bVDJayEMs9gt/0svawzDlFAq+sOL3+2Lop2oyKmPOGTir3uKirlS2/I dMvnMdgc2M81lv6Tsa99QvEHFkKEfOKvvX+32uF3DqJU2gsfFRhOYE5jzcqJNKpuy7ajC/ ybXJoTMVnQM4c5ysJjSzPvucI4gZ4V5PJ5I6Bb2104F1sYPIGYLsqDx6p6LuMr3iRc2XLN O7WNogDSYu6Vr+LXWeaaI0BvglPvffKyXaHyIRM6mOAgCWa9ijYMXJhp8iPLbqDw3jEs5Z h4DhGHH8tMRe2QfyPO0YfwnL1aZmak6GnyakCoUMEhZmWxey2iJPz49nYWntSw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685391547; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aLTlfptI5P4dBPx3/ykp9SW+K0hdhL8BSFcrWJbpq1o=; b=02KjXCeR0pyA0usSuRg6JvkN7CsI2kUNdtIvuzTodsVj7xQAQFn2DMSJ5BIiC0CU1LxisH B6hQnlEhseROKKDA== To: Huacai Chen Cc: Marc Zyngier , Huacai Chen , Bjorn Helgaas , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Xuefeng Li , Jiaxun Yang Subject: Re: [PATCH 1/2] genirq/msi, platform-msi: Adjust return value of msi_domain_prepare_irqs() In-Reply-To: References: <20230527054633.704916-1-chenhuacai@loongson.cn> <20230527054633.704916-2-chenhuacai@loongson.cn> <87pm6llvm6.ffs@tglx> <86fs7gdhid.wl-maz@kernel.org> <87ilcblc72.ffs@tglx> Date: Mon, 29 May 2023 22:19:06 +0200 Message-ID: <878rd6lwlh.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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,T_SCC_BODY_TEXT_LINE 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 Huacai! On Mon, May 29 2023 at 17:36, Huacai Chen wrote: > On Mon, May 29, 2023 at 5:27=E2=80=AFPM Thomas Gleixner wrote: >> By default you allow up to 256 interrupts to be allocated, right? So to >> prevent vector exhaustion, the admin needs to reboot the machine and set >> a command line parameter to limit this, right? As that parameter is not >> documented the admin is going to dice a number. That's impractical and >> just a horrible bandaid. > > OK, I think I should update the documents in the new version. Updating documentation neither makes it more practical (it still requires a reboot) nor does it justify the abuse of the msi_prepare() callback. The only reason why this hack "works" is that there is a historical mechanism which tells the PCI/MSI core that the number of requested vectors cannot be allocated, but that there would be $N vectors possible. But even that return value has no guarantee. This mechanism is ill defined and really should go away. Adding yet another way to limit this via msi_prepare() is just proliferating this ill defined mechanism and I have zero interest in that. Let's take a step back and look at the larger picture: 1) A PCI/MSI irqdomain is attached to a PCI bus=20=20 2) The number of PCI devices on that PCI bus is usually known at boot time _before_ the first device driver is probed. That's not entirely true for PCI hotplug devices, but that's hardly relevant for an architecture which got designed less than 10 years ago and the architects decided that 256 MSI vectors are good enough for up to 256 CPUs. The concept of per CPU queues was already known at that time, no? So the irqdomain can tell the PCI/MSI core the maximum number of vectors available for a particular bus, right? The default, i.e if the irqdomain does not expose that information, would be "unlimited", i.e. ULONG_MAX. Now take that number and divide it by the number of devices on the bus and you get at least a sensible limit which does not immediately cause vector exhaustion. That limit might be suboptimal if there are lots of other devices on that bus which just require one or two vectors, but that's something which can be optimized via a generic command line option or even a sysfs mechanism. Thanks, tglx