qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org,  Andrei Gudkov <gudkov.andrei@huawei.com>,
	Leonardo Bras <leobras@redhat.com>,
	 Chuan Zheng <zhengchuan@huawei.com>,
	Peter Xu <peterx@redhat.com>,
	 Zhenzhong Duan <zhenzhong.duan@intel.com>
Subject: Re: [PATCH 1/3] migration: Teach dirtyrate about qemu_target_page_size()
Date: Thu, 11 May 2023 13:44:44 +0200	[thread overview]
Message-ID: <87y1lv3xeb.fsf@secure.mitica> (raw)
In-Reply-To: <80a9bfb8-c99c-7b78-fac0-867f68779f21@linaro.org> (Richard Henderson's message of "Thu, 11 May 2023 12:07:58 +0100")

Richard Henderson <richard.henderson@linaro.org> wrote:
> On 5/11/23 10:22, Juan Quintela wrote:
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>   migration/dirtyrate.c | 11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>> diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
>> index 180ba38c7a..9aa092738c 100644
>> --- a/migration/dirtyrate.c
>> +++ b/migration/dirtyrate.c
>> @@ -17,6 +17,7 @@
>>   #include "cpu.h"
>>   #include "exec/ramblock.h"
>>   #include "exec/ram_addr.h"
>> +#include "exec/target_page.h"
>>   #include "qemu/rcu_queue.h"
>>   #include "qemu/main-loop.h"
>>   #include "qapi/qapi-commands-migration.h"
>> @@ -78,7 +79,7 @@ static int64_t do_calculate_dirtyrate(DirtyPageRecord dirty_pages,
>>       uint64_t increased_dirty_pages =
>>           dirty_pages.end_pages - dirty_pages.start_pages;
>>   -    memory_size_MB = (increased_dirty_pages * TARGET_PAGE_SIZE)
>> >> 20;
>> +    memory_size_MB = (increased_dirty_pages * qemu_target_page_size()) >> 20;
>
> See the recent cleanups for dirtylimit_dirty_ring_full_time, folding
> multiply+shift into subtract+shift.
>
>>         return memory_size_MB * 1000 / calc_time_ms;
>>   }
>> @@ -291,8 +292,8 @@ static void update_dirtyrate_stat(struct RamblockDirtyInfo *info)
>>       DirtyStat.page_sampling.total_dirty_samples += info->sample_dirty_count;
>>       DirtyStat.page_sampling.total_sample_count += info->sample_pages_count;
>>       /* size of total pages in MB */
>> -    DirtyStat.page_sampling.total_block_mem_MB += (info->ramblock_pages *
>> -                                                   TARGET_PAGE_SIZE) >> 20;
>> +    DirtyStat.page_sampling.total_block_mem_MB +=
>> +        (info->ramblock_pages * qemu_target_page_size()) >> 20;
>
> And a third copy?
> Can we abstract this somewhere?

This is for dirtyrate folks.  But I agree that having to do this so many
times look wrong.  I will wait to see if they answer.

Later, Juan.



  reply	other threads:[~2023-05-11 11:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11  9:22 [PATCH 0/3] migration: Make dirtyrate.c target independent Juan Quintela
2023-05-11  9:22 ` [PATCH 1/3] migration: Teach dirtyrate about qemu_target_page_size() Juan Quintela
2023-05-11 11:07   ` Richard Henderson
2023-05-11 11:44     ` Juan Quintela [this message]
2023-05-11 13:12     ` Juan Quintela
2023-05-11 14:36       ` gudkov.andrei--- via
2023-05-11  9:22 ` [PATCH 2/3] migration: Teach dirtyrate about qemu_target_page_bits() Juan Quintela
2023-05-11 11:08   ` Richard Henderson
2023-05-11 12:01   ` Philippe Mathieu-Daudé
2023-05-11  9:22 ` [PATCH 3/3] migration: Make dirtyrate.c target independent Juan Quintela
2023-05-11 11:09   ` Richard Henderson
2023-05-11 11:46     ` Juan Quintela
2023-05-11 11:52       ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y1lv3xeb.fsf@secure.mitica \
    --to=quintela@redhat.com \
    --cc=gudkov.andrei@huawei.com \
    --cc=leobras@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=zhengchuan@huawei.com \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).