From 805420810cdd500055ed1dba0f5a1d7c1f6e42e7 Mon Sep 17 00:00:00 2001 From: Dor Laor <dlaor@redhat.com> Date: Sun, 24 May 2009 12:13:53 +0300 Subject: [PATCH 10/14] Call missing qemu_bh_delete at the end of raw_aio_em_cb callback. Fixes - *Bug 501694* <https://bugzilla.redhat.com/show_bug.cgi?id=501694> - KVM: VMs indicate 100% cpu load after two days of running. Upstream does not have this because Christoph's verctored aio work. >From b0a0bac29134ffb3199312eb5d09efa13fb031aa Mon Sep 17 00:00:00 2001 From: Dor Laor <dor@redhat.com> Date: Sun, 24 May 2009 00:22:17 +0300 Subject: [PATCH] Call missing qemu_bh_delete at the end of raw_aio_em_cb callback. Without it, these cb's does not get cleaned and it slows down qemu more and more. (to test, the # of bh->next chain is huge when using cache=off). Thanks Avi for helping with the debug. Signed-off-by: Dor Laor <dor@redhat.com> Message-ID: <4A190FD1.8070805@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> RH-Upstream-status: pending Acked-by: Kevin Wolf <kwolf@redhat.com> Acked-by: Gleb Natapov <gleb@redhat.com> Acked-by: Juan Quintela <quintela@redhat.com> Acked-by: Andrea Arcangeli <aarcange@redhat.com> Bugzilla: 503793 --- qemu/block-raw-posix.c | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diff --git a/qemu/block-raw-posix.c b/qemu/block-raw-posix.c index 6a2b517..85c57b8 100644 --- a/qemu/block-raw-posix.c +++ b/qemu/block-raw-posix.c @@ -440,6 +440,7 @@ typedef struct RawAIOCB { BlockDriverAIOCB common; struct qemu_paiocb aiocb; struct RawAIOCB *next; + QEMUBH *bh; int ret; } RawAIOCB; @@ -594,6 +595,8 @@ static void raw_aio_em_cb(void* opaque) { RawAIOCB *acb = opaque; acb->common.cb(acb->common.opaque, acb->ret); + qemu_bh_delete(acb->bh); + acb->bh = NULL; qemu_aio_release(acb); } @@ -610,11 +613,12 @@ static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs, BDRVRawState *s = bs->opaque; if (unlikely(s->aligned_buf != NULL && ((uintptr_t) buf % 512))) { - QEMUBH *bh; acb = qemu_aio_get(bs, cb, opaque); acb->ret = raw_pread(bs, 512 * sector_num, buf, 512 * nb_sectors); - bh = qemu_bh_new(raw_aio_em_cb, acb); - qemu_bh_schedule(bh); + acb->bh = qemu_bh_new(raw_aio_em_cb, acb); + if (!acb->bh) + return NULL; + qemu_bh_schedule(acb->bh); return &acb->common; } @@ -641,11 +645,12 @@ static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs, BDRVRawState *s = bs->opaque; if (unlikely(s->aligned_buf != NULL && ((uintptr_t) buf % 512))) { - QEMUBH *bh; acb = qemu_aio_get(bs, cb, opaque); acb->ret = raw_pwrite(bs, 512 * sector_num, buf, 512 * nb_sectors); - bh = qemu_bh_new(raw_aio_em_cb, acb); - qemu_bh_schedule(bh); + acb->bh = qemu_bh_new(raw_aio_em_cb, acb); + if (!acb->bh) + return NULL; + qemu_bh_schedule(acb->bh); return &acb->common; } -- 1.6.3.rc4.29.g8146