qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH qemu] hmp: Print if memory section is registered in KVM
Date: Thu, 8 Nov 2018 10:44:02 -0200	[thread overview]
Message-ID: <03fc996a-7f14-4751-88c2-458c0caa86f0@gmail.com> (raw)
In-Reply-To: <20181108010258.27010-1-aik@ozlabs.ru>



On 11/7/18 11:02 PM, Alexey Kardashevskiy wrote:
> This adds a "KVM" marker to the "into mtree -f" to tell the user if
> a particular memory section is registered as a KVM memory slot; useful
> for debugging purposes.
>
> Since it is memory sections which get registered in KVM (rather than
> memory regions), this only prints "KVM" for flatviews.
>
> For example:
>   Root memory region: system
>    0000000000000000-00000003ffffffff (prio 0, ram): ppc_spapr.ram KVM
>    0000200000000020-000020000000003f (prio 1, i/o): virtio-pci
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---


Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>


>   include/sysemu/kvm.h |  1 +
>   accel/kvm/kvm-all.c  |  7 +++++++
>   memory.c             | 10 ++++++++++
>   3 files changed, 18 insertions(+)
>
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 97d8d9d0d5..9eab5ac1b1 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -471,6 +471,7 @@ void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len);
>   #if !defined(CONFIG_USER_ONLY)
>   int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr,
>                                          hwaddr *phys_addr);
> +bool is_kvm_memory(hwaddr start_addr, hwaddr size);
>   #endif
>   
>   #endif /* NEED_CPU_H */
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index 4880a05399..d72808aaa6 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -216,6 +216,13 @@ static KVMSlot *kvm_lookup_matching_slot(KVMMemoryListener *kml,
>       return NULL;
>   }
>   
> +bool is_kvm_memory(hwaddr start_addr, hwaddr size)
> +{
> +    KVMMemoryListener *kml = &kvm_state->memory_listener;
> +
> +    return NULL != kvm_lookup_matching_slot(kml, start_addr, size);
> +}
> +
>   /*
>    * Calculate and align the start address and the size of the section.
>    * Return the size. If the size is 0, the aligned section is empty.
> diff --git a/memory.c b/memory.c
> index 51204aa079..56c733c687 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -2916,6 +2916,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
>       int n = view->nr;
>       int i;
>       AddressSpace *as;
> +    bool print_kvm = false;
>   
>       p(f, "FlatView #%d\n", fvi->counter);
>       ++fvi->counter;
> @@ -2927,6 +2928,9 @@ static void mtree_print_flatview(gpointer key, gpointer value,
>               p(f, ", alias %s", memory_region_name(as->root->alias));
>           }
>           p(f, "\n");
> +        if (as == &address_space_memory) {
> +            print_kvm = true;
> +        }
>       }
>   
>       p(f, " Root memory region: %s\n",
> @@ -2960,6 +2964,12 @@ static void mtree_print_flatview(gpointer key, gpointer value,
>           if (fvi->owner) {
>               mtree_print_mr_owner(p, f, mr);
>           }
> +
> +        if (kvm_enabled() && print_kvm &&
> +            is_kvm_memory(int128_get64(range->addr.start),
> +                          MR_SIZE(range->addr.size) + 1)) {
> +            p(f, " KVM");
> +        }
>           p(f, "\n");
>           range++;
>       }

  reply	other threads:[~2018-11-08 12:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-08  1:02 [Qemu-devel] [PATCH qemu] hmp: Print if memory section is registered in KVM Alexey Kardashevskiy
2018-11-08 12:44 ` Daniel Henrique Barboza [this message]
2018-11-13 14:51 ` Dr. David Alan Gilbert
2018-11-13 15:56   ` Paolo Bonzini
2018-12-11  2:36     ` Alexey Kardashevskiy

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=03fc996a-7f14-4751-88c2-458c0caa86f0@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=aik@ozlabs.ru \
    --cc=qemu-devel@nongnu.org \
    /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).