From: Liang Li <liang.z.li@intel.com>
To: mst@redhat.com, quintela@redhat.com, amit.shah@redhat.com,
pbonzini@redhat.com, lcapitulino@redhat.com
Cc: armbru@redhat.com, peter.maydell@linaro.org, rth@twiddle.net,
ehabkost@redhat.com, james.hogan@imgtec.com,
aurelien@aurel32.net, leon.alrae@imgtec.com, agraf@suse.de,
borntraeger@de.ibm.com, cornelia.huck@de.ibm.com,
qemu-devel@nongnu.org, kvm@vger.kernel.org,
Liang Li <liang.z.li@intel.com>
Subject: [Qemu-devel] [PATCH QEMU 2/5] kvm: Add two new arch specific functions
Date: Tue, 19 Apr 2016 22:20:40 +0800 [thread overview]
Message-ID: <1461075643-3668-3-git-send-email-liang.z.li@intel.com> (raw)
In-Reply-To: <1461075643-3668-1-git-send-email-liang.z.li@intel.com>
Add a new function to get the vm's max pfn and a new function
to filter out the holes to get a tight free page bitmap.
They are implemented on X86, and all the arches should implement
them for live migration optimization.
Signed-off-by: Liang Li <liang.z.li@intel.com>
---
include/sysemu/kvm.h | 2 ++
target-arm/kvm.c | 14 ++++++++++++++
target-i386/kvm.c | 35 +++++++++++++++++++++++++++++++++++
target-mips/kvm.c | 14 ++++++++++++++
target-ppc/kvm.c | 14 ++++++++++++++
target-s390x/kvm.c | 14 ++++++++++++++
6 files changed, 93 insertions(+)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 0e18f15..5263304 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -228,6 +228,8 @@ int kvm_remove_breakpoint(CPUState *cpu, target_ulong addr,
target_ulong len, int type);
void kvm_remove_all_breakpoints(CPUState *cpu);
int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap);
+unsigned long *tighten_guest_free_page_bmap(unsigned long *bmap);
+unsigned long get_guest_max_pfn(void);
#ifndef _WIN32
int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset);
#endif
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index 3671032..59e9417 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -626,3 +626,17 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
{
return (data - 32) & 0xffff;
}
+
+unsigned long get_guest_max_pfn(void)
+{
+ /* To be done */
+
+ return 0;
+}
+
+unsigned long *tighten_guest_free_page_bmap(unsigned long *bmap)
+{
+ /* To be done */
+
+ return bmap;
+}
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 799fdfa..76a33bd 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -3334,3 +3334,38 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
{
abort();
}
+
+unsigned long get_guest_max_pfn(void)
+{
+ PCMachineState *pcms = PC_MACHINE(current_machine);
+ ram_addr_t above_4g_mem = pcms->above_4g_mem_size;
+ unsigned long max_pfn;
+
+ if (above_4g_mem) {
+ max_pfn = ((1ULL << 32) + above_4g_mem) >> TARGET_PAGE_BITS;
+ } else {
+ max_pfn = pcms->below_4g_mem_size >> TARGET_PAGE_BITS;
+ }
+
+ return max_pfn;
+}
+
+unsigned long *tighten_guest_free_page_bmap(unsigned long *bmap)
+{
+ PCMachineState *pcms = PC_MACHINE(current_machine);
+ ram_addr_t above_4g_mem = pcms->above_4g_mem_size;
+
+ if (above_4g_mem) {
+ unsigned long *src, *dst, len, pos;
+ ram_addr_t below_4g_mem = pcms->below_4g_mem_size;
+ src = bmap + ((1ULL << 32) >> TARGET_PAGE_BITS) / BITS_PER_LONG;
+ dst = bmap + (below_4g_mem >> TARGET_PAGE_BITS) / BITS_PER_LONG;
+ bitmap_move(dst, src, above_4g_mem >> TARGET_PAGE_BITS);
+
+ pos = (above_4g_mem + below_4g_mem) >> TARGET_PAGE_BITS;
+ len = ((1ULL << 32) - below_4g_mem) >> TARGET_PAGE_BITS;
+ bitmap_clear(bmap, pos, len);
+ }
+
+ return bmap;
+}
diff --git a/target-mips/kvm.c b/target-mips/kvm.c
index 950bc05..23fdc50 100644
--- a/target-mips/kvm.c
+++ b/target-mips/kvm.c
@@ -1048,3 +1048,17 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
{
abort();
}
+
+unsigned long get_guest_max_pfn(void)
+{
+ /* To be done */
+
+ return 0;
+}
+
+unsigned long *tighten_guest_free_page_bmap(unsigned long *bmap)
+{
+ /* To be done */
+
+ return bmap;
+}
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index c4c8146..bf4c60f 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -2579,3 +2579,17 @@ int kvmppc_enable_hwrng(void)
return kvmppc_enable_hcall(kvm_state, H_RANDOM);
}
+
+unsigned long get_guest_max_pfn(void)
+{
+ /* To be done */
+
+ return 0;
+}
+
+unsigned long *tighten_guest_free_page_bmap(unsigned long *bmap)
+{
+ /* To be done */
+
+ return bmap;
+}
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index e1859ca..7f5e1b8 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -2250,3 +2250,17 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
{
abort();
}
+
+unsigned long get_guest_max_pfn(void)
+{
+ /* To be done */
+
+ return 0;
+}
+
+unsigned long *tighten_guest_free_page_bmap(unsigned long *bmap)
+{
+ /* To be done */
+
+ return bmap;
+}
--
1.8.3.1
next prev parent reply other threads:[~2016-04-19 14:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 14:20 [Qemu-devel] [PATCH QEMU 0/5] spee up live migration by skipping free pages Liang Li
2016-04-19 14:20 ` [Qemu-devel] [PATCH QEMU 1/5] bitmap: Add a new bitmap_move function Liang Li
2016-04-19 14:20 ` Liang Li [this message]
2016-04-19 14:20 ` [Qemu-devel] [PATCH QEMU 3/5] virtio-balloon: Add a new feature to balloon device Liang Li
2016-04-19 16:32 ` Michael S. Tsirkin
2016-04-19 14:20 ` [Qemu-devel] [PATCH QEMU 4/5] migration: filter out free pages during live migration Liang Li
2016-04-19 14:20 ` [Qemu-devel] [PATCH QEMU 5/5] migration: Add the interface for cache drop control Liang Li
2016-04-19 14:52 ` Eric Blake
2016-04-19 14:59 ` Li, Liang Z
2016-04-19 14:37 ` [Qemu-devel] [PATCH QEMU 0/5] spee up live migration by skipping free pages Alexander Graf
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=1461075643-3668-3-git-send-email-liang.z.li@intel.com \
--to=liang.z.li@intel.com \
--cc=agraf@suse.de \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=aurelien@aurel32.net \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=ehabkost@redhat.com \
--cc=james.hogan@imgtec.com \
--cc=kvm@vger.kernel.org \
--cc=lcapitulino@redhat.com \
--cc=leon.alrae@imgtec.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=rth@twiddle.net \
/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).