[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v8 2/6] memory: make global_dirty_tracking a bitmask
From: |
Peter Xu |
Subject: |
Re: [PATCH v8 2/6] memory: make global_dirty_tracking a bitmask |
Date: |
Fri, 18 Jun 2021 11:46:46 -0400 |
On Fri, Jun 18, 2021 at 11:32:03PM +0800, huangy81@chinatelecom.cn wrote:
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index b114f54..dd2404f 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -55,7 +55,17 @@ static inline void fuzz_dma_read_cb(size_t addr,
> }
> #endif
>
> -extern bool global_dirty_log;
> +/* Possible bits for global_dirty_log */
s/log/tracking/
[...]
> -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)));
> + assert((global_dirty_tracking & flags) == flags);
> + global_dirty_tracking &= ~flags;
> +
> + trace_global_dirty_changed(global_dirty_tracking);
>
> /* Refresh DIRTY_MEMORY_MIGRATION bit. */
> memory_region_transaction_begin();
> @@ -2691,8 +2699,9 @@ static void memory_global_dirty_log_do_stop(void)
> static void memory_vm_change_state_handler(void *opaque, bool running,
> RunState state)
> {
> + unsigned int *flags = (unsigned int *)opaque;
[1]
> if (running) {
> - memory_global_dirty_log_do_stop();
> + memory_global_dirty_log_do_stop(*flags);
>
> if (vmstate_change) {
> qemu_del_vm_change_state_handler(vmstate_change);
> @@ -2701,18 +2710,19 @@ static void memory_vm_change_state_handler(void
> *opaque, bool running,
> }
> }
>
> -void memory_global_dirty_log_stop(void)
> +void memory_global_dirty_log_stop(unsigned int flags)
> {
> if (!runstate_is_running()) {
> if (vmstate_change) {
> return;
> }
> vmstate_change = qemu_add_vm_change_state_handler(
> - memory_vm_change_state_handler, NULL);
> + memory_vm_change_state_handler,
> + (void *)&flags);
If to drop malloc/free, we need to cast it with (void *)flags. &flags is the
address of the local var, which will lost its meaning after the function
returns..
Then at [1] it should be "unsigned int flags = (unsigned int)opaque;".
--
Peter Xu
- [PATCH v8 0/6] support dirtyrate at the granualrity of vcpu, huangy81, 2021/06/18
- [PATCH v8 4/6] migration/dirtyrate: adjust order of registering thread, huangy81, 2021/06/18
- [PATCH v8 3/6] migration/dirtyrate: introduce struct and adjust DirtyRateStat, huangy81, 2021/06/18
- [PATCH v8 5/6] migration/dirtyrate: move init step of calculation to main thread, huangy81, 2021/06/18
- [PATCH v8 6/6] migration/dirtyrate: implement dirty-ring dirtyrate calculation, huangy81, 2021/06/18
- Re: [PATCH v8 0/6] support dirtyrate at the granualrity of vcpu, Peter Xu, 2021/06/18