From: David Hildenbrand <david@redhat.com>
To: Nico Boehr <nrb@linux.ibm.com>,
borntraeger@linux.ibm.com, frankja@linux.ibm.com,
imbrenda@linux.ibm.com
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH v2 1/2] KVM: s390: add stat counter for shadow gmap events
Date: Thu, 27 Jul 2023 09:37:21 +0200 [thread overview]
Message-ID: <e0b2195a-6f60-6a49-cf3f-4a528eb2df43@redhat.com> (raw)
In-Reply-To: <20230510121822.546629-2-nrb@linux.ibm.com>
On 10.05.23 14:18, Nico Boehr wrote:
> The shadow gmap tracks memory of nested guests (guest-3). In certain
> scenarios, the shadow gmap needs to be rebuilt, which is a costly operation
> since it involves a SIE exit into guest-1 for every entry in the respective
> shadow level.
>
> Add kvm stat counters when new shadow structures are created at various
> levels. Also add a counter gmap_shadow_acquire when a completely fresh
> shadow gmap is created.
>
> Note that when several levels are shadowed at once, counters on all
> affected levels will be increased.
>
> Also note that not all page table levels need to be present and a ASCE
> can directly point to e.g. a segment table. In this case, a new segment
> table will always be equivalent to a new shadow gmap and hence will be
> counted as gmap_shadow_acquire and not as gmap_shadow_segment.
>
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> ---
> arch/s390/include/asm/kvm_host.h | 6 ++++++
> arch/s390/kvm/gaccess.c | 7 +++++++
> arch/s390/kvm/kvm-s390.c | 8 +++++++-
> arch/s390/kvm/vsie.c | 1 +
> 4 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
> index 2bbc3d54959d..d35e03e82d3d 100644
> --- a/arch/s390/include/asm/kvm_host.h
> +++ b/arch/s390/include/asm/kvm_host.h
> @@ -777,6 +777,12 @@ struct kvm_vm_stat {
> u64 inject_service_signal;
> u64 inject_virtio;
> u64 aen_forward;
> + u64 gmap_shadow_acquire;
> + u64 gmap_shadow_r1_te;
> + u64 gmap_shadow_r2_te;
> + u64 gmap_shadow_r3_te;
> + u64 gmap_shadow_sg_te;
> + u64 gmap_shadow_pg_te;
Is "te" supposed to stand for "table entry" ?
If so, I'd suggest to just call this gmap_shadow_pg_entry etc.
> };
>
> struct kvm_arch_memory_slot {
> diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
> index 3eb85f254881..6f4292ad0e4a 100644
> --- a/arch/s390/kvm/gaccess.c
> +++ b/arch/s390/kvm/gaccess.c
> @@ -1382,6 +1382,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
> unsigned long *pgt, int *dat_protection,
> int *fake)
> {
> + struct kvm *kvm;
> struct gmap *parent;
> union asce asce;
> union vaddress vaddr;
> @@ -1390,6 +1391,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
>
> *fake = 0;
> *dat_protection = 0;
> + kvm = sg->private;
> parent = sg->parent;
> vaddr.addr = saddr;
> asce.val = sg->orig_asce;
> @@ -1450,6 +1452,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
> rc = gmap_shadow_r2t(sg, saddr, rfte.val, *fake);
> if (rc)
> return rc;
> + kvm->stat.gmap_shadow_r1_te++;
> }
> fallthrough;
> case ASCE_TYPE_REGION2: {
> @@ -1478,6 +1481,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
> rc = gmap_shadow_r3t(sg, saddr, rste.val, *fake);
> if (rc)
> return rc;
> + kvm->stat.gmap_shadow_r2_te++;
> }
> fallthrough;
> case ASCE_TYPE_REGION3: {
> @@ -1515,6 +1519,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
> rc = gmap_shadow_sgt(sg, saddr, rtte.val, *fake);
> if (rc)
> return rc;
> + kvm->stat.gmap_shadow_r3_te++;
> }
> fallthrough;
> case ASCE_TYPE_SEGMENT: {
> @@ -1548,6 +1553,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
> rc = gmap_shadow_pgt(sg, saddr, ste.val, *fake);
> if (rc)
> return rc;
> + kvm->stat.gmap_shadow_sg_te++;
> }
> }
> /* Return the parent address of the page table */
> @@ -1618,6 +1624,7 @@ int kvm_s390_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg,
> pte.p |= dat_protection;
> if (!rc)
> rc = gmap_shadow_page(sg, saddr, __pte(pte.val));
> + vcpu->kvm->stat.gmap_shadow_pg_te++;
> ipte_unlock(vcpu->kvm);
> mmap_read_unlock(sg->mm);
> return rc;
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 17b81659cdb2..ded4149e145b 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -66,7 +66,13 @@ const struct _kvm_stats_desc kvm_vm_stats_desc[] = {
> STATS_DESC_COUNTER(VM, inject_pfault_done),
> STATS_DESC_COUNTER(VM, inject_service_signal),
> STATS_DESC_COUNTER(VM, inject_virtio),
> - STATS_DESC_COUNTER(VM, aen_forward)
> + STATS_DESC_COUNTER(VM, aen_forward),
> + STATS_DESC_COUNTER(VM, gmap_shadow_acquire),
> + STATS_DESC_COUNTER(VM, gmap_shadow_r1_te),
> + STATS_DESC_COUNTER(VM, gmap_shadow_r2_te),
> + STATS_DESC_COUNTER(VM, gmap_shadow_r3_te),
> + STATS_DESC_COUNTER(VM, gmap_shadow_sg_te),
> + STATS_DESC_COUNTER(VM, gmap_shadow_pg_te),
> };
>
> const struct kvm_stats_header kvm_vm_stats_header = {
> diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
> index 8d6b765abf29..beb3be037722 100644
> --- a/arch/s390/kvm/vsie.c
> +++ b/arch/s390/kvm/vsie.c
> @@ -1221,6 +1221,7 @@ static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
> if (IS_ERR(gmap))
> return PTR_ERR(gmap);
> gmap->private = vcpu->kvm;
> + vcpu->kvm->stat.gmap_shadow_acquire++;
Do you rather want to have events for
gmap_shadow_reuse (if gmap_shadow_valid() succeeded in that function)
gmap_shadow_create (if we have to create a new one via gmap_shadow)
?
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2023-07-27 7:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 12:18 [PATCH v2 0/2] KVM: s390: add counters for vsie performance Nico Boehr
2023-05-10 12:18 ` [PATCH v2 1/2] KVM: s390: add stat counter for shadow gmap events Nico Boehr
2023-07-27 7:37 ` David Hildenbrand [this message]
2023-08-01 11:48 ` Nico Boehr
2023-08-01 13:34 ` Janosch Frank
2023-05-10 12:18 ` [PATCH v2 2/2] KVM: s390: add tracepoint in gmap notifier Nico Boehr
2023-07-27 7:41 ` David Hildenbrand
2023-08-04 9:46 ` Nico Boehr
2023-08-04 9:59 ` David Hildenbrand
2023-07-27 7:24 ` [PATCH v2 0/2] KVM: s390: add counters for vsie performance Nico Boehr
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=e0b2195a-6f60-6a49-cf3f-4a528eb2df43@redhat.com \
--to=david@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nrb@linux.ibm.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