Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp490419rwb; Wed, 16 Nov 2022 03:49:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BQM3q7JUVQPJWe83NvKBUu2xk7TyO867tPqeSJA+h/MgkdOn6N1GGccPlFwvZj8D2nvBP X-Received: by 2002:a62:5b86:0:b0:56d:8d19:f331 with SMTP id p128-20020a625b86000000b0056d8d19f331mr23170949pfb.7.1668599371111; Wed, 16 Nov 2022 03:49:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668599371; cv=none; d=google.com; s=arc-20160816; b=CfALPuiRr38Xo5eq5/lgu9sye8MdIX6K5SIEYX0Ew1tExGsx+/i1s+pNIcc2jG5BnE QTP/quZiGeywEFYMptmJ/jNj1w/oqixOTr/N4BYjxi8x4IDlk6+YgTI7Qd4p4JLkBLmN s7jKdlywXGIHzP0iRKZwZ1dyhgfWrZS1V4qXi4ZDOT9RBd7d9D9Esm+3E7LybRMZ7kxL SMVp5x8HPl7GmvjBbf9Vi9IR5wfxknFBsqAZDlrOOLnJ4CjA8gQuaUx8ABEo33ymOs2i C/B01R5OQg1CgARlShkcyhMmmC1nEm8Zy6FL7kgqkO1Ji/s4ymUT8nJKWVQ7FhHnf1pd gPUg== 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=QX2SKCrid73QyxVgZp3pXrhrbHc1mgUmMeIiTTjDIJ8=; b=OCxx8x0ZF9T/bjaDNGup4ziD4xhBXfvrDJqUxhUINevTfN/5mYLVboVt0bdNAWzGp5 SY0QkodMDWWQd99AQBl6dzrxsgidqRk7FVA7F9g9+d3WMDR5jb3YR09+PSgvLJJSzk4j Ap/LUaWrJWMkokznARb53NGeZ1XsX2aIJmUrOcIFNgErUCQL0C7LLYL1RoQ+pjTM3tF3 Fn2njxNv83RatjzV/t680QMnPtct5+m9TzzghyS+XohAwvA6uGNj0AuUZJZ/oieArIHD k4bbqnZ2MELeIqTRYxMth1bYrh9RhT4vEHFpKcK6Q1yYpHSzUtbU58kQ2bf3n5lcoiXv RnkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Lhlt6L0x; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=YMNl0EUQ; 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 q3-20020a056a00088300b0056e4c95266bsi14226492pfj.77.2022.11.16.03.49.19; Wed, 16 Nov 2022 03:49:31 -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=Lhlt6L0x; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=YMNl0EUQ; 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 S238793AbiKPKzJ (ORCPT + 91 others); Wed, 16 Nov 2022 05:55:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238649AbiKPKyb (ORCPT ); Wed, 16 Nov 2022 05:54:31 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D069DCDA for ; Wed, 16 Nov 2022 02:43:26 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668595405; 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=QX2SKCrid73QyxVgZp3pXrhrbHc1mgUmMeIiTTjDIJ8=; b=Lhlt6L0xF38lo/Id90Tb6KyW2KU0rhGNz7/AFj/bhP6vIB4tWw+GgjHaijmqEXtLJEnGSg wxNKyc8vzxmn4KmezESnUk8vYrGQDJ9rd01W2U1fXJ1EINL75wEXtxMpDi4t5hPjrwXWdY D+NIx5LS+1K+nNNkM5CLQWy47gbypYptGF4RGW39g+ZuIBzKA9MR2qPRyOY8ufajzPEDHd 3vd+AbR7EpjIZK4bWd/aOfC6vWwiIaY9l4HXoSkU5CR+sgomimoU7T6EwYfg27uAHgf6aU VhMZ5mE4hd0AXg32zbq3LDgQyzgZkbReHEXKAeKYrrjBTtXvpEHWs/13byeQIg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668595405; 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=QX2SKCrid73QyxVgZp3pXrhrbHc1mgUmMeIiTTjDIJ8=; b=YMNl0EUQ4vnNNkN/qmrs64zL+FbqgwsjdyiNF7NJ+oRf/5XOqxVL3RM+Hgd8eqh+r4nvYN wC3etXsLenLQosAQ== To: "Michael S. Tsirkin" Cc: Angus Chen , "linux-kernel@vger.kernel.org" , Ming Lei , Jason Wang Subject: Re: IRQ affinity problem from virtio_blk In-Reply-To: <20221115183339-mutt-send-email-mst@kernel.org> References: <87v8nfrhbw.ffs@tglx> <20221115174152-mutt-send-email-mst@kernel.org> <87sfijrf9o.ffs@tglx> <87o7t7rec7.ffs@tglx> <20221115183339-mutt-send-email-mst@kernel.org> Date: Wed, 16 Nov 2022 11:43:24 +0100 Message-ID: <87leobqiwj.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 Tue, Nov 15 2022 at 18:36, Michael S. Tsirkin wrote: > On Wed, Nov 16, 2022 at 12:24:24AM +0100, Thomas Gleixner wrote: >> I just checked on a random VM. The PCI device as advertised to the guest >> does not expose that many vectors. One has 2 and the other 4. >> >> But as the interrupts are requested 'managed' the core ends up setting >> the vectors aside. That's a fundamental property of managed interrupts. >> >> Assume you have less queues than CPUs, which is the case with 2 vectors >> and tons of CPUs, i.e. one ends up for config and the other for the >> actual queue. So the affinity spreading code will end up having the full >> cpumask for the queue vector, which is marked managed. And managed means >> that it's guaranteed e.g. in the CPU hotplug case that the interrupt can >> be migrated to a still online CPU. >> >> So we end up setting 79 vectors aside (one per CPU) in the case that the >> virtio device only provides two vectors. >> >> But that's not the end of the world as you really would need ~200 such >> devices to exhaust the vector space... > > Let's say we have 20 queues - then just 10 devices will exhaust the > vector space right? No. If you have 20 queues then the queues are spread out over the CPUs. Assume 80 CPUs: Then each queue is associated to 80/20 = 4 CPUs and the resulting affinity mask of each queue contains exactly 4 CPUs: q0: 0 - 3 q1: 4 - 7 ... q19: 76 - 79 So this puts exactly 80 vectors aside, one per CPU. As long as at least one CPU of a queue mask is online the queue is enabled. If the last CPU of a queue mask goes offline then the queue is shutdown which means the interrupt associated to the queue is shut down too. That's all handled by the block MQ and the interrupt core. If a CPU of a queue mask comes back online then the guaranteed vector is allocated again. So it does not matter how many queues per device you have it will reserve exactly ONE interrupt per CPU. Ergo you need 200 devices to exhaust the vector space. Thanks, tglx