From patchwork Fri Nov 5 22:01:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 70303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 928E21007D2 for ; Sat, 6 Nov 2010 09:02:10 +1100 (EST) Received: from localhost ([127.0.0.1]:41597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PEUMJ-0007zb-J2 for incoming@patchwork.ozlabs.org; Fri, 05 Nov 2010 18:02:07 -0400 Received: from [140.186.70.92] (port=44286 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PEULk-0007wT-SX for qemu-devel@nongnu.org; Fri, 05 Nov 2010 18:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PEULj-0002sv-OZ for qemu-devel@nongnu.org; Fri, 05 Nov 2010 18:01:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52883) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PEULj-0002sc-Hw for qemu-devel@nongnu.org; Fri, 05 Nov 2010 18:01:31 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA5M1UAX020538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 5 Nov 2010 18:01:30 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA5M1TXM004038; Fri, 5 Nov 2010 18:01:29 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Fri, 05 Nov 2010 16:01:29 -0600 Message-ID: <20101105220128.26044.11658.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: alex.williamson@redhat.com Subject: [Qemu-devel] [PATCH RESEND] apic: Don't iterate past last used apic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- hw/apic.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/hw/apic.c b/hw/apic.c index 63d62c7..5f4a87c 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -437,6 +437,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; @@ -472,6 +474,8 @@ static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask, set_bit(deliver_bitmask, i); } } + } else { + break; } } }