From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: cornelia.huck@de.ibm.com, borntraeger@de.ibm.com,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH v2 1/2] AioContext: avoid leaking deleted BHs on cleanup
Date: Tue, 28 Jul 2015 13:12:55 +0100 [thread overview]
Message-ID: <1438085576-12072-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1438085576-12072-1-git-send-email-stefanha@redhat.com>
BHs are freed during aio_bh_poll(). This leads to memory leaks if there
is no aio_bh_poll() between qemu_bh_delete() and aio_ctx_finalize().
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
async.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/async.c b/async.c
index 9a98a74..929d533 100644
--- a/async.c
+++ b/async.c
@@ -234,7 +234,20 @@ aio_ctx_finalize(GSource *source)
aio_set_event_notifier(ctx, &ctx->notifier, NULL);
event_notifier_cleanup(&ctx->notifier);
rfifolock_destroy(&ctx->lock);
+
+ qemu_mutex_lock(&ctx->bh_lock);
+ while (ctx->first_bh) {
+ QEMUBH *next = ctx->first_bh->next;
+
+ /* TODO ignore leaks for now, change to an assertion in the future */
+ if (ctx->first_bh->deleted) {
+ g_free(ctx->first_bh);
+ }
+ ctx->first_bh = next;
+ }
+ qemu_mutex_unlock(&ctx->bh_lock);
qemu_mutex_destroy(&ctx->bh_lock);
+
timerlistgroup_deinit(&ctx->tlg);
}
--
2.4.3
next prev parent reply other threads:[~2015-07-28 12:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 12:12 [Qemu-devel] [PATCH v2 0/2] AioContext: fix deadlock after aio_context_acquire() race Stefan Hajnoczi
2015-07-28 12:12 ` Stefan Hajnoczi [this message]
2015-07-28 12:12 ` [Qemu-devel] [PATCH v2 2/2] AioContext: force event loop iteration using BH Stefan Hajnoczi
2015-07-28 14:08 ` [Qemu-devel] [PATCH v2 0/2] AioContext: fix deadlock after aio_context_acquire() race Stefan Hajnoczi
2015-07-28 16:17 ` Paolo Bonzini
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=1438085576-12072-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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 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).