]> git.proxmox.com Git - qemu.git/commitdiff
apic: Don't iterate past last used apic
authorAlex Williamson <alex.williamson@redhat.com>
Fri, 5 Nov 2010 22:01:29 +0000 (16:01 -0600)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 16 Nov 2010 15:31:18 +0000 (09:31 -0600)
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 <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/apic.c

index 63d62c75531757c5fe914fc6e024dc07799411df..5f4a87c80769da024225efee6132b2f9d889f31f 100644 (file)
--- 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;
             }
         }
     }