From: "Michael S. Tsirkin" <mst@redhat.com>
To: Liang Li <liang.z.li@intel.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org,
lcapitulino@redhat.com, pbonzini@redhat.com, quintela@redhat.com,
amit.shah@redhat.com, dgilbert@redhat.com
Subject: Re: [Qemu-devel] [QEMU 6/7] kvm: Add two new arch specific functions
Date: Sun, 19 Jun 2016 07:27:59 +0300 [thread overview]
Message-ID: <20160619072648-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1465813009-21390-7-git-send-email-liang.z.li@intel.com>
On Mon, Jun 13, 2016 at 06:16:48PM +0800, Liang Li wrote:
> 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 ad6f837..50915f9 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -230,6 +230,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 83da447..6464542 100644
> --- a/target-arm/kvm.c
> +++ b/target-arm/kvm.c
> @@ -627,3 +627,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 abf50e6..0b394cb 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -3327,3 +3327,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;
> +}
Why is this in kvm?
> +
> +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;
> +}
what does this do? External APIs should have documentation.
> diff --git a/target-mips/kvm.c b/target-mips/kvm.c
> index a854e4d..89a54e5 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 24d6032..e222b31 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 8f46fd0..893755b 100644
> --- a/target-s390x/kvm.c
> +++ b/target-s390x/kvm.c
> @@ -2271,3 +2271,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.9.1
next prev parent reply other threads:[~2016-06-19 4:28 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 10:16 [Qemu-devel] [QEMU 0/7] Fast balloon and fast live migration Liang Li
2016-06-13 10:16 ` [Qemu-devel] [QEMU 1/7] balloon: speed up inflating & deflating process Liang Li
2016-06-14 11:37 ` Thomas Huth
2016-06-14 14:22 ` Li, Liang Z
2016-06-14 14:41 ` Li, Liang Z
2016-06-14 15:33 ` Thomas Huth
2016-06-17 0:54 ` Li, Liang Z
2016-06-19 4:12 ` Michael S. Tsirkin
2016-06-20 1:37 ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 2/7] virtio-balloon: add drop cache support Liang Li
2016-06-19 4:14 ` Michael S. Tsirkin
2016-06-20 2:09 ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 3/7] Add the hmp and qmp interface for dropping cache Liang Li
2016-06-13 10:50 ` Daniel P. Berrange
2016-06-13 11:06 ` Daniel P. Berrange
2016-06-13 14:12 ` Li, Liang Z
2016-06-13 11:41 ` Paolo Bonzini
2016-06-13 14:14 ` Li, Liang Z
2016-06-13 13:50 ` Li, Liang Z
2016-06-13 15:09 ` Dr. David Alan Gilbert
2016-06-14 1:15 ` Li, Liang Z
2016-06-17 1:35 ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 4/7] balloon: get free page info from guest Liang Li
2016-06-19 4:24 ` Michael S. Tsirkin
2016-06-20 2:48 ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 5/7] bitmap: Add a new bitmap_move function Liang Li
2016-06-13 10:16 ` [Qemu-devel] [QEMU 6/7] kvm: Add two new arch specific functions Liang Li
2016-06-19 4:27 ` Michael S. Tsirkin [this message]
2016-06-20 3:16 ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 7/7] migration: skip free pages during live migration Liang Li
2016-06-19 4:43 ` Michael S. Tsirkin
2016-06-20 2:52 ` Li, Liang Z
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=20160619072648-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=amit.shah@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lcapitulino@redhat.com \
--cc=liang.z.li@intel.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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).