[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 1/3] x86/match-cpu: Improvements to x86_match_cpu()



Xen's use of struct x86_cpu_id is a bit different to Linux's, so we can
simplify the loop termination condition.  Leave a comment explaining Xen's
assumptions.

Switch to Xen style, as we've properly devated from Linux, and switch to the
new vendor/family/model names.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>

v2:
 * New

There is a marginal code generation improvement, because of not needing to
hold as many registers live over the loop termination check.
---
 xen/arch/x86/cpu/common.c | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index f221b9497c61..a659ea7bf604 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -1007,19 +1007,26 @@ void cpu_uninit(unsigned int cpu)
 
 const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id table[])
 {
-       const struct x86_cpu_id *m;
-       const struct cpuinfo_x86 *c = &boot_cpu_data;
+    const struct x86_cpu_id *m;
+    const struct cpuinfo_x86 *c = &boot_cpu_data;
 
-       for (m = table; m->vendor | m->family | m->model | m->feature; m++) {
-               if (c->x86_vendor != m->vendor)
-                       continue;
-               if (c->x86 != m->family)
-                       continue;
-               if (c->x86_model != m->model)
-                       continue;
-               if (!cpu_has(c, m->feature))
-                       continue;
-               return m;
-       }
-       return NULL;
+    /*
+     * Although derived from Linux originally, Xen has no valid rows where
+     * ->vendor is nonzero, so used this in place of checking all metadata.
+     */
+    for ( m = table; m->vendor; m++ )
+    {
+        if ( c->vendor != m->vendor )
+            continue;
+        if ( c->family != m->family )
+            continue;
+        if ( c->model != m->model )
+            continue;
+        if ( !cpu_has(c, m->feature) )
+            continue;
+
+        return m;
+    }
+
+    return NULL;
 }
-- 
2.39.5




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.