Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp496121rwb; Wed, 16 Nov 2022 03:56:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf7F53WL8TKGKwEauU4q42GOMXb+mqAtMJ8EHQZBjWq2h82OKYd7KMZfvFFGpBzzZZIVwppM X-Received: by 2002:a17:906:7203:b0:7ae:664a:a7d2 with SMTP id m3-20020a170906720300b007ae664aa7d2mr17426311ejk.676.1668599771279; Wed, 16 Nov 2022 03:56:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668599771; cv=none; d=google.com; s=arc-20160816; b=zS3LgQ67sPiHVjpeKTFLUHf+junIhKhaF49sbv+pEVwVBD3LGYry/WQmcvUsGRv+hJ oqO0ikOCg6LyQqj3QUpqtFZ0KD2ciowBDo13uoCXPdsFEofsExKBBn7LPxe9tIggQ4+V h9hFr6KAj+PepPc8eS7XpVuMnhNfzpaX+EbEqGNlqFxm+pJZJVZ/UdhjxT+X2PSUE2lY 9XB944oPK0pTKpvEloPp/9wrJnyY39iscvrPFg4p/4EH+i9FfHXMUkpE9aIbEdhTls07 5csd9pBVY767k6dhE024RV92UO2TuI3xLhlo5/8+3tgvqMj/O4bdG0c0mHky07kX13Xp IpWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=76g6nnVy/er8XFtFjE8C/ZicZTPcSvobVbZwHsj2pVY=; b=ExRGi9kuXxC2fpfs4Df60uNWoOOtMnb1+7a6Q1EHPtQ0ucIv0vZhI9qSpwkXGHNHjV a1ym7KhP8hetCc7oNvBbBAfJLFzvgEkKpRXCI40qG2TOWuynWrQAokuGMRNenDG0/92x iRSaFjxEjoM56L1kHTLm+K3Lr86mCA6hHO0tD2KPzWdrJQJomPgr62cQTcP1fULWMINm Q1a/W9KY4ViiIOOQ4TiV2pWjTHxMrD3xNqxh4FLili7brUQ/uPGzsaA+eTYMRjQKiJ5Q OlPrzHB0Ulun1/vNnkk3N72n9MMCDKSifUppqruXMwd1lkyAxQNEYB5P7Gt+cXhXAIQE lrqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TobUHZzs; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cq22-20020a056402221600b0045fca739593si11858341edb.188.2022.11.16.03.55.49; Wed, 16 Nov 2022 03:56:11 -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=@redhat.com header.s=mimecast20190719 header.b=TobUHZzs; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232057AbiKPLuO (ORCPT + 91 others); Wed, 16 Nov 2022 06:50:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237640AbiKPLtr (ORCPT ); Wed, 16 Nov 2022 06:49:47 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 043DAB1C1 for ; Wed, 16 Nov 2022 03:35:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668598536; 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=76g6nnVy/er8XFtFjE8C/ZicZTPcSvobVbZwHsj2pVY=; b=TobUHZzstEwoDlnOAaaF1fKEBpDsY8DbmFz4EdzmqpLejii3r/8t480brRosujxdH6zRvh d/zSvuwkYT/Ih/rsAP0LsieLKsKOCmevv/PwW8Ocxqla0MAEHYM+GcO6gwgAuPo72h7vYO AGoXPixiuM3yJ02VBj769yKHNZNoR8Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-OAQOQCrIPZOWLHiUvlxydw-1; Wed, 16 Nov 2022 06:35:33 -0500 X-MC-Unique: OAQOQCrIPZOWLHiUvlxydw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06EFF185A78B; Wed, 16 Nov 2022 11:35:33 +0000 (UTC) Received: from T590 (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B6AF2166B29; Wed, 16 Nov 2022 11:35:28 +0000 (UTC) Date: Wed, 16 Nov 2022 19:35:23 +0800 From: Ming Lei To: Thomas Gleixner Cc: "Michael S. Tsirkin" , Angus Chen , "linux-kernel@vger.kernel.org" , Jason Wang Subject: Re: IRQ affinity problem from virtio_blk Message-ID: References: <87v8nfrhbw.ffs@tglx> <20221115174152-mutt-send-email-mst@kernel.org> <87sfijrf9o.ffs@tglx> <87o7t7rec7.ffs@tglx> <20221115183339-mutt-send-email-mst@kernel.org> <87leobqiwj.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87leobqiwj.ffs@tglx> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Wed, Nov 16, 2022 at 11:43:24AM +0100, Thomas Gleixner wrote: > 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. Hi Thomas, I am wondering why one interrupt needs to be reserved for each CPU, in theory one queue needs one irq, I understand, so would you mind explaining the story a bit? Thanks, Ming