All of lore.kernel.org
 help / color / mirror / Atom feed
From: huangy81@chinatelecom.cn
To: qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	Hyman <huangy81@chinatelecom.cn>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Peter Xu <peterx@redhat.com>, Chuan Zheng <zhengchuan@huawei.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH v3 2/3] memory: introduce DirtyRateDirtyPages and util function
Date: Thu, 15 Jul 2021 23:51:32 +0800	[thread overview]
Message-ID: <316de737c2fee577cbf75a47dc7537ce38844a63.1626364220.git.huangy81@chinatelecom.cn> (raw)
In-Reply-To: <cover.1626354884.git.huangy81@chinatelecom.cn>
In-Reply-To: <cover.1626364220.git.huangy81@chinatelecom.cn>

From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>

introduce DirtyRateDirtyPages and use it to the dirty pages
along with memory_global_dirty_log_sync.
introduce cpu_physical_memory_dirtyrate_reset_protect to
clear dirty bitmap within slot in kvm

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
---
 include/exec/ram_addr.h | 19 +++++++++++++++++++
 migration/dirtyrate.c   |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 45c9132..dce0f46 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -26,6 +26,8 @@
 #include "exec/ramlist.h"
 #include "exec/ramblock.h"
 
+extern uint64_t DirtyRateDirtyPages;
+
 /**
  * clear_bmap_size: calculate clear bitmap size
  *
@@ -415,6 +417,17 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
             }
         }
     }
+
+    if (global_dirty_tracking &&
+        global_dirty_tracking & GLOBAL_DIRTY_DIRTY_RATE) {
+        long nr = BITS_TO_LONGS(pages);
+        for (i = 0; i < nr; i++) {
+            if (bitmap[i]) {
+                unsigned long temp = leul_to_cpu(bitmap[i]);
+                DirtyRateDirtyPages += ctpopl(temp);
+            }
+        }
+    }
 }
 #endif /* not _WIN32 */
 
@@ -510,5 +523,11 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb,
 
     return num_dirty;
 }
+
+static inline
+void cpu_physical_memory_dirtyrate_reset_protect(RAMBlock *rb)
+{
+    memory_region_clear_dirty_bitmap(rb->mr, 0, rb->used_length);
+}
 #endif
 #endif
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 3c8c5e2..c465e62 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -28,6 +28,8 @@
 #include "sysemu/runstate.h"
 #include "exec/memory.h"
 
+uint64_t DirtyRateDirtyPages;
+
 typedef struct DirtyPageRecord {
     uint64_t start_pages;
     uint64_t end_pages;
-- 
1.8.3.1



  parent reply	other threads:[~2021-07-15 15:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 15:51 [PATCH v3 0/3] support dirtyrate measurement with dirty bitmap huangy81
     [not found] ` <cover.1626364220.git.huangy81@chinatelecom.cn>
2021-07-15 15:51   ` [PATCH v3 1/3] KVM: introduce kvm_get_manual_dirty_log_protect huangy81
2021-07-15 15:51   ` huangy81 [this message]
2021-07-15 20:49     ` [PATCH v3 2/3] memory: introduce DirtyRateDirtyPages and util function Peter Xu
2021-07-15 15:51   ` [PATCH v3 3/3] migration/dirtyrate: implement dirty-bitmap dirtyrate calculation huangy81
2021-07-15 20:58     ` Peter Xu
2021-07-15 21:00 ` [PATCH v3 0/3] support dirtyrate measurement with dirty bitmap 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=316de737c2fee577cbf75a47dc7537ce38844a63.1626364220.git.huangy81@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.