[PATCH v4 3/8] arm/irq: Keep track of irq affinities

Mykyta Poturai posted 8 patches 6 days, 15 hours ago
[PATCH v4 3/8] arm/irq: Keep track of irq affinities
Posted by Mykyta Poturai 6 days, 15 hours ago
Currently on Arm the desc->affinity mask of an irq is never updated,
which makes it hard to know the actual affinity of an interrupt.

Fix this by updating the field in irq_set_affinity.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>

v3->v4:
* patch introduced
---
 xen/arch/arm/irq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 73e58a5108..28b40331f7 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -219,7 +219,10 @@ static inline struct domain *irq_get_domain(struct irq_desc *desc)
 void irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
 {
     if ( desc != NULL )
+    {
+        cpumask_copy(desc->affinity, mask);
         desc->handler->set_affinity(desc, mask);
+    }
 }
 
 int request_irq(unsigned int irq, unsigned int irqflags,
-- 
2.51.2
Re: [PATCH v4 3/8] arm/irq: Keep track of irq affinities
Posted by Julien Grall 2 days, 15 hours ago
Hi Mykyta,

On 12/11/2025 10:51, Mykyta Poturai wrote:
> Currently on Arm the desc->affinity mask of an irq is never updated,
> which makes it hard to know the actual affinity of an interrupt.
> 
> Fix this by updating the field in irq_set_affinity.
> 
> Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
> 
> v3->v4:
> * patch introduced
> ---
>   xen/arch/arm/irq.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index 73e58a5108..28b40331f7 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -219,7 +219,10 @@ static inline struct domain *irq_get_domain(struct irq_desc *desc)
>   void irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
>   {
>       if ( desc != NULL )
> +    {
> +        cpumask_copy(desc->affinity, mask);

irq_set_affinity() doesn't always seems to be called with ``desc->lock`` 
taken (see vgic_migrate_irq(), arch_move_irqs()). So I am not sure this 
is safe. You probably need to update the callers as well to always take 
the lock. irq_set_affinity() probably want to gain an 
ASSERT(spin_is_locked()) with some documentation on top of the function.

>           desc->handler->set_affinity(desc, mask);
> +    }

NIT: As there are multiple lines in the ``if``, I would consider 
reworking the logic so we return early when desc is NULL.

>   }
>   
>   int request_irq(unsigned int irq, unsigned int irqflags,

Cheers,

-- 
Julien Grall