* [PATCH] migration/ram: Fix memory leak when using x-ignore-shared
@ 2022-09-16 8:44 Nikolay Borisov
2022-09-22 17:42 ` Dr. David Alan Gilbert
0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2022-09-16 8:44 UTC (permalink / raw)
To: Juan Quintela, Dr. David Alan Gilbert, qemu-devel; +Cc: Nikolay Borisov
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.
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] migration/ram: Fix memory leak when using x-ignore-shared
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
2022-09-23 9:18 ` Nikolay Borisov
0 siblings, 1 reply; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2022-09-22 17:42 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: Juan Quintela, qemu-devel
* 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] migration/ram: Fix memory leak when using x-ignore-shared
2022-09-22 17:42 ` Dr. David Alan Gilbert
@ 2022-09-23 9:18 ` Nikolay Borisov
0 siblings, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2022-09-23 9:18 UTC (permalink / raw)
To: Dr. David Alan Gilbert; +Cc: Juan Quintela, qemu-devel
On 22.09.22 г. 20:42 ч., Dr. David Alan Gilbert wrote:
> * 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.
Huhz, you are perfectly right and I assume I got confused by the
RAMBLOCK_FOREACH_MIGRATABLE in ram_save_setup as opposed to the code in
ram_list_init_bitmaps. Apologies for the noise...
>
> 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
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-23 9:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2022-09-23 9:18 ` Nikolay Borisov
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).