From: Hyman Huang <huangy81@chinatelecom.cn>
To: Peter Xu <peterx@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
Juan Quintela <quintela@redhat.com>,
qemu-devel@nongnu.org,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Chuan Zheng <zhengchuan@huawei.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v4 2/6] memory: make global_dirty_log a bitmask
Date: Thu, 17 Jun 2021 12:49:49 +0800 [thread overview]
Message-ID: <6b74cc3d-49ba-143b-d0eb-946874580390@chinatelecom.cn> (raw)
In-Reply-To: <YMoXQxNW0EHGXCS8@t490s>
在 2021/6/16 23:22, Peter Xu 写道:
> On Wed, Jun 16, 2021 at 09:12:28AM +0800, huangy81@chinatelecom.cn wrote:
>> diff --git a/include/exec/memory.h b/include/exec/memory.h
>> index b114f54..e31eef2 100644
>> --- a/include/exec/memory.h
>> +++ b/include/exec/memory.h
>> @@ -55,7 +55,11 @@ static inline void fuzz_dma_read_cb(size_t addr,
>> }
>> #endif
>>
>> -extern bool global_dirty_log;
>> +/* what is the purpose of current dirty log, migration or dirty rate ? */
>
> Nitpick: I'll make it:
>
> /* Possible bits for global_dirty_log */
>
> /* Dirty tracking enabled because migration is running */
> #define GLOBAL_DIRTY_MIGRATION (1U << 0)
>
> /* Dirty tracking enabled because measuring dirty rate */
> #define GLOBAL_DIRTY_DIRTY_RATE (1U << 1)
>
>> +#define GLOBAL_DIRTY_MIGRATION (1U << 0)
>> +#define GLOBAL_DIRTY_DIRTY_RATE (1U << 1)
>> +
>> +extern unsigned int global_dirty_log;
>>
>> typedef struct MemoryRegionOps MemoryRegionOps;
>>
>
> [...]
>
>> @@ -39,7 +39,7 @@
>> static unsigned memory_region_transaction_depth;
>> static bool memory_region_update_pending;
>> static bool ioeventfd_update_pending;
>> -bool global_dirty_log;
>> +unsigned int global_dirty_log;
>
> I'm wondering whether it's a good chance to rename it to global_dirty_tracking,
> because "logging" has a hint on the method while it's not the only one now.
yeah, all references to global_dirty_log should be modified and can this
be done in a single patch before this patchset?
>
>>
>> static QTAILQ_HEAD(, MemoryListener) memory_listeners
>> = QTAILQ_HEAD_INITIALIZER(memory_listeners);
>> @@ -2659,14 +2659,19 @@ void memory_global_after_dirty_log_sync(void)
>>
>> static VMChangeStateEntry *vmstate_change;
>>
>> -void memory_global_dirty_log_start(void)
>> +void memory_global_dirty_log_start(unsigned int flags)
>> {
>> if (vmstate_change) {
>> qemu_del_vm_change_state_handler(vmstate_change);
>> vmstate_change = NULL;
>> }
>>
>> - global_dirty_log = true;
>> +#define GLOBAL_DIRTY_MASK (0x3)
>> + assert(flags && !(flags & (~GLOBAL_DIRTY_MASK)));
>> + assert(global_dirty_log ^ flags);
>
> Heh, this is probably my fault... I think what I wanted to suggest is actually:
>
> assert(!(global_dirty_log & flags));
this is more graceful if concerning about only one of the reason can
start dirty tracking at once. I'll pick up it in the next version.
>
> Then for stop() below...
>
>> + global_dirty_log |= flags;
>> +
>> + trace_global_dirty_changed(global_dirty_log);
>>
>> MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
>>
>> @@ -2676,9 +2681,12 @@ void memory_global_dirty_log_start(void)
>> memory_region_transaction_commit();
>> }
>>
>> -static void memory_global_dirty_log_do_stop(void)
>> +static void memory_global_dirty_log_do_stop(unsigned int flags)
>> {
>> - global_dirty_log = false;
>> + assert(flags && !(flags & (~GLOBAL_DIRTY_MASK)));
>
> ... it should probably be:
>
> assert((global_dirty_log & flags) == flags);
>
> Sorry about the confusion.
not at all, since i'm not figure out how this bitmask works clearly,
thanks a lot for your guidance.
>
--
Best regard
Hyman Huang(黄勇)
next prev parent reply other threads:[~2021-06-17 4:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 1:12 [PATCH v4 0/6] support dirtyrate at the granualrity of vcpu huangy81
2021-06-16 1:12 ` [PATCH v4 1/6] KVM: introduce dirty_pages and kvm_dirty_ring_enabled huangy81
2021-06-16 15:23 ` Peter Xu
2021-06-16 1:12 ` [PATCH v4 2/6] memory: make global_dirty_log a bitmask huangy81
2021-06-16 15:22 ` Peter Xu
2021-06-17 4:49 ` Hyman Huang [this message]
2021-06-16 1:12 ` [PATCH v4 3/6] migration/dirtyrate: introduce struct and adjust DirtyRateStat huangy81
2021-06-16 15:30 ` Peter Xu
2021-06-16 1:12 ` [PATCH v4 4/6] migration/dirtyrate: adjust order of registering thread huangy81
2021-06-16 15:32 ` Peter Xu
2021-06-16 1:12 ` [PATCH v4 5/6] migration/dirtyrate: move init step of calculation to main thread huangy81
2021-06-16 16:47 ` Peter Xu
2021-06-16 1:12 ` [PATCH v4 6/6] migration/dirtyrate: implement dirty-ring dirtyrate calculation huangy81
2021-06-16 16:56 ` Peter Xu
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=6b74cc3d-49ba-143b-d0eb-946874580390@chinatelecom.cn \
--to=huangy81@chinatelecom.cn \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=zhengchuan@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.