qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: qemu-devel@nongnu.org, Juraj Marcin <jmarcin@redhat.com>,
	Prasad Pandit <ppandit@redhat.com>,
	Julia Suvorova <jusual@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Fabiano Rosas <farosas@suse.de>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Zhiyi Guo <zhguo@redhat.com>
Subject: Re: [PATCH 3/4] KVM: Dynamic sized kvm memslots array
Date: Wed, 4 Sep 2024 16:55:13 -0400	[thread overview]
Message-ID: <ZtjJMXoHvi0VHEhn@x1n> (raw)
In-Reply-To: <4ed8cec2-413a-4254-8804-55befbcd0d00@redhat.com>

On Wed, Sep 04, 2024 at 10:43:23PM +0200, David Hildenbrand wrote:
> On 04.09.24 21:16, Peter Xu wrote:
> > Zhiyi reported an infinite loop issue in VFIO use case.  The cause of that
> > was a separate discussion, however during that I found a regression of
> > dirty sync slowness when profiling.
> > 
> > Each KVMMemoryListerner maintains an array of kvm memslots.  Currently it's
> > statically allocated to be the max supported by the kernel.  However after
> > Linux commit 4fc096a99e ("KVM: Raise the maximum number of user memslots"),
> > the max supported memslots reported now grows to some number large enough
> > so that it may not be wise to always statically allocate with the max
> > reported.
> > 
> > What's worse, QEMU kvm code still walks all the allocated memslots entries
> > to do any form of lookups.  It can drastically slow down all memslot
> > operations because each of such loop can run over 32K times on the new
> > kernels.
> > 
> > Fix this issue by making the memslots to be allocated dynamically.
> 
> Wouldn't it be sufficient to limit the walk to the actually used slots?
> 
> I know, the large allocation might sound scary at first, but memory
> overcommit+populate-on-demand should handle that, assuming nobody touches
> the yet-unused slots.

I thought we can have holes within the array?

I meant e.g. when 10 slots populated, but then one of them got removed,
then nr_slots_used would be 9 even if slots[9] is still in use?

Thanks,

-- 
Peter Xu



  parent reply	other threads:[~2024-09-04 20:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 19:16 [PATCH 0/4] KVM: Dynamic sized memslots array Peter Xu
2024-09-04 19:16 ` [PATCH 1/4] KVM: Rename KVMState->nr_slots to nr_slots_max Peter Xu
2024-09-04 20:36   ` David Hildenbrand
2024-09-04 19:16 ` [PATCH 2/4] KVM: Define KVM_MEMSLOTS_NUM_MAX_DEFAULT Peter Xu
2024-09-04 20:39   ` David Hildenbrand
2024-09-04 20:56     ` Peter Xu
2024-09-04 19:16 ` [PATCH 3/4] KVM: Dynamic sized kvm memslots array Peter Xu
2024-09-04 20:43   ` David Hildenbrand
2024-09-04 20:51     ` David Hildenbrand
2024-09-04 20:55     ` Peter Xu [this message]
2024-09-04 21:07   ` David Hildenbrand
2024-09-04 21:20     ` Peter Xu
2024-09-04 21:23       ` David Hildenbrand
2024-09-04 21:34         ` Peter Xu
2024-09-04 21:38           ` David Hildenbrand
2024-09-04 21:46             ` Peter Xu
2024-09-04 21:58               ` Peter Xu
2024-09-04 19:16 ` [PATCH 4/4] KVM: Rename KVMMemoryListener.nr_used_slots to nr_slots_used Peter Xu
2024-09-04 20:40   ` David Hildenbrand

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=ZtjJMXoHvi0VHEhn@x1n \
    --to=peterx@redhat.com \
    --cc=david@redhat.com \
    --cc=farosas@suse.de \
    --cc=jmarcin@redhat.com \
    --cc=jusual@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vkuznets@redhat.com \
    --cc=zhguo@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).