These days d->max_vcpus is populated on domain_create(), so use that instead and
avoid a function call.
Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
---
pipeline: https://gitlab.com/xen-project/people/agvallejo/xen/-/pipelines/1930259234
---
xen/arch/x86/hvm/dom0_build.c | 7 +++----
xen/arch/x86/io_apic.c | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index a038e58c11..9964068387 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -890,19 +890,18 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr)
struct acpi_madt_local_x2apic *x2apic;
acpi_status status;
unsigned long size;
- unsigned int i, max_vcpus;
+ unsigned int i;
int rc;
/* Count number of interrupt overrides in the MADT. */
acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE,
acpi_count_intr_ovr, UINT_MAX);
- max_vcpus = dom0_max_vcpus();
/* Calculate the size of the crafted MADT. */
size = sizeof(*madt);
size += sizeof(*io_apic) * nr_ioapics;
size += sizeof(*intsrcovr) * acpi_intr_overrides;
- size += sizeof(*x2apic) * max_vcpus;
+ size += sizeof(*x2apic) * d->max_vcpus;
madt = xzalloc_bytes(size);
if ( !madt )
@@ -942,7 +941,7 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr)
}
x2apic = (void *)io_apic;
- for ( i = 0; i < max_vcpus; i++ )
+ for ( i = 0; i < d->max_vcpus; i++ )
{
x2apic->header.type = ACPI_MADT_TYPE_LOCAL_X2APIC;
x2apic->header.length = sizeof(*x2apic);
diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index 84bd87a5e4..1816e1c0b9 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -2758,7 +2758,7 @@ unsigned int __hwdom_init arch_hwdom_irqs(const struct domain *d)
else
{
if ( !d->domain_id )
- n = min(n, dom0_max_vcpus());
+ n = min(n, d->max_vcpus);
n = min(nr_irqs_gsi + n * NR_DYNAMIC_VECTORS, max_irqs);
}
base-commit: dff462313fe0bfa273c54ffc9bff71f054c365af
--
2.43.0
On 16.07.2025 16:18, Alejandro Vallejo wrote: > These days d->max_vcpus is populated on domain_create(), so use that instead and > avoid a function call. One further nit though: Please limit commit message line length to 75 chars, such that certain git output (indenting by 4 chars) still stays below 80. Jan
On Thu Jul 17, 2025 at 8:49 AM CEST, Jan Beulich wrote: > On 16.07.2025 16:18, Alejandro Vallejo wrote: >> These days d->max_vcpus is populated on domain_create(), so use that instead and >> avoid a function call. > > One further nit though: Please limit commit message line length to 75 chars, > such that certain git output (indenting by 4 chars) still stays below 80. > > Jan Sure, I'm happy to do that. We might want to add it to the CODING_STYLE if there is consensus though. I'm not a big fan of unwritten rules. Cheers, Alejandro
On 2025-07-16 10:18, Alejandro Vallejo wrote: > These days d->max_vcpus is populated on domain_create(), so use that instead and > avoid a function call. > > Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com> Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
On 16.07.2025 16:18, Alejandro Vallejo wrote: > These days d->max_vcpus is populated on domain_create(), so use that instead and > avoid a function call. And it's not just this. As it's not straightforward to prove that two runs of this function, at different points in time, would yield the same result, it's also quite desirable that then there's only a single call remaining. > Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Jan
© 2016 - 2025 Red Hat, Inc.