x86/shadow: remove pointless loops over all vCPU-s
authorJan Beulich <jbeulich@suse.com>
Wed, 20 Dec 2017 09:04:48 +0000 (10:04 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 20 Dec 2017 09:04:48 +0000 (10:04 +0100)
The vCPU count can be had more directly.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/shadow/common.c
xen/arch/x86/mm/shadow/multi.c

index 3a33e0b148078e2ba6d6dc3686373baa701c9f67..600df0cedc27c6464e3d043bccd491648a03ddd5 100644 (file)
@@ -1143,13 +1143,7 @@ const u8 sh_type_to_size[] = {
  * worth to make sure we never return zero. */
 static unsigned int shadow_min_acceptable_pages(struct domain *d)
 {
-    u32 vcpu_count = 1;
-    struct vcpu *v;
-
-    for_each_vcpu(d, v)
-        vcpu_count++;
-
-    return (vcpu_count * 128);
+    return (d->max_vcpus + 1) * 128;
 }
 
 /* Dispatcher function: call the per-mode function that will unhook the
index 440857592090533c31af426bd6387cf0c2879a8e..f7182e466a24ee2868202ae73358694b5a116868 100644 (file)
@@ -1476,16 +1476,14 @@ sh_make_shadow(struct vcpu *v, mfn_t gmfn, u32 shadow_type)
          * pinning l3es.  This is not very quick but it doesn't happen
          * very often. */
         struct page_info *sp, *t;
-        struct vcpu *v2;
-        int l4count = 0, vcpus = 0;
+        unsigned int l4count = 0;
+
         page_list_for_each(sp, &d->arch.paging.shadow.pinned_shadows)
         {
             if ( sp->u.sh.type == SH_type_l4_64_shadow )
                 l4count++;
         }
-        for_each_vcpu ( d, v2 )
-            vcpus++;
-        if ( l4count > 2 * vcpus )
+        if ( l4count > 2 * d->max_vcpus )
         {
             /* Unpin all the pinned l3 tables, and don't pin any more. */
             page_list_for_each_safe(sp, t, &d->arch.paging.shadow.pinned_shadows)