All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@amd.com>,
	 Anthony PERARD <anthony.perard@vates.tech>,
	 qemu-devel@nongnu.org, sstabellini@kernel.org,  paul@xen.org,
	 xen-devel@lists.xenproject.org
Subject: Re: [PATCH v1 2/2] xen: mapcache: Fix unmapping of first entries in buckets
Date: Sun, 07 Jul 2024 09:45:57 +0100	[thread overview]
Message-ID: <87jzhxd1yy.fsf@draig.linaro.org> (raw)
In-Reply-To: <CAJy5ezrfbAzwPWg_YABLy5NwCUiNa31FFR1nAZzy-WC3vXrMhg@mail.gmail.com> (Edgar E. Iglesias's message of "Sat, 6 Jul 2024 09:27:43 +0300")

"Edgar E. Iglesias" <edgar.iglesias@gmail.com> writes:

> On Thu, Jul 4, 2024 at 9:48 PM Edgar E. Iglesias <edgar.iglesias@amd.com> wrote:
>
>  On Thu, Jul 04, 2024 at 05:44:52PM +0100, Alex Bennée wrote:
>  > Anthony PERARD <anthony.perard@vates.tech> writes:
>  > 
>  > > On Tue, Jul 02, 2024 at 12:44:21AM +0200, Edgar E. Iglesias wrote:
>  > >> From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
>  > >> 
>  > >> This fixes the clobbering of the entry->next pointer when
>  > >> unmapping the first entry in a bucket of a mapcache.
>  > >> 
>  > >> Fixes: 123acd816d ("xen: mapcache: Unmap first entries in buckets")
>  > >> Reported-by: Anthony PERARD <anthony.perard@vates.tech>
>  > >> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
>  > >> ---
>  > >>  hw/xen/xen-mapcache.c | 12 +++++++++++-
>  > >>  1 file changed, 11 insertions(+), 1 deletion(-)
>  > >> 
>  > >> diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c
>  > >> index 5f23b0adbe..18ba7b1d8f 100644
>  > >> --- a/hw/xen/xen-mapcache.c
>  > >> +++ b/hw/xen/xen-mapcache.c
>  > >> @@ -597,7 +597,17 @@ static void xen_invalidate_map_cache_entry_unlocked(MapCache *mc,
>  > >>          pentry->next = entry->next;
>  > >>          g_free(entry);
>  > >>      } else {
>  > >> -        memset(entry, 0, sizeof *entry);
>  > >> +        /*
>  > >> +         * Invalidate mapping but keep entry->next pointing to the rest
>  > >> +         * of the list.
>  > >> +         *
>  > >> +         * Note that lock is already zero here, otherwise we don't unmap.
>  > >> +         */
>  > >> +        entry->paddr_index = 0;
>  > >> +        entry->vaddr_base = NULL;
>  > >> +        entry->valid_mapping = NULL;
>  > >> +        entry->flags = 0;
>  > >> +        entry->size = 0;
>  > >
>  > > This kind of feels like mc->entry should be an array of pointer rather
>  > > than an array of MapCacheEntry but that seems to work well enough and
>  > > not the first time entries are been cleared like that.
>  > 
>  > The use of a hand rolled list is a bit of a concern considering QEMU and
>  > Glib both provide various abstractions used around the rest of the code
>  > base. The original patch that introduces the mapcache doesn't tell me
>  > much about access patterns for the cache, just that it is trying to
>  > solve memory exhaustion issues with lots of dynamic small mappings.
>  > 
>  > Maybe a simpler structure is desirable?
>  > 
>  > We also have an interval tree implementation ("qemu/interval-tree.h") if
>  > what we really want is a sorted tree of memory that can be iterated
>  > locklessly.
>  > 
>
>  Yes, it would be interesting to benchmark other options.
>  I agree that we should at minimum reuse existing lists/hash tables.
>
>  We've also had some discussions around removing it partially or alltogether but
>  there are some concerns around that. We're going to need something to
>  keep track of grants. For 32-bit hosts, it's a problem to exhaust virtual
>  address-space if mapping all of the guest (are folks still using 32-bit hosts?).
>  There may be other issues aswell.
>
>  Some benefits are that we'll remove some of the complexity and latency for mapping
>  and unmapping stuff continously.
>
> One more thing I forgot to add is that IMO, these larger longer term
> changes should not block this tiny bugfix...

Agreed.

>
> Cheers,
> Edgar 

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2024-07-07  8:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 22:44 [PATCH v1 0/2] xen: mapcache: Fix unmapping of first the entry in a bucket Edgar E. Iglesias
2024-07-01 22:44 ` [PATCH v1 1/2] physmem: Bail out qemu_ram_block_from_host() for invalid ram addrs Edgar E. Iglesias
2024-07-04 10:26   ` Alex Bennée
2024-07-04 11:42     ` Edgar E. Iglesias
2024-07-04 12:33       ` Alex Bennée
2024-07-08 23:14   ` Stefano Stabellini
2024-07-01 22:44 ` [PATCH v1 2/2] xen: mapcache: Fix unmapping of first entries in buckets Edgar E. Iglesias
2024-07-04 14:23   ` Anthony PERARD
2024-07-04 16:44     ` Alex Bennée
2024-07-04 18:48       ` Edgar E. Iglesias via
2024-07-04 18:48         ` Edgar E. Iglesias
2024-07-06  6:27         ` Edgar E. Iglesias
2024-07-07  8:45           ` Alex Bennée [this message]
2024-07-08 23:16   ` Stefano Stabellini

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=87jzhxd1yy.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=anthony.perard@vates.tech \
    --cc=edgar.iglesias@amd.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=paul@xen.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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 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.