From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59175 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvXCB-0008DB-Go for qemu-devel@nongnu.org; Tue, 14 Sep 2010 11:13:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvXC7-00089d-FQ for qemu-devel@nongnu.org; Tue, 14 Sep 2010 11:13:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31312) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvXC7-00089T-9E for qemu-devel@nongnu.org; Tue, 14 Sep 2010 11:13:15 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8EFDErm005715 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Sep 2010 11:13:14 -0400 From: Alex Williamson Date: Tue, 14 Sep 2010 09:13:13 -0600 Message-ID: <20100914151230.4223.79925.stgit@s20.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] apic: Don't iterate past last used apic List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com local_apics are allocated sequentially and never removed, so we can stop any iterations that go to MAX_APICS as soon as we hit the first NULL. Looking at a small guest running a virtio-net workload with oprofile, this drops apic_get_delivery_bitmask() from #3 in the profile to down in the noise. Signed-off-by: Alex Williamson --- Post 0.13 hw/apic.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/hw/apic.c b/hw/apic.c index d686b51..c07238c 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -449,6 +449,8 @@ static int apic_find_dest(uint8_t dest) apic = local_apics[i]; if (apic && apic->id == dest) return i; + if (!apic) + break; } return -1; @@ -484,6 +486,8 @@ static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask, set_bit(deliver_bitmask, i); } } + } else { + break; } } }