[PATCH v2 2/2] ram-block-attributes: Unify the retrieval of the block size

Chenyi Qiang posted 2 patches 3 weeks, 1 day ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
[PATCH v2 2/2] ram-block-attributes: Unify the retrieval of the block size
Posted by Chenyi Qiang 3 weeks, 1 day ago
There's an existing helper function designed to obtain the block size.
Modify ram_block_attribute_create() to use this function for
consistency.

Tested-by: Farrah Chen <farrah.chen@intel.com>
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
---
Changes in v2:
  - Newly added.
---
 system/ram-block-attributes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/system/ram-block-attributes.c b/system/ram-block-attributes.c
index a7579de5b46..cf8f5f41966 100644
--- a/system/ram-block-attributes.c
+++ b/system/ram-block-attributes.c
@@ -390,7 +390,7 @@ int ram_block_attributes_state_change(RamBlockAttributes *attr,
 
 RamBlockAttributes *ram_block_attributes_create(RAMBlock *ram_block)
 {
-    const int block_size  = qemu_real_host_page_size();
+    const int block_size  = ram_block_attributes_get_block_size();
     RamBlockAttributes *attr;
     MemoryRegion *mr = ram_block->mr;
 
-- 
2.43.5
Re: [PATCH v2 2/2] ram-block-attributes: Unify the retrieval of the block size
Posted by Xiaoyao Li 3 weeks ago
On 10/23/2025 5:55 PM, Chenyi Qiang wrote:
> There's an existing helper function designed to obtain the block size.
> Modify ram_block_attribute_create() to use this function for
> consistency.
> 
> Tested-by: Farrah Chen <farrah.chen@intel.com>
> Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>

Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>

> ---
> Changes in v2:
>    - Newly added.
> ---
>   system/ram-block-attributes.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/system/ram-block-attributes.c b/system/ram-block-attributes.c
> index a7579de5b46..cf8f5f41966 100644
> --- a/system/ram-block-attributes.c
> +++ b/system/ram-block-attributes.c
> @@ -390,7 +390,7 @@ int ram_block_attributes_state_change(RamBlockAttributes *attr,
>   
>   RamBlockAttributes *ram_block_attributes_create(RAMBlock *ram_block)
>   {
> -    const int block_size  = qemu_real_host_page_size();
> +    const int block_size  = ram_block_attributes_get_block_size();
>       RamBlockAttributes *attr;
>       MemoryRegion *mr = ram_block->mr;
>
Re: [PATCH v2 2/2] ram-block-attributes: Unify the retrieval of the block size
Posted by David Hildenbrand 3 weeks, 1 day ago
On 23.10.25 11:55, Chenyi Qiang wrote:
> There's an existing helper function designed to obtain the block size.
> Modify ram_block_attribute_create() to use this function for
> consistency.
> 
> Tested-by: Farrah Chen <farrah.chen@intel.com>
> Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
> ---
> Changes in v2:
>    - Newly added.
> ---
>   system/ram-block-attributes.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/system/ram-block-attributes.c b/system/ram-block-attributes.c
> index a7579de5b46..cf8f5f41966 100644
> --- a/system/ram-block-attributes.c
> +++ b/system/ram-block-attributes.c
> @@ -390,7 +390,7 @@ int ram_block_attributes_state_change(RamBlockAttributes *attr,
>   
>   RamBlockAttributes *ram_block_attributes_create(RAMBlock *ram_block)
>   {
> -    const int block_size  = qemu_real_host_page_size();
> +    const int block_size  = ram_block_attributes_get_block_size();

Double space before the "  " can be removed while you touch this.

-- 
Cheers

David / dhildenb
Re: [PATCH v2 2/2] ram-block-attributes: Unify the retrieval of the block size
Posted by Chenyi Qiang 3 weeks, 1 day ago

On 10/23/2025 6:17 PM, David Hildenbrand wrote:
> On 23.10.25 11:55, Chenyi Qiang wrote:
>> There's an existing helper function designed to obtain the block size.
>> Modify ram_block_attribute_create() to use this function for
>> consistency.
>>
>> Tested-by: Farrah Chen <farrah.chen@intel.com>
>> Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
>> ---
>> Changes in v2:
>>    - Newly added.
>> ---
>>   system/ram-block-attributes.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/system/ram-block-attributes.c b/system/ram-block-attributes.c
>> index a7579de5b46..cf8f5f41966 100644
>> --- a/system/ram-block-attributes.c
>> +++ b/system/ram-block-attributes.c
>> @@ -390,7 +390,7 @@ int ram_block_attributes_state_change(RamBlockAttributes *attr,
>>     RamBlockAttributes *ram_block_attributes_create(RAMBlock *ram_block)
>>   {
>> -    const int block_size  = qemu_real_host_page_size();
>> +    const int block_size  = ram_block_attributes_get_block_size();
> 
> Double space before the "  " can be removed while you touch this.

Oops, so careless I was. To fixup this patch:

===

From 3c224dfb946feccf6f94af8aa1068cc72bf5ddc7 Mon Sep 17 00:00:00 2001
From: Chenyi Qiang <chenyi.qiang@intel.com>
Date: Thu, 23 Oct 2025 19:43:52 +0800
Subject: [PATCH] fixup! ram-block-attributes: Unify the retrieval of the block
 size

Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
---
 system/ram-block-attributes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/system/ram-block-attributes.c b/system/ram-block-attributes.c
index cf8f5f41966..fb7c5c27467 100644
--- a/system/ram-block-attributes.c
+++ b/system/ram-block-attributes.c
@@ -390,7 +390,7 @@ int ram_block_attributes_state_change(RamBlockAttributes *attr,
 
 RamBlockAttributes *ram_block_attributes_create(RAMBlock *ram_block)
 {
-    const int block_size  = ram_block_attributes_get_block_size();
+    const int block_size = ram_block_attributes_get_block_size();
     RamBlockAttributes *attr;
     MemoryRegion *mr = ram_block->mr;
 
-- 
2.43.5



>