From: Peter Xu <peterx@redhat.com>
To: huangy81@chinatelecom.cn
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: Wed, 16 Jun 2021 11:22:43 -0400 [thread overview]
Message-ID: <YMoXQxNW0EHGXCS8@t490s> (raw)
In-Reply-To: <3848028c3029e2e870286c84c2b3e9a93967567e.1623804189.git.huangy81@chinatelecom.cn>
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.
>
> 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));
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.
--
Peter Xu
next prev parent reply other threads:[~2021-06-16 15:24 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 [this message]
2021-06-17 4:49 ` Hyman Huang
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=YMoXQxNW0EHGXCS8@t490s \
--to=peterx@redhat.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=huangy81@chinatelecom.cn \
--cc=pbonzini@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 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).