[PATCH] common: Convert !test_bit(_VPF_down) into is_vcpu_online()

Teddy Astie posted 1 patch 3 weeks, 4 days ago
xen/arch/arm/domctl.c  | 2 +-
xen/arch/arm/traps.c   | 2 +-
xen/arch/arm/vgic.c    | 2 +-
xen/arch/arm/vpsci.c   | 4 ++--
xen/arch/x86/pv/shim.c | 2 +-
xen/arch/x86/traps.c   | 2 +-
xen/common/domain.c    | 2 +-
7 files changed, 8 insertions(+), 8 deletions(-)
[PATCH] common: Convert !test_bit(_VPF_down) into is_vcpu_online()
Posted by Teddy Astie 3 weeks, 4 days ago
Do the same for test_bit(_VPF_down) into !is_vcpu_online().

No functional change.

Signed-off-by: Teddy Astie <teddy.astie@vates.tech>
---
 xen/arch/arm/domctl.c  | 2 +-
 xen/arch/arm/traps.c   | 2 +-
 xen/arch/arm/vgic.c    | 2 +-
 xen/arch/arm/vpsci.c   | 4 ++--
 xen/arch/x86/pv/shim.c | 2 +-
 xen/arch/x86/traps.c   | 2 +-
 xen/common/domain.c    | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
index b76af56fad..292cc92159 100644
--- a/xen/arch/arm/domctl.c
+++ b/xen/arch/arm/domctl.c
@@ -203,7 +203,7 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
     ctxt->ttbr1 = v->arch.ttbr1;
     ctxt->ttbcr = v->arch.ttbcr;
 
-    if ( !test_bit(_VPF_down, &v->pause_flags) )
+    if ( is_vcpu_online(v) )
         ctxt->flags |= VGCF_online;
 }
 
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 6a5dcef2aa..47a5c6bdd4 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -1004,7 +1004,7 @@ static void show_guest_stack(struct vcpu *v, const struct cpu_user_regs *regs)
     void *mapped;
     unsigned long *stack, addr;
 
-    if ( test_bit(_VPF_down, &v->pause_flags) )
+    if ( !is_vcpu_online(v) )
     {
         printk("No stack trace, VCPU offline\n");
         return;
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index acded6a40f..062238a899 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -818,7 +818,7 @@ void vgic_inject_irq(struct domain *d, struct vcpu *v, unsigned int virq,
     }
 
     /* vcpu offline */
-    if ( test_bit(_VPF_down, &v->pause_flags) )
+    if ( !is_vcpu_online(v) )
     {
         spin_unlock_irqrestore(&v->arch.vgic.lock, flags);
         return;
diff --git a/xen/arch/arm/vpsci.c b/xen/arch/arm/vpsci.c
index ac6af6118f..b2b6b4c98d 100644
--- a/xen/arch/arm/vpsci.c
+++ b/xen/arch/arm/vpsci.c
@@ -85,7 +85,7 @@ static int do_common_cpu_on(register_t target_cpu, register_t entry_point,
     if ( is_64bit_domain(d) && is_thumb )
         return PSCI_INVALID_ADDRESS;
 
-    if ( !test_bit(_VPF_down, &v->pause_flags) )
+    if ( is_vcpu_online(v) )
         return PSCI_ALREADY_ON;
 
     rc = vpsci_build_guest_context(v, entry_point, context_id, &ctxt);
@@ -195,7 +195,7 @@ static int32_t do_psci_0_2_affinity_info(register_t target_affinity,
         v = d->vcpu[vcpuid];
 
         if ( ( ( v->arch.vmpidr & tmask ) == target_affinity )
-                && ( !test_bit(_VPF_down, &v->pause_flags) ) )
+                && ( is_vcpu_online(v) ) )
             return PSCI_0_2_AFFINITY_LEVEL_ON;
     }
 
diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c
index 41000b0523..8ec03d7295 100644
--- a/xen/arch/x86/pv/shim.c
+++ b/xen/arch/x86/pv/shim.c
@@ -404,7 +404,7 @@ int pv_shim_shutdown(uint8_t reason)
         /* Stop the singleshot timer. */
         stop_timer(&v->singleshot_timer);
 
-        if ( test_bit(_VPF_down, &v->pause_flags) )
+        if ( !is_vcpu_online(v) )
             BUG_ON(vcpu_reset(v));
 
         if ( v != current )
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index ac01ba0872..5a702fe22c 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -918,7 +918,7 @@ void vcpu_show_execution_state(struct vcpu *v)
 {
     unsigned long flags = 0;
 
-    if ( test_bit(_VPF_down, &v->pause_flags) )
+    if ( !is_vcpu_online(v) )
     {
         printk("*** %pv is offline ***\n", v);
         return;
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 6b52713518..167338f360 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -2190,7 +2190,7 @@ long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)
 
     case VCPUOP_down:
         for_each_vcpu ( d, v )
-            if ( v->vcpu_id != vcpuid && !test_bit(_VPF_down, &v->pause_flags) )
+            if ( v->vcpu_id != vcpuid && is_vcpu_online(v) )
             {
                rc = 1;
                break;
-- 
2.56.0



-- 
Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
Re: [PATCH] common: Convert !test_bit(_VPF_down) into is_vcpu_online()
Posted by Orzel, Michal 2 weeks ago

On 29-Oct-26 14:58, Teddy Astie wrote:
> Do the same for test_bit(_VPF_down) into !is_vcpu_online().
> 
> No functional change.
> 
> Signed-off-by: Teddy Astie <teddy.astie@vates.tech>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>

~Michal
Re: [PATCH] common: Convert !test_bit(_VPF_down) into is_vcpu_online()
Posted by Jan Beulich 3 weeks, 4 days ago
On 29.10.2026 14:58, Teddy Astie wrote:
> Do the same for test_bit(_VPF_down) into !is_vcpu_online().
> 
> No functional change.
> 
> Signed-off-by: Teddy Astie <teddy.astie@vates.tech>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
with one nit addressed (can likely be done while committing):

> @@ -195,7 +195,7 @@ static int32_t do_psci_0_2_affinity_info(register_t target_affinity,
>          v = d->vcpu[vcpuid];
>  
>          if ( ( ( v->arch.vmpidr & tmask ) == target_affinity )
> -                && ( !test_bit(_VPF_down, &v->pause_flags) ) )
> +                && ( is_vcpu_online(v) ) )

With this the parentheses also want to go away. With them the stray extra
blanks then will also disappear (at least from the line being touched).

Jan
Re: [PATCH] common: Convert !test_bit(_VPF_down) into is_vcpu_online()
Posted by Teddy Astie 3 weeks, 4 days ago
Le 29/10/2026 à 15:11, Jan Beulich a écrit :
> On 29.10.2026 14:58, Teddy Astie wrote:
>> Do the same for test_bit(_VPF_down) into !is_vcpu_online().
>>
>> No functional change.
>>
>> Signed-off-by: Teddy Astie <teddy.astie@vates.tech>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> with one nit addressed (can likely be done while committing):
> 
>> @@ -195,7 +195,7 @@ static int32_t do_psci_0_2_affinity_info(register_t target_affinity,
>>           v = d->vcpu[vcpuid];
>>   
>>           if ( ( ( v->arch.vmpidr & tmask ) == target_affinity )
>> -                && ( !test_bit(_VPF_down, &v->pause_flags) ) )
>> +                && ( is_vcpu_online(v) ) )
> 
> With this the parentheses also want to go away. With them the stray extra
> blanks then will also disappear (at least from the line being touched).
> 

Looks good to me.

> Jan

Teddy