qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: Juan Quintela <quintela@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] migration/ram: Fix memory leak when using x-ignore-shared
Date: Thu, 22 Sep 2022 18:42:54 +0100	[thread overview]
Message-ID: <Yyyenk4Qu6nWMsJD@work-vm> (raw)
In-Reply-To: <20220916084442.1349996-1-nborisov@suse.com>

* Nikolay Borisov (nborisov@suse.com) wrote:
> During ram initialization for migration dirty/clear bitmaps are
> allocated for all migratable blocks, irrespective of their shared
> status. However, during ram migration cleanup those bitmaps are freed
> only for those blocks which aren't shared, in case x-ignore-shared
> capability is used. This leads to a situation where the bitmaps aren't
> freed for such blocks.

Can you show me where you're seeing the allocation based on MIGRATABLE?
I'm looking at ram_list_init_bitmaps:


        RAMBLOCK_FOREACH_NOT_IGNORED(block) {
            block->bmap = bitmap_new(pages);
....
            block->clear_bmap = bitmap_new(clear_bmap_size(pages, shift));


So that's based on NOT_IGNORED.

Dave

> Fix this by switching the cleanup code to also free bitmaps for all
> migratable blocks.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  migration/ram.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index dc1de9ddbc68..2e40166d2f9e 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -2678,7 +2678,7 @@ static void ram_save_cleanup(void *opaque)
>          }
>      }
>  
> -    RAMBLOCK_FOREACH_NOT_IGNORED(block) {
> +    RAMBLOCK_FOREACH_MIGRATABLE(block) {
>          g_free(block->clear_bmap);
>          block->clear_bmap = NULL;
>          g_free(block->bmap);
> -- 
> 2.34.1
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2022-09-22 17:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16  8:44 [PATCH] migration/ram: Fix memory leak when using x-ignore-shared Nikolay Borisov
2022-09-22 17:42 ` Dr. David Alan Gilbert [this message]
2022-09-23  9:18   ` Nikolay Borisov

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=Yyyenk4Qu6nWMsJD@work-vm \
    --to=dgilbert@redhat.com \
    --cc=nborisov@suse.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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).