From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH v5] kvm: Use a bitmap for tracking used GSIs Date: Wed, 13 May 2009 19:05:19 +0300 Message-ID: <20090513160519.GA1738@redhat.com> References: <20090513043835.6696.27384.stgit@dl380g6-3.ned.telco.ned.telco> <20090513150815.8221.49221.stgit@dl380g6-3.ned.telco.ned.telco> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, sheng.yang@intel.com, avi@redhat.com To: Alex Williamson Return-path: Received: from mx2.redhat.com ([66.187.237.31]:34566 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757535AbZEMQGW (ORCPT ); Wed, 13 May 2009 12:06:22 -0400 Content-Disposition: inline In-Reply-To: <20090513150815.8221.49221.stgit@dl380g6-3.ned.telco.ned.telco> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, May 13, 2009 at 09:13:38AM -0600, Alex Williamson wrote: > @@ -323,6 +326,28 @@ kvm_context_t kvm_init(struct kvm_callbacks *callbacks, > kvm->no_irqchip_creation = 0; > kvm->no_pit_creation = 0; > > + gsi_count = kvm_get_gsi_count(kvm); > + if (gsi_count > 0) { > + int gsi_bytes, i; > + > + /* Round up so we can search ints using ffs */ > + gsi_bytes = ((gsi_count + 31) / 32) * 4; Let's take ALIGN macro from linux/kernel.h? > + kvm->used_gsi_bitmap = malloc(gsi_bytes); > + if (!kvm->used_gsi_bitmap) > + goto out_close; > + memset(kvm->used_gsi_bitmap, 0, gsi_bytes); > + kvm->max_gsi = gsi_bytes * 8; > + > + /* Mark all the IOAPIC pin GSIs and any over-allocated > + * GSIs as already in use. */ Align '*'s please. > +#ifdef KVM_IOAPIC_NUM_PINS I think we should just export #define KVM_IOAPIC_NUM_PINS 0 for ppc in kernel headers (or in libkvm), and get rid of this ifdef completely. Avi, agree? > + for (i = 0; i < min(KVM_IOAPIC_NUM_PINS, gsi_count); i++) > + set_bit(kvm->used_gsi_bitmap, i); > +#endif > + for (i = gsi_count; i < kvm->max_gsi; i++) > + set_bit(kvm->used_gsi_bitmap, i); > + } > + > return kvm; > out_close: > close(fd); -- MST