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

[xen staging] x86/mm: Improve bitops in vcpumask_to_pcpumask()



commit 78ce2be733b1e45e2e190c1765fe31da318d435f
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Wed May 29 14:58:57 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri May 2 15:04:41 2025 +0100

    x86/mm: Improve bitops in vcpumask_to_pcpumask()
    
    This loop is for_each_set_bit() in disguise.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/mm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 0b787ba553..66c15a3c86 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -3411,7 +3411,7 @@ int new_guest_cr3(mfn_t mfn)
 static int vcpumask_to_pcpumask(
     struct domain *d, XEN_GUEST_HANDLE_PARAM(const_void) bmap, cpumask_t 
*pmask)
 {
-    unsigned int vcpu_id, vcpu_bias, offs;
+    unsigned int vcpu_bias, offs;
     unsigned long vmask;
     struct vcpu *v;
     bool is_native = !is_pv_32bit_domain(d);
@@ -3432,12 +3432,10 @@ static int vcpumask_to_pcpumask(
             return -EFAULT;
         }
 
-        while ( vmask )
+        for_each_set_bit ( vcpu_id, vmask )
         {
             unsigned int cpu;
 
-            vcpu_id = ffsl(vmask) - 1;
-            vmask &= ~(1UL << vcpu_id);
             vcpu_id += vcpu_bias;
             if ( (vcpu_id >= d->max_vcpus) )
                 return 0;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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