From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y98ww-0003dE-1c for qemu-devel@nongnu.org; Thu, 08 Jan 2015 04:00:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y98wr-0005Qj-2x for qemu-devel@nongnu.org; Thu, 08 Jan 2015 04:00:13 -0500 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:50483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y98wq-0005N2-Rg for qemu-devel@nongnu.org; Thu, 08 Jan 2015 04:00:08 -0500 Received: by mail-wi0-f182.google.com with SMTP id h11so1814093wiw.3 for ; Thu, 08 Jan 2015 01:00:08 -0800 (PST) Sender: Paolo Bonzini Message-ID: <54AE4713.8060407@redhat.com> Date: Thu, 08 Jan 2015 10:00:03 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <201412311145449265941@tencent.com> In-Reply-To: <201412311145449265941@tencent.com> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] Fix irq route entries exceed KVM_MAX_IRQ_ROUTES List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?gbk?Q?=22kevinnma=28=C2=ED=CE=C4=CB=AA=29=22?= , qemu-devel On 31/12/2014 04:45, kevinnma(ÂíÎÄ˪) wrote: > Last month, we experienced several guests crash(6cores-8cores),qemu logs > display the following messages: > > qemu-system-x86_64: /build/qemu-2.1.2/kvm-all.c:976: > kvm_irqchip_commit_routes: Assertion `ret == 0' failed. > > After analysis and verification, we can confirm it's irq-balance > daemon(in guest) leads to the assertion failure.So start a 8 core guest > with two disks, execute the following scripts will reproduce the BUG quickly: > > vda_irq_num=25 > vdb_irq_num=27 > while [ 1 ] > do > for irq in {1,2,4,8,10,20,40,80} > do > echo $irq > /proc/irq/$vda_irq_num/smp_affinity > echo $irq > /proc/irq/$vdb_irq_num/smp_affinity > dd if=/dev/vda of=/dev/zero bs=4K count=100 iflag=direct > dd if=/dev/vdb of=/dev/zero bs=4K count=100 iflag=direct > done > done > > QEMU setup static irq route entries in kvm_pc_setup_irq_routing(),PIC and > IOAPIC share the first 15 GSI numbers,take up 23 GSI numbers,but take up 38 > irq route entries.When change irq smp_affinity in guest,a dynamic route > entry may be setup,the current logic is:if allocate GSI number succeeds, > a new route entry can be added.The available dynamic GSI numbers is > 1021(KVM_MAX_IRQ_ROUTES-23),but available irq route entries is only > 986(KVM_MAX_IRQ_ROUTES-38),GSI numbers greater than route entries. > irq-balance's behavior will eventually leads to total irq route entries > exceed KVM_MAX_IRQ_ROUTES,ioctl(KVM_SET_GSI_ROUTING) fail and > kvm_irqchip_commit_routes() trigger assertion failure. I have two questions: 1) why isn't the existing check in kvm_irqchip_get_virq enough to fix the bug? if (!s->direct_msi && retry) { retry = false; kvm_flush_dynamic_msi_routes(s); goto again; } 2) If you introduce this extra call to kvm_flush_dynamic_msi_routes, does the existing check become obsolete? Thanks, Paolo