From: Radim =?utf-8?Q?Krcm=C3=A1r?= Subject: Re: [PATCH] KVM: x86: Add lowest-priority support for vt-d posted-interrupts Date: Thu, 26 Nov 2015 15:03:20 +0100 Message-ID: <20151126140319.GE13925@potion.brq.redhat.com> References: <1447037208-75615-1-git-send-email-feng.wu@intel.com> <20151116190314.GA12245@potion.brq.redhat.com> <20151124143154.GB13925@potion.brq.redhat.com> <20151125141238.GC13925@potion.brq.redhat.com> <5655C7C9.1010008@redhat.com> <20151125154308.GD13925@potion.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Paolo Bonzini , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" To: "Wu, Feng" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:55937 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751224AbbKZODX (ORCPT ); Thu, 26 Nov 2015 09:03:23 -0500 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: 2015-11-26 06:24+0000, Wu, Feng: >> From: Radim Kr=C4=8Dm=C3=A1=C5=99 [mailto:rkrcmar@redhat.com] >> 2015-11-25 15:38+0100, Paolo Bonzini: >>> On 25/11/2015 15:12, Radim Krcm=C3=A1r wrote: >>>> I think it's ok to pick any algorithm we like. It's unlikely that >>>> software would recognize and take advantage of the hardware algori= thm >>>> without adding a special treatment for KVM. >>>> (I'd vote for the simple pick-first-APIC lowest priority algorithm= ... >>>> I don't see much point in complicating lowest priority when it do= esn't >>>> deliver to lowest priority CPU anyway.) >>> >>> Vector hashing is an improvement for the common case where all vect= ors >>> are set to all CPUs. Sure you can get an unlucky assignment, but i= t's >>> still better than pick-first-APIC. >>=20 >> Yeah, hashing has a valid use case, but a subtle weighting of drawba= cks >> led me to prefer pick-first-APIC ... >=20 > Is it possible that pick-first-APIC policy make certain vCPU's irq wo= rkload too > heavy? It is, but vector hashing doesn't eliminate that possibility, just make= s it significantly less likely. irqbalanced takes care of proper distribution in Linux guests. I'm not sure what other OS do, but they should have something like that as well= =2E >> (I'd prefer to have simple code in KVM and depend on static IRQ bala= ncing >> in a guest to handle the distribution. >> The guest could get the unlucky assignment anyway, so it should be >> prepared; and hashing just made KVM worse in that case. Guests mi= ght >> also configure physical x(2)APIC, where is no lowest priority. >> And if the guest doesn't do anything with IRQs, then it might not e= ven >> care about the impact that our choice has.) >=20 > Do do you guys have an agreement on how to handle this? Or we can imp= lement > the vector hashing at the current stage. then we can improve it like = Radim mentioned > above if it is really needed?=20 Vector hashing is definitely an improvement over the current situation; I'll agree with any algorithm if it is reasonably implemented. (v1 fails delivery if chosen APIC is disabled, misuses KVM_MAX_VCPUS as bitmap size, and counting number of bits is better done with hweight16= () -- these bugs would hopefully be fixed by having a common functinon :]= )