* [PATCH v2 1/2] ppc/spapr: Introduce SPAPR_NR_IPIS to refer IRQ range for CPU IPIs.
@ 2023-11-22 9:24 Harsh Prateek Bora
2023-11-22 9:24 ` [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS Harsh Prateek Bora
0 siblings, 1 reply; 8+ messages in thread
From: Harsh Prateek Bora @ 2023-11-22 9:24 UTC (permalink / raw)
To: npiggin, qemu-ppc; +Cc: danielhb413, clg, david, qemu-devel, harshpb
spapr_irq_init currently uses existing macro SPAPR_XIRQ_BASE to refer to
the range of CPU IPIs during initialization of nr-irqs property.
It is more appropriate to have its own define which can be further
reused as appropriate for correct interpretation.
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Suggested-by: Cedric Le Goater <clg@kaod.org>
---
hw/ppc/spapr_irq.c | 4 ++--
include/hw/ppc/spapr_irq.h | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
index a0d1e1298e..0c5db6b161 100644
--- a/hw/ppc/spapr_irq.c
+++ b/hw/ppc/spapr_irq.c
@@ -329,7 +329,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
int i;
dev = qdev_new(TYPE_SPAPR_XIVE);
- qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs + SPAPR_XIRQ_BASE);
+ qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs + SPAPR_NR_IPIS);
/*
* 8 XIVE END structures per CPU. One for each available
* priority
@@ -356,7 +356,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
}
spapr->qirqs = qemu_allocate_irqs(spapr_set_irq, spapr,
- smc->nr_xirqs + SPAPR_XIRQ_BASE);
+ smc->nr_xirqs + SPAPR_NR_IPIS);
/*
* Mostly we don't actually need this until reset, except that not
diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h
index c22a72c9e2..e7a80a8349 100644
--- a/include/hw/ppc/spapr_irq.h
+++ b/include/hw/ppc/spapr_irq.h
@@ -28,6 +28,7 @@
#define SPAPR_IRQ_MSI (SPAPR_XIRQ_BASE + 0x0300)
#define SPAPR_NR_XIRQS 0x1000
+#define SPAPR_NR_IPIS 0x1000
struct SpaprMachineState;
--
2.39.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS.
2023-11-22 9:24 [PATCH v2 1/2] ppc/spapr: Introduce SPAPR_NR_IPIS to refer IRQ range for CPU IPIs Harsh Prateek Bora
@ 2023-11-22 9:24 ` Harsh Prateek Bora
0 siblings, 0 replies; 8+ messages in thread
From: Harsh Prateek Bora @ 2023-11-22 9:24 UTC (permalink / raw)
To: npiggin, qemu-ppc; +Cc: danielhb413, clg, david, qemu-devel, harshpb
Initialize the machine specific max_cpus limit as per the maximum range
of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not
free error due to XIVE/XICS limitation and keeping beyond 8192 will hit
assert in tcg_region_init or spapr_xive_claim_irq.
Logs:
Without patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: IRQ 4096 is not free
[root@host build]#
On LPAR:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
**
ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size >= 2 * page_size)
Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size >= 2 * page_size)
Aborted (core dumped)
[root@host build]#
On x86:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
qemu-system-ppc64: ../hw/intc/spapr_xive.c:596: spapr_xive_claim_irq:
Assertion `lisn < xive->nr_irqs' failed.
Aborted (core dumped)
[root@host build]#
With patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by
machine 'pseries-8.2' is 4096
[root@host build]#
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
---
hw/ppc/spapr.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index df09aa9d6a..0de11a4458 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -4647,13 +4647,10 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
mc->block_default_type = IF_SCSI;
/*
- * Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values
- * should be limited by the host capability instead of hardcoded.
- * max_cpus for KVM guests will be checked in kvm_init(), and TCG
- * guests are welcome to have as many CPUs as the host are capable
- * of emulate.
+ * While KVM determines max cpus in kvm_init() using kvm_max_vcpus(),
+ * In TCG the limit is restricted by the range of CPU IPIs available.
*/
- mc->max_cpus = INT32_MAX;
+ mc->max_cpus = SPAPR_NR_IPIS;
mc->no_parallel = 1;
mc->default_boot_order = "";
--
2.39.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS.
2023-11-22 9:28 [PATCH RESEND v2 0/2] Introduce SPAPR_NR_IPIS and fix max-cpus Harsh Prateek Bora
@ 2023-11-22 9:28 ` Harsh Prateek Bora
2023-11-22 11:16 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 8+ messages in thread
From: Harsh Prateek Bora @ 2023-11-22 9:28 UTC (permalink / raw)
To: npiggin, qemu-ppc; +Cc: danielhb413, clg, david, qemu-devel, harshpb
Initialize the machine specific max_cpus limit as per the maximum range
of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not
free error due to XIVE/XICS limitation and keeping beyond 8192 will hit
assert in tcg_region_init or spapr_xive_claim_irq.
Logs:
Without patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: IRQ 4096 is not free
[root@host build]#
On LPAR:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
**
ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size >= 2 * page_size)
Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size >= 2 * page_size)
Aborted (core dumped)
[root@host build]#
On x86:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
qemu-system-ppc64: ../hw/intc/spapr_xive.c:596: spapr_xive_claim_irq:
Assertion `lisn < xive->nr_irqs' failed.
Aborted (core dumped)
[root@host build]#
With patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by
machine 'pseries-8.2' is 4096
[root@host build]#
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
---
hw/ppc/spapr.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index df09aa9d6a..0de11a4458 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -4647,13 +4647,10 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
mc->block_default_type = IF_SCSI;
/*
- * Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values
- * should be limited by the host capability instead of hardcoded.
- * max_cpus for KVM guests will be checked in kvm_init(), and TCG
- * guests are welcome to have as many CPUs as the host are capable
- * of emulate.
+ * While KVM determines max cpus in kvm_init() using kvm_max_vcpus(),
+ * In TCG the limit is restricted by the range of CPU IPIs available.
*/
- mc->max_cpus = INT32_MAX;
+ mc->max_cpus = SPAPR_NR_IPIS;
mc->no_parallel = 1;
mc->default_boot_order = "";
--
2.39.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS.
2023-11-22 9:28 ` [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS Harsh Prateek Bora
@ 2023-11-22 11:16 ` Philippe Mathieu-Daudé
2023-11-23 5:03 ` Harsh Prateek Bora
0 siblings, 1 reply; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-22 11:16 UTC (permalink / raw)
To: Harsh Prateek Bora, npiggin, qemu-ppc; +Cc: danielhb413, clg, david, qemu-devel
Hi Harsh,
On 22/11/23 10:28, Harsh Prateek Bora wrote:
> Initialize the machine specific max_cpus limit as per the maximum range
> of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not
> free error due to XIVE/XICS limitation and keeping beyond 8192 will hit
> assert in tcg_region_init or spapr_xive_claim_irq.
>
> Logs:
>
> Without patch fix:
>
> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
> qemu-system-ppc64: IRQ 4096 is not free
> [root@host build]#
>
> On LPAR:
> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
> **
> ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
> (region_size >= 2 * page_size)
> Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
> (region_size >= 2 * page_size)
> Aborted (core dumped)
> [root@host build]#
>
> On x86:
> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
> qemu-system-ppc64: ../hw/intc/spapr_xive.c:596: spapr_xive_claim_irq:
> Assertion `lisn < xive->nr_irqs' failed.
> Aborted (core dumped)
> [root@host build]#
>
> With patch fix:
> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
> qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by
> machine 'pseries-8.2' is 4096
> [root@host build]#
>
> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
> ---
> hw/ppc/spapr.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index df09aa9d6a..0de11a4458 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -4647,13 +4647,10 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
> mc->block_default_type = IF_SCSI;
>
> /*
> - * Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values
> - * should be limited by the host capability instead of hardcoded.
> - * max_cpus for KVM guests will be checked in kvm_init(), and TCG
> - * guests are welcome to have as many CPUs as the host are capable
> - * of emulate.
> + * While KVM determines max cpus in kvm_init() using kvm_max_vcpus(),
> + * In TCG the limit is restricted by the range of CPU IPIs available.
> */
> - mc->max_cpus = INT32_MAX;
> + mc->max_cpus = SPAPR_NR_IPIS;
Is SPAPR_NR_IPIS also the upper limit for KVM?
> mc->no_parallel = 1;
> mc->default_boot_order = "";
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS.
2023-11-22 11:16 ` Philippe Mathieu-Daudé
@ 2023-11-23 5:03 ` Harsh Prateek Bora
2023-11-23 8:47 ` Cédric Le Goater
0 siblings, 1 reply; 8+ messages in thread
From: Harsh Prateek Bora @ 2023-11-23 5:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, npiggin, qemu-ppc
Cc: danielhb413, clg, david, qemu-devel
Hi Philippe,
On 11/22/23 16:46, Philippe Mathieu-Daudé wrote:
> Hi Harsh,
>
> On 22/11/23 10:28, Harsh Prateek Bora wrote:
>> Initialize the machine specific max_cpus limit as per the maximum range
>> of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not
>> free error due to XIVE/XICS limitation and keeping beyond 8192 will hit
>> assert in tcg_region_init or spapr_xive_claim_irq.
>>
>> Logs:
>>
>> Without patch fix:
>>
>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
>> qemu-system-ppc64: IRQ 4096 is not free
>> [root@host build]#
>>
>> On LPAR:
>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
>> **
>> ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
>> (region_size >= 2 * page_size)
>> Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
>> (region_size >= 2 * page_size)
>> Aborted (core dumped)
>> [root@host build]#
>>
>> On x86:
>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
>> qemu-system-ppc64: ../hw/intc/spapr_xive.c:596: spapr_xive_claim_irq:
>> Assertion `lisn < xive->nr_irqs' failed.
>> Aborted (core dumped)
>> [root@host build]#
>>
>> With patch fix:
>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
>> qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by
>> machine 'pseries-8.2' is 4096
>> [root@host build]#
>>
>> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
>> ---
>> hw/ppc/spapr.c | 9 +++------
>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index df09aa9d6a..0de11a4458 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -4647,13 +4647,10 @@ static void
>> spapr_machine_class_init(ObjectClass *oc, void *data)
>> mc->block_default_type = IF_SCSI;
>> /*
>> - * Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values
>> - * should be limited by the host capability instead of hardcoded.
>> - * max_cpus for KVM guests will be checked in kvm_init(), and TCG
>> - * guests are welcome to have as many CPUs as the host are capable
>> - * of emulate.
>> + * While KVM determines max cpus in kvm_init() using
>> kvm_max_vcpus(),
>> + * In TCG the limit is restricted by the range of CPU IPIs
>> available.
>> */
>> - mc->max_cpus = INT32_MAX;
>> + mc->max_cpus = SPAPR_NR_IPIS;
>
> Is SPAPR_NR_IPIS also the upper limit for KVM?
In KVM mode, the limit is restricted to what is supported by KVM which
is checked using kvm_ioctl via wrappers in kvm_init and appears to be
evaluating to 2048. So, having a larger default works for both case.
regards,
Harsh
>
>> mc->no_parallel = 1;
>> mc->default_boot_order = "";
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS.
2023-11-23 5:03 ` Harsh Prateek Bora
@ 2023-11-23 8:47 ` Cédric Le Goater
2023-11-23 10:26 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 8+ messages in thread
From: Cédric Le Goater @ 2023-11-23 8:47 UTC (permalink / raw)
To: Harsh Prateek Bora, Philippe Mathieu-Daudé, npiggin,
qemu-ppc
Cc: danielhb413, clg, david, qemu-devel
On 11/23/23 06:03, Harsh Prateek Bora wrote:
> Hi Philippe,
>
> On 11/22/23 16:46, Philippe Mathieu-Daudé wrote:
>> Hi Harsh,
>>
>> On 22/11/23 10:28, Harsh Prateek Bora wrote:
>>> Initialize the machine specific max_cpus limit as per the maximum range
>>> of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not
>>> free error due to XIVE/XICS limitation and keeping beyond 8192 will hit
>>> assert in tcg_region_init or spapr_xive_claim_irq.
>>>
>>> Logs:
>>>
>>> Without patch fix:
>>>
>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
>>> qemu-system-ppc64: IRQ 4096 is not free
>>> [root@host build]#
>>>
>>> On LPAR:
>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
>>> **
>>> ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
>>> (region_size >= 2 * page_size)
>>> Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
>>> (region_size >= 2 * page_size)
>>> Aborted (core dumped)
>>> [root@host build]#
>>>
>>> On x86:
>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
>>> qemu-system-ppc64: ../hw/intc/spapr_xive.c:596: spapr_xive_claim_irq:
>>> Assertion `lisn < xive->nr_irqs' failed.
>>> Aborted (core dumped)
>>> [root@host build]#
>>>
>>> With patch fix:
>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
>>> qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by
>>> machine 'pseries-8.2' is 4096
>>> [root@host build]#
>>>
>>> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
>>> ---
>>> hw/ppc/spapr.c | 9 +++------
>>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>>> index df09aa9d6a..0de11a4458 100644
>>> --- a/hw/ppc/spapr.c
>>> +++ b/hw/ppc/spapr.c
>>> @@ -4647,13 +4647,10 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
>>> mc->block_default_type = IF_SCSI;
>>> /*
>>> - * Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values
>>> - * should be limited by the host capability instead of hardcoded.
>>> - * max_cpus for KVM guests will be checked in kvm_init(), and TCG
>>> - * guests are welcome to have as many CPUs as the host are capable
>>> - * of emulate.
>>> + * While KVM determines max cpus in kvm_init() using kvm_max_vcpus(),
>>> + * In TCG the limit is restricted by the range of CPU IPIs available.
>>> */
>>> - mc->max_cpus = INT32_MAX;
>>> + mc->max_cpus = SPAPR_NR_IPIS;
>>
>> Is SPAPR_NR_IPIS also the upper limit for KVM?
>
> In KVM mode, the limit is restricted to what is supported by KVM which is checked using kvm_ioctl via wrappers in kvm_init and appears to be evaluating to 2048. So, having a larger default works for both case.
QEMU sets the number of cpus with KVM ioctls :
KVM_DEV_XICS_NR_SERVERS
KVM_DEV_XIVE_NR_SERVERS
This is important for the host since the interrupt controller is then
configured with these values through FW.
The default value is indeed 2K but this is large and wastes a lot of
HW resources, page mappings, etc.
Thanks,
C.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS.
2023-11-23 8:47 ` Cédric Le Goater
@ 2023-11-23 10:26 ` Philippe Mathieu-Daudé
2023-11-23 13:51 ` Cédric Le Goater
0 siblings, 1 reply; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-23 10:26 UTC (permalink / raw)
To: Cédric Le Goater, Harsh Prateek Bora, npiggin, qemu-ppc
Cc: danielhb413, clg, david, qemu-devel
On 23/11/23 09:47, Cédric Le Goater wrote:
> On 11/23/23 06:03, Harsh Prateek Bora wrote:
>> Hi Philippe,
>>
>> On 11/22/23 16:46, Philippe Mathieu-Daudé wrote:
>>> Hi Harsh,
>>>
>>> On 22/11/23 10:28, Harsh Prateek Bora wrote:
>>>> Initialize the machine specific max_cpus limit as per the maximum range
>>>> of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not
>>>> free error due to XIVE/XICS limitation and keeping beyond 8192 will hit
>>>> assert in tcg_region_init or spapr_xive_claim_irq.
>>>>
>>>> Logs:
>>>>
>>>> Without patch fix:
>>>>
>>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
>>>> qemu-system-ppc64: IRQ 4096 is not free
>>>> [root@host build]#
>>>>
>>>> On LPAR:
>>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
>>>> **
>>>> ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
>>>> (region_size >= 2 * page_size)
>>>> Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
>>>> (region_size >= 2 * page_size)
>>>> Aborted (core dumped)
>>>> [root@host build]#
>>>>
>>>> On x86:
>>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
>>>> qemu-system-ppc64: ../hw/intc/spapr_xive.c:596: spapr_xive_claim_irq:
>>>> Assertion `lisn < xive->nr_irqs' failed.
>>>> Aborted (core dumped)
>>>> [root@host build]#
>>>>
>>>> With patch fix:
>>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
>>>> qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by
>>>> machine 'pseries-8.2' is 4096
>>>> [root@host build]#
>>>>
>>>> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
>>>> ---
>>>> hw/ppc/spapr.c | 9 +++------
>>>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>>>> index df09aa9d6a..0de11a4458 100644
>>>> --- a/hw/ppc/spapr.c
>>>> +++ b/hw/ppc/spapr.c
>>>> @@ -4647,13 +4647,10 @@ static void
>>>> spapr_machine_class_init(ObjectClass *oc, void *data)
>>>> mc->block_default_type = IF_SCSI;
>>>> /*
>>>> - * Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values
>>>> - * should be limited by the host capability instead of hardcoded.
>>>> - * max_cpus for KVM guests will be checked in kvm_init(), and TCG
>>>> - * guests are welcome to have as many CPUs as the host are capable
>>>> - * of emulate.
>>>> + * While KVM determines max cpus in kvm_init() using
>>>> kvm_max_vcpus(),
>>>> + * In TCG the limit is restricted by the range of CPU IPIs
>>>> available.
>>>> */
>>>> - mc->max_cpus = INT32_MAX;
>>>> + mc->max_cpus = SPAPR_NR_IPIS;
>>>
>>> Is SPAPR_NR_IPIS also the upper limit for KVM?
>>
>> In KVM mode, the limit is restricted to what is supported by KVM which
>> is checked using kvm_ioctl via wrappers in kvm_init and appears to be
>> evaluating to 2048. So, having a larger default works for both case.
>
> QEMU sets the number of cpus with KVM ioctls :
>
> KVM_DEV_XICS_NR_SERVERS
> KVM_DEV_XIVE_NR_SERVERS
>
> This is important for the host since the interrupt controller is then
> configured with these values through FW.
>
> The default value is indeed 2K but this is large and wastes a lot of
> HW resources, page mappings, etc.
I was wondering if one day KVM raise its limit to 5k, then the
machine will clamp to 4k, and someone will have to debug that.
Not a big deal ;)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS.
2023-11-23 10:26 ` Philippe Mathieu-Daudé
@ 2023-11-23 13:51 ` Cédric Le Goater
0 siblings, 0 replies; 8+ messages in thread
From: Cédric Le Goater @ 2023-11-23 13:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Harsh Prateek Bora, npiggin,
qemu-ppc
Cc: danielhb413, clg, david, qemu-devel
On 11/23/23 11:26, Philippe Mathieu-Daudé wrote:
> On 23/11/23 09:47, Cédric Le Goater wrote:
>> On 11/23/23 06:03, Harsh Prateek Bora wrote:
>>> Hi Philippe,
>>>
>>> On 11/22/23 16:46, Philippe Mathieu-Daudé wrote:
>>>> Hi Harsh,
>>>>
>>>> On 22/11/23 10:28, Harsh Prateek Bora wrote:
>>>>> Initialize the machine specific max_cpus limit as per the maximum range
>>>>> of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not
>>>>> free error due to XIVE/XICS limitation and keeping beyond 8192 will hit
>>>>> assert in tcg_region_init or spapr_xive_claim_irq.
>>>>>
>>>>> Logs:
>>>>>
>>>>> Without patch fix:
>>>>>
>>>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
>>>>> qemu-system-ppc64: IRQ 4096 is not free
>>>>> [root@host build]#
>>>>>
>>>>> On LPAR:
>>>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
>>>>> **
>>>>> ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
>>>>> (region_size >= 2 * page_size)
>>>>> Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
>>>>> (region_size >= 2 * page_size)
>>>>> Aborted (core dumped)
>>>>> [root@host build]#
>>>>>
>>>>> On x86:
>>>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
>>>>> qemu-system-ppc64: ../hw/intc/spapr_xive.c:596: spapr_xive_claim_irq:
>>>>> Assertion `lisn < xive->nr_irqs' failed.
>>>>> Aborted (core dumped)
>>>>> [root@host build]#
>>>>>
>>>>> With patch fix:
>>>>> [root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
>>>>> qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by
>>>>> machine 'pseries-8.2' is 4096
>>>>> [root@host build]#
>>>>>
>>>>> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
>>>>> ---
>>>>> hw/ppc/spapr.c | 9 +++------
>>>>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>>>>> index df09aa9d6a..0de11a4458 100644
>>>>> --- a/hw/ppc/spapr.c
>>>>> +++ b/hw/ppc/spapr.c
>>>>> @@ -4647,13 +4647,10 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
>>>>> mc->block_default_type = IF_SCSI;
>>>>> /*
>>>>> - * Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values
>>>>> - * should be limited by the host capability instead of hardcoded.
>>>>> - * max_cpus for KVM guests will be checked in kvm_init(), and TCG
>>>>> - * guests are welcome to have as many CPUs as the host are capable
>>>>> - * of emulate.
>>>>> + * While KVM determines max cpus in kvm_init() using kvm_max_vcpus(),
>>>>> + * In TCG the limit is restricted by the range of CPU IPIs available.
>>>>> */
>>>>> - mc->max_cpus = INT32_MAX;
>>>>> + mc->max_cpus = SPAPR_NR_IPIS;
>>>>
>>>> Is SPAPR_NR_IPIS also the upper limit for KVM?
>>>
>>> In KVM mode, the limit is restricted to what is supported by KVM which is checked using kvm_ioctl via wrappers in kvm_init and appears to be evaluating to 2048. So, having a larger default works for both case.
>>
>> QEMU sets the number of cpus with KVM ioctls :
>>
>> KVM_DEV_XICS_NR_SERVERS
>> KVM_DEV_XIVE_NR_SERVERS
>>
>> This is important for the host since the interrupt controller is then
>> configured with these values through FW.
>>
>> The default value is indeed 2K but this is large and wastes a lot of
>> HW resources, page mappings, etc.
>
> I was wondering if one day KVM raise its limit to 5k, then the
> machine will clamp to 4k, and someone will have to debug that.
> Not a big deal ;)
Changing the number of CPUs will require some work in Linux first.
I think we (as ppc) tried to push it to 8K but there was some push
back upstream. Anyhow, there are DT issues also, memory layout, etc.
It won't happen without being noticed I am sure :)
Anyhow, If we need more IPIs to support more CPUs, the IRQ number
space will need an extra range after the device range to preserve
compatibility.
Thanks,
C.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-11-23 13:52 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-22 9:24 [PATCH v2 1/2] ppc/spapr: Introduce SPAPR_NR_IPIS to refer IRQ range for CPU IPIs Harsh Prateek Bora
2023-11-22 9:24 ` [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS Harsh Prateek Bora
-- strict thread matches above, loose matches on Subject: below --
2023-11-22 9:28 [PATCH RESEND v2 0/2] Introduce SPAPR_NR_IPIS and fix max-cpus Harsh Prateek Bora
2023-11-22 9:28 ` [PATCH v2 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_NR_IPIS Harsh Prateek Bora
2023-11-22 11:16 ` Philippe Mathieu-Daudé
2023-11-23 5:03 ` Harsh Prateek Bora
2023-11-23 8:47 ` Cédric Le Goater
2023-11-23 10:26 ` Philippe Mathieu-Daudé
2023-11-23 13:51 ` Cédric Le Goater
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).