From: Anthony PERARD <anthony.perard@citrix.com>
To: Olaf Hering <olaf@aepfle.de>
Cc: qemu-devel@nongnu.org,
Stefano Stabellini <sstabellini@kernel.org>,
Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
"open list:X86" <xen-devel@lists.xenproject.org>,
"open list:Block layer core" <qemu-block@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v1] xen_disk: fix memory leak
Date: Thu, 13 Dec 2018 11:33:33 +0000 [thread overview]
Message-ID: <20181213113333.GZ18875@perard.uk.xensource.com> (raw)
In-Reply-To: <20181211160224.22181-1-olaf@aepfle.de>
On Tue, Dec 11, 2018 at 05:02:24PM +0100, Olaf Hering wrote:
> There are some code paths that clobber ioreq->buf, which leads to a huge
> memory leak after a few hours of runtime. One code path is
> qemu_aio_complete, which might be called recursive. Another one is
I think it's s/recursive/recursively/.
> ioreq_reset, which might clobber ioreq->buf as well.
>
> Add wrappers to free ioreq->buf before reassignment.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
That patch seems fine, with a few coding style issues, and is going to
be needed to be forward ported to Paul's reimplementation (not yet
merged).
> ---
> hw/block/xen_disk.c | 22 +++++++++++++++++-----
> 1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index 36eff94f84..e15eefe625 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -103,12 +103,24 @@ struct XenBlkDev {
>
> /* ------------------------------------------------------------- */
>
> +static void ioreq_buf_alloc(struct ioreq *ioreq, size_t alignment)
You have the parameter `alignment` but don't actually use it, I don't
think it's needed.
> +{
> + if (ioreq->buf)
> + qemu_vfree(ioreq->buf);
You could call ioreq_buf_free here instead of duplicating the code.
> + ioreq->buf = qemu_memalign(XC_PAGE_SIZE, ioreq->size);
> +}
> +static void ioreq_buf_free(struct ioreq *ioreq)
> +{
> + if (ioreq->buf)
> + qemu_vfree(ioreq->buf);
> + ioreq->buf = NULL;
> +}
Thanks,
--
Anthony PERARD
next prev parent reply other threads:[~2018-12-13 11:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-11 16:02 [Qemu-devel] [PATCH v1] xen_disk: fix memory leak Olaf Hering
2018-12-11 17:14 ` no-reply
2018-12-13 11:33 ` Anthony PERARD [this message]
2018-12-13 12:05 ` [Qemu-devel] [Xen-devel] " Paul Durrant
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=20181213113333.GZ18875@perard.uk.xensource.com \
--to=anthony.perard@citrix.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=olaf@aepfle.de \
--cc=qemu-block@nongnu.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 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).