All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Christian Borntraeger <borntraeger@linux.ibm.com>,
	KVM <kvm@vger.kernel.org>
Cc: Janosch Frank <frankja@linux.ibm.com>,
	linux-s390 <linux-s390@vger.kernel.org>,
	Thomas Huth <thuth@redhat.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>
Subject: Re: [PATCH/RFC] KVM: s390: vsie/gmap: reduce gmap_rmap overhead
Date: Fri, 29 Apr 2022 18:02:48 +0200	[thread overview]
Message-ID: <54927e4b-3be7-f186-747c-f14097aa2df9@redhat.com> (raw)
In-Reply-To: <20220429151526.1560-1-borntraeger@linux.ibm.com>

On 29.04.22 17:15, Christian Borntraeger wrote:
> there are cases that trigger a 2nd shadow event for the same
> vmaddr/raddr combination. (prefix changes, reboots, some known races)
> This will increase memory usages and it will result in long latencies
> when cleaning up, e.g. on shutdown. To avoid cases with a list that has
> hundreds of identical raddrs we check existing entries at insert time.
> As this measurably reduces the list length this will be faster than
> traversing the list at shutdown time.
> 
> In the long run several places will be optimized to create less entries
> and a shrinker might be necessary.
> 
> Fixes: 4be130a08420 ("s390/mm: add shadow gmap support")
> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> ---
>  arch/s390/mm/gmap.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
> index 69c08d966fda..0fc0c26a71f2 100644
> --- a/arch/s390/mm/gmap.c
> +++ b/arch/s390/mm/gmap.c
> @@ -1185,12 +1185,19 @@ static inline void gmap_insert_rmap(struct gmap *sg, unsigned long vmaddr,
>  				    struct gmap_rmap *rmap)
>  {
>  	void __rcu **slot;
> +	struct gmap_rmap *temp;
>  
>  	BUG_ON(!gmap_is_shadow(sg));
>  	slot = radix_tree_lookup_slot(&sg->host_to_rmap, vmaddr >> PAGE_SHIFT);
>  	if (slot) {
>  		rmap->next = radix_tree_deref_slot_protected(slot,
>  							&sg->guest_table_lock);
> +		for (temp = rmap->next; temp; temp = temp->next) {
> +			if (temp->raddr == rmap->raddr) {
> +				kfree(rmap);
> +				return;
> +			}
> +		}
>  		radix_tree_replace_slot(&sg->host_to_rmap, slot, rmap);
>  	} else {
>  		rmap->next = NULL;

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


      reply	other threads:[~2022-04-29 16:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29 15:15 [PATCH/RFC] KVM: s390: vsie/gmap: reduce gmap_rmap overhead Christian Borntraeger
2022-04-29 16:02 ` David Hildenbrand [this message]

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=54927e4b-3be7-f186-747c-f14097aa2df9@redhat.com \
    --to=david@redhat.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=thuth@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 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.