[PATCH] ARM/vgic: Use for_each_set_bit() in vgic_check_inflight_irqs_pending()

Andrew Cooper posted 1 patch 3 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20240823230045.1581050-1-andrew.cooper3@citrix.com
xen/arch/arm/include/asm/vgic.h | 2 +-
xen/arch/arm/vgic-v2.c          | 2 +-
xen/arch/arm/vgic-v3.c          | 2 +-
xen/arch/arm/vgic.c             | 8 ++------
4 files changed, 5 insertions(+), 9 deletions(-)
[PATCH] ARM/vgic: Use for_each_set_bit() in vgic_check_inflight_irqs_pending()
Posted by Andrew Cooper 3 months, 1 week ago
... which is better optimised for scalar values, rather than using the
arbitrary-sized bitmap helpers.

Additionally, unlike other vgic helpers, this takes both a domain and vcpu
pointer.  The domain parameter isn't used, and the callers pass v->domain.

Strip out the domain pointer.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/include/asm/vgic.h | 2 +-
 xen/arch/arm/vgic-v2.c          | 2 +-
 xen/arch/arm/vgic-v3.c          | 2 +-
 xen/arch/arm/vgic.c             | 8 ++------
 4 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/xen/arch/arm/include/asm/vgic.h b/xen/arch/arm/include/asm/vgic.h
index 79b73a0dbb58..e309dca1ad01 100644
--- a/xen/arch/arm/include/asm/vgic.h
+++ b/xen/arch/arm/include/asm/vgic.h
@@ -315,7 +315,7 @@ extern bool vgic_to_sgi(struct vcpu *v, register_t sgir,
                         enum gic_sgi_mode irqmode, int virq,
                         const struct sgi_target *target);
 extern bool vgic_migrate_irq(struct vcpu *old, struct vcpu *new, unsigned int irq);
-extern void vgic_check_inflight_irqs_pending(struct domain *d, struct vcpu *v,
+extern void vgic_check_inflight_irqs_pending(struct vcpu *v,
                                              unsigned int rank, uint32_t r);
 
 #endif /* !CONFIG_NEW_VGIC */
diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
index 0aa10fff0f10..a19d61017861 100644
--- a/xen/arch/arm/vgic-v2.c
+++ b/xen/arch/arm/vgic-v2.c
@@ -483,7 +483,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info,
         rank = vgic_rank_offset(v, 1, gicd_reg - GICD_ICPENDR, DABT_WORD);
         if ( rank == NULL ) goto write_ignore;
 
-        vgic_check_inflight_irqs_pending(v->domain, v, rank->index, r);
+        vgic_check_inflight_irqs_pending(v, rank->index, r);
 
         goto write_ignore;
 
diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
index cc3832770181..2eaa48fadbb0 100644
--- a/xen/arch/arm/vgic-v3.c
+++ b/xen/arch/arm/vgic-v3.c
@@ -820,7 +820,7 @@ static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v,
         rank = vgic_rank_offset(v, 1, reg - GICD_ICPENDR, DABT_WORD);
         if ( rank == NULL ) goto write_ignore;
 
-        vgic_check_inflight_irqs_pending(v->domain, v, rank->index, r);
+        vgic_check_inflight_irqs_pending(v, rank->index, r);
 
         goto write_ignore;
 
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 905e5eeb66d4..7b54ccc7cbfa 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -720,13 +720,9 @@ unsigned int vgic_max_vcpus(unsigned int domctl_vgic_version)
     }
 }
 
-void vgic_check_inflight_irqs_pending(struct domain *d, struct vcpu *v,
-                                      unsigned int rank, uint32_t r)
+void vgic_check_inflight_irqs_pending(struct vcpu *v, unsigned int rank, uint32_t r)
 {
-    const unsigned long mask = r;
-    unsigned int i;
-
-    bitmap_for_each ( i, &mask, 32 )
+    for_each_set_bit ( i, r )
     {
         struct pending_irq *p;
         struct vcpu *v_target;
-- 
2.39.2
Re: [PATCH] ARM/vgic: Use for_each_set_bit() in vgic_check_inflight_irqs_pending()
Posted by Michal Orzel 3 months, 1 week ago

On 24/08/2024 01:00, Andrew Cooper wrote:
> 
> 
> ... which is better optimised for scalar values, rather than using the
> arbitrary-sized bitmap helpers.
> 
> Additionally, unlike other vgic helpers, this takes both a domain and vcpu
> pointer.  The domain parameter isn't used, and the callers pass v->domain.
> 
> Strip out the domain pointer.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>

~Michal