Skip to contentSkip to conversation

apic: Don't iterate past last used apic

PATCH RESEND Applied Alex Williamson 2 participants 2 messages Nov 5, 2010 – Nov 16, 2010

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 apic: Don't iterate past last used apic

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.

---

 hw/apic.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
hw/apic.c +4 -0
index 63d62c7..5f4a87c 100644
@@ -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;
             }
         }
     }
#1 lore raw
Quoted 8 lines · Alex Williamson

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.

Applied. Thanks.

Regards,

Anthony LIguori

Quoted 31 lines

---

  hw/apic.c |    4 ++++
  1 files changed, 4 insertions(+), 0 deletions(-)
hw/apic.c +4 -0
index 63d62c7..5f4a87c 100644
@@ -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;
              }
          }
      }