[PATCH 4/5] hw/loongarch: Set minimium memory size as 256M

Bibo Mao posted 5 patches 8 months, 3 weeks ago
Maintainers: Song Gao <gaosong@loongson.cn>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
[PATCH 4/5] hw/loongarch: Set minimium memory size as 256M
Posted by Bibo Mao 8 months, 3 weeks ago
The minium memory size for LoongArch UEFI bios is 256M, also some
test cases such as migration and qos uses parameter 256M.

Here set minium memory size for Loongarch VirtMachine with 256M,
also default memory size is changed with 256M.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 hw/loongarch/virt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index a7d700497d..5bc332f4e3 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -815,8 +815,8 @@ static void virt_init(MachineState *machine)
         cpu_model = LOONGARCH_CPU_TYPE_NAME("la464");
     }
 
-    if (ram_size < 1 * GiB) {
-        error_report("ram_size must be greater than 1G.");
+    if (ram_size < 256 * MiB) {
+        error_report("ram_size must be greater than 256M.");
         exit(1);
     }
     create_fdt(vms);
@@ -1144,7 +1144,7 @@ static void virt_class_init(ObjectClass *oc, void *data)
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
 
     mc->init = virt_init;
-    mc->default_ram_size = 1 * GiB;
+    mc->default_ram_size = 256 * MiB;
     mc->default_cpu_type = LOONGARCH_CPU_TYPE_NAME("la464");
     mc->default_ram_id = "loongarch.ram";
     mc->max_cpus = LOONGARCH_MAX_CPUS;
-- 
2.39.3
Re: [PATCH 4/5] hw/loongarch: Set minimium memory size as 256M
Posted by Thomas Huth 8 months, 3 weeks ago
On 20/02/2024 13.41, Bibo Mao wrote:
> The minium memory size for LoongArch UEFI bios is 256M, also some
> test cases such as migration and qos uses parameter 256M.
> 
> Here set minium memory size for Loongarch VirtMachine with 256M,
> also default memory size is changed with 256M.
> 
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>   hw/loongarch/virt.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
> index a7d700497d..5bc332f4e3 100644
> --- a/hw/loongarch/virt.c
> +++ b/hw/loongarch/virt.c
> @@ -815,8 +815,8 @@ static void virt_init(MachineState *machine)
>           cpu_model = LOONGARCH_CPU_TYPE_NAME("la464");
>       }
>   
> -    if (ram_size < 1 * GiB) {
> -        error_report("ram_size must be greater than 1G.");
> +    if (ram_size < 256 * MiB) {
> +        error_report("ram_size must be greater than 256M.");
>           exit(1);
>       }
>       create_fdt(vms);
> @@ -1144,7 +1144,7 @@ static void virt_class_init(ObjectClass *oc, void *data)
>       HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
>   
>       mc->init = virt_init;
> -    mc->default_ram_size = 1 * GiB;
> +    mc->default_ram_size = 256 * MiB;

While changing the minimum ram_size in the first hunk is certainly a good 
idea, you should maybe consider twice whether you also want to change the 
default_ram_size here. 256 MiB is often not enough to run a guest OS like 
Linux, so for most users it might be more convenient if you have a 
default_ram_size of 1GiB instead. At least that's what I've seen on other 
architectures. YMMV.

  Thomas
Re: [PATCH 4/5] hw/loongarch: Set minimium memory size as 256M
Posted by maobibo 8 months, 3 weeks ago

On 2024/2/21 上午12:47, Thomas Huth wrote:
> On 20/02/2024 13.41, Bibo Mao wrote:
>> The minium memory size for LoongArch UEFI bios is 256M, also some
>> test cases such as migration and qos uses parameter 256M.
>>
>> Here set minium memory size for Loongarch VirtMachine with 256M,
>> also default memory size is changed with 256M.
>>
>> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
>> ---
>>   hw/loongarch/virt.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
>> index a7d700497d..5bc332f4e3 100644
>> --- a/hw/loongarch/virt.c
>> +++ b/hw/loongarch/virt.c
>> @@ -815,8 +815,8 @@ static void virt_init(MachineState *machine)
>>           cpu_model = LOONGARCH_CPU_TYPE_NAME("la464");
>>       }
>> -    if (ram_size < 1 * GiB) {
>> -        error_report("ram_size must be greater than 1G.");
>> +    if (ram_size < 256 * MiB) {
>> +        error_report("ram_size must be greater than 256M.");
>>           exit(1);
>>       }
>>       create_fdt(vms);
>> @@ -1144,7 +1144,7 @@ static void virt_class_init(ObjectClass *oc, 
>> void *data)
>>       HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
>>       mc->init = virt_init;
>> -    mc->default_ram_size = 1 * GiB;
>> +    mc->default_ram_size = 256 * MiB;
> 
> While changing the minimum ram_size in the first hunk is certainly a 
> good idea, you should maybe consider twice whether you also want to 
> change the default_ram_size here. 256 MiB is often not enough to run a 
> guest OS like Linux, so for most users it might be more convenient if 
> you have a default_ram_size of 1GiB instead. At least that's what I've 
> seen on other architectures. YMMV.
Sounds good, I will keep default ram size unchanged, and only change 
minimum ram size with 256MiB.

And thanks for your suggestion.

Regards
Bibo Mao
> 
>   Thomas