[PATCH v2 6/6] x86/irq: do not set nr_irqs based on nr_irqs_gsi in APIC mode

Roger Pau Monne posted 6 patches 3 years, 7 months ago
[PATCH v2 6/6] x86/irq: do not set nr_irqs based on nr_irqs_gsi in APIC mode
Posted by Roger Pau Monne 3 years, 7 months ago
When using an APIC do not set nr_irqs based on a factor of nr_irqs_gsi
(currently x8), and instead do so exclusively based on the amount of
available vectors on the system.

There's no point in setting nr_irqs to a value higher than the
available set of vectors, as vector allocation will fail anyway.

Fixes: e99d45da8a ('x86/x2apic: properly implement cluster mode')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/irq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 7f75ec8bcc..e3b0bee527 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -426,8 +426,7 @@ int __init init_irq_data(void)
             (x2apic_enabled && !x2apic_phys) ? x2apic_max_cluster_id + 1
                                              : num_present_cpus();
 
-        nr_irqs = cpu_has_apic ? max(vec_spaces * NR_DYNAMIC_VECTORS,
-                                     8 * nr_irqs_gsi)
+        nr_irqs = cpu_has_apic ? vec_spaces * NR_DYNAMIC_VECTORS
                                : nr_irqs_gsi;
     }
     else if ( nr_irqs < 16 )
-- 
2.36.1


Re: [PATCH v2 6/6] x86/irq: do not set nr_irqs based on nr_irqs_gsi in APIC mode
Posted by Jan Beulich 3 years, 7 months ago
On 30.06.2022 10:54, Roger Pau Monne wrote:
> When using an APIC do not set nr_irqs based on a factor of nr_irqs_gsi
> (currently x8), and instead do so exclusively based on the amount of
> available vectors on the system.
> 
> There's no point in setting nr_irqs to a value higher than the
> available set of vectors, as vector allocation will fail anyway.

Only if in the earlier calculation you include hotplug CPUs.

> --- a/xen/arch/x86/irq.c
> +++ b/xen/arch/x86/irq.c
> @@ -426,8 +426,7 @@ int __init init_irq_data(void)
>              (x2apic_enabled && !x2apic_phys) ? x2apic_max_cluster_id + 1
>                                               : num_present_cpus();
>  
> -        nr_irqs = cpu_has_apic ? max(vec_spaces * NR_DYNAMIC_VECTORS,
> -                                     8 * nr_irqs_gsi)
> +        nr_irqs = cpu_has_apic ? vec_spaces * NR_DYNAMIC_VECTORS
>                                 : nr_irqs_gsi;

I wonder how useful it is to retain the !cpu_has_apic case here. I
don't have much hope for Xen to work properly if APIC use was
suppressed, and I'm unaware of x86-64 CPUs without APIC.

Jan