Skip to contentSkip to conversation

Possible memory leak in qemu-dm (qemu-dm swapping 20GB+, adding 2gb+ per day)

DISCUSSION Steven Haigh 4 participants 12 messages Mar 25, 2014 – Mar 26, 2014

lore
Share & tools
lore
#0 lore raw

Continuing from:
http://lists.xenproject.org/archives/html/xen-devel/2013-11/msg03961.html

Hi guys,

Continuing on from this thread, has any progress been made on this?

I have had a report from a user of my packages with the same problem:

	http://xen.crc.id.au/bugs/view.php?id=25

He has been able to reproduce this in a reliable manner.

--
Steven Haigh

Email: [email protected]
Web: https://www.crc.id.au
Phone: (03) 9001 6090 - 0412 935 897
Fax: (03) 8338 0299

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 12 lines · Steven Haigh

Continuing from:
http://lists.xenproject.org/archives/html/xen-devel/2013-11/msg03961.html

Hi guys,

Continuing on from this thread, has any progress been made on this?

I have had a report from a user of my packages with the same problem:

	http://xen.crc.id.au/bugs/view.php?id=25

He has been able to reproduce this in a reliable manner.

I thought the fix was committed to all the maintained qemu-traditional branches..

-- Pasi

Quoted 8 lines

--
Steven Haigh

Ehmail: [email protected]
Web: https://www.crc.id.au
Phone: (03) 9001 6090 - 0412 935 897
Fax: (03) 8338 0299

#2 lore raw
Quoted 8 lines · Pasi Kärkkäinen
Quoted 7 lines · Steven Haigh

Continuing from:
http://lists.xenproject.org/archives/html/xen-devel/2013-11/msg03961.html

Hi guys,

Continuing on from this thread, has any progress been made on this?

Quoted 7 lines
Quoted 5 lines

I have had a report from a user of my packages with the same problem:

	http://xen.crc.id.au/bugs/view.php?id=25

He has been able to reproduce this in a reliable manner.

I thought the fix was committed to all the maintained qemu-traditional branches..

I think so too.

But if not then given a reliable repro I think the advice to try it under valgrind (which AIUI can now traces qemus thanks to Andrew Coopers work) still holds as a useful next step.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 15 lines · Ian Campbell
Quoted 14 lines · Pasi Kärkkäinen
Quoted 12 lines · Steven Haigh

Continuing from:
http://lists.xenproject.org/archives/html/xen-devel/2013-11/msg03961.html

Hi guys,

Continuing on from this thread, has any progress been made on this?

I have had a report from a user of my packages with the same problem:

	http://xen.crc.id.au/bugs/view.php?id=25

He has been able to reproduce this in a reliable manner.

Quoted 7 lines
Quoted 1 line

I thought the fix was committed to all the maintained qemu-traditional branches..

I think so too.

But if not then given a reliable repro I think the advice to try it under valgrind (which AIUI can now traces qemus thanks to Andrew Coopers work) still holds as a useful next step.

Is there any guide on how to do this to gather said info? Documentation? Implementation? Interpretation?

--
Steven Haigh

Email: [email protected]
Web: https://www.crc.id.au
Phone: (03) 9001 6090 - 0412 935 897
Fax: (03) 8338 0299

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw
Quoted 18 lines · Steven Haigh
Quoted 17 lines · Ian Campbell
Quoted 15 lines · Pasi Kärkkäinen
Quoted 12 lines · Steven Haigh

Continuing from:
http://lists.xenproject.org/archives/html/xen-devel/2013-11/msg03961.html

Hi guys,

Continuing on from this thread, has any progress been made on this?

I have had a report from a user of my packages with the same problem:

	http://xen.crc.id.au/bugs/view.php?id=25

He has been able to reproduce this in a reliable manner.

I thought the fix was committed to all the maintained qemu-traditional branches..

Quoted 8 lines
Quoted 5 lines

I think so too.

But if not then given a reliable repro I think the advice to try it under valgrind (which AIUI can now traces qemus thanks to Andrew Coopers work) still holds as a useful next step.

Is there any guide on how to do this to gather said info? Documentation? Implementation? Interpretation?

http://blog.xen.org/index.php/2013/01/18/using-valgrind-to-debug-xen-toolstacks/ has some info on running valgrind on the toolstack, I think this should extend to processes launched by the toolstack such as qemu, so it might be as easy as following that.

Otherwise Andrew might have some more concrete advise but I think the approach I would take is to create a wrapper script which does "valgrind /path/to/qemu $@" and then use that via the device_model_override directive in the domain config.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw
Quoted 24 lines · Ian Campbell
Quoted 15 lines · Steven Haigh
Quoted 14 lines · Ian Campbell
Quoted 13 lines · Pasi Kärkkäinen
Quoted 12 lines · Steven Haigh

Continuing from:
http://lists.xenproject.org/archives/html/xen-devel/2013-11/msg03961.html

Hi guys,

Continuing on from this thread, has any progress been made on this?

I have had a report from a user of my packages with the same problem:

	http://xen.crc.id.au/bugs/view.php?id=25

He has been able to reproduce this in a reliable manner.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I thought the fix was committed to all the maintained qemu-traditional branches..

I think so too.

But if not then given a reliable repro I think the advice to try it under valgrind (which AIUI can now traces qemus thanks to Andrew Coopers work) still holds as a useful next step.

Is there any guide on how to do this to gather said info? Documentation? Implementation? Interpretation?

Quoted 10 lines

http://blog.xen.org/index.php/2013/01/18/using-valgrind-to-debug-xen-toolstacks/ has some info on running valgrind on the toolstack, I think this should extend to processes launched by the toolstack such as qemu, so it might be as easy as following that.

Otherwise Andrew might have some more concrete advise but I think the approach I would take is to create a wrapper script which does "valgrind /path/to/qemu $@" and then use that via the device_model_override directive in the domain config.

Ian.

I have never used valgrind in combination with xl and qemu before, but the intercepting it in a Xapi environment is mostly similar.

Something like:

#!/bin/sh
valgrind --log-file="/path/to/logs/qemu-%p-valgrind.log" /path/to/qemu "$@"

should work fine.

You will need the latest valgrind, and the patchset of 7 from [email protected] as they are still pending acceptance upstream.

At some point soon I will need to do some more patches for the new SYSCTL and pending DOMCTL interface bumps new in unstable, but that wont affect you if you are on a released version of Xen.

Finally, I have not yet tried qemu-upstream, so there might still be some missing hypercalls, but qemu-traditional should work fine.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
Quoted 50 lines · Andrew Cooper
Quoted 24 lines · Ian Campbell
Quoted 15 lines · Steven Haigh
Quoted 14 lines · Ian Campbell
Quoted 13 lines · Pasi Kärkkäinen
Quoted 12 lines · Steven Haigh

Continuing from:
http://lists.xenproject.org/archives/html/xen-devel/2013-11/msg03961.html

Hi guys,

Continuing on from this thread, has any progress been made on this?

I have had a report from a user of my packages with the same problem:

	http://xen.crc.id.au/bugs/view.php?id=25

He has been able to reproduce this in a reliable manner.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I thought the fix was committed to all the maintained qemu-traditional branches..

I think so too.

But if not then given a reliable repro I think the advice to try it under valgrind (which AIUI can now traces qemus thanks to Andrew Coopers work) still holds as a useful next step.

Is there any guide on how to do this to gather said info? Documentation? Implementation? Interpretation?

Quoted 10 lines

http://blog.xen.org/index.php/2013/01/18/using-valgrind-to-debug-xen-toolstacks/ has some info on running valgrind on the toolstack, I think this should extend to processes launched by the toolstack such as qemu, so it might be as easy as following that.

Otherwise Andrew might have some more concrete advise but I think the approach I would take is to create a wrapper script which does "valgrind /path/to/qemu $@" and then use that via the device_model_override directive in the domain config.

Ian.

I have never used valgrind in combination with xl and qemu before, but the intercepting it in a Xapi environment is mostly similar.

Something like:

#!/bin/sh
valgrind --log-file="/path/to/logs/qemu-%p-valgrind.log" /path/to/qemu "$@"

should work fine.

You will need the latest valgrind, and the patchset of 7 from [email protected] as they are still pending acceptance upstream.

Quoted 6 lines

At some point soon I will need to do some more patches for the new SYSCTL and pending DOMCTL interface bumps new in unstable, but that wont affect you if you are on a released version of Xen.

Finally, I have not yet tried qemu-upstream, so there might still be some missing hypercalls, but qemu-traditional should work fine.

Hi Andrew / Ian,

Valgrind log available here:
http://xen.crc.id.au/bugs/view.php?id=25

Do you have any further suggestions / ideas based on this?

--
Steven Haigh

Email: [email protected]
Web: https://www.crc.id.au
Phone: (03) 9001 6090 - 0412 935 897
Fax: (03) 8338 0299

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by Ian Jackson
#7 lore raw
Quoted 2 lines · Steven Haigh

Valgrind log available here:
http://xen.crc.id.au/bugs/view.php?id=25

Thanks.

Before we go any further, can you confirm that you have this commit in your qemu-xen-traditional tree:
commit 96b58a44756a8821c108358439b0f2c06e531159
Author: Matthew Daley <[email protected]>
Date: Wed Dec 4 15:16:18 2013 +1300

xen_disk: fix memory leak

On ioreq_release the full ioreq was memset to 0, losing all the data and memory allocations inside the QEMUIOVector, which leads to a memory leak. Create a new function to specifically reset ioreq.

Backport to qemu-xen-traditional.

Quoted 1 line

Do you have any further suggestions / ideas based on this?

Unfortunately the qemu-dm binary seems to have been stripped, which removes much of the useful info from the traces. Please can you make sure you have the following commit to the qemu-xen-traditional tree:
commit 18a08a23da88863435d56a0b14ff72013ef3b003
Author: Olaf Hering <[email protected]>
Date: Tue Oct 15 11:42:26 2013 +0200

qemu-traditional: do not strip binaries during make install

It is wrong to strip code during make install, unless explicit requested. Introduce a new variable INSTALL_PROG and use it along with an optional STRIP_OPT where currently install -s -m 755 is used. This is what upstream qemu offers in version 1.6.

If you are packaging this as RPM I guess you will also want the accompanying debuginfo RPM installed too, since RPM will have done magic with the unstripped binary.

Adding --leak-check=full and/or --track-origins=yes to the valgrind options might also be helpful.

The most plausible candidate for a leak would seem to be "Syscall param munmap(length) contains uninitialised byte(s)", but that might just be down to "Warning: noted but unhandled ioctl 0x84501 with no size/direction hints" on the corresponding mmap call. Hopefully with debugging symbols things will become clearer.

Thanks,

Ian.

#8 lore raw
Quoted 36 lines · Ian Campbell
Quoted 2 lines · Steven Haigh

Valgrind log available here:
http://xen.crc.id.au/bugs/view.php?id=25

Thanks.

Before we go any further, can you confirm that you have this commit in your qemu-xen-traditional tree:
commit 96b58a44756a8821c108358439b0f2c06e531159
Author: Matthew Daley <[email protected]>
Date: Wed Dec 4 15:16:18 2013 +1300

xen_disk: fix memory leak

On ioreq_release the full ioreq was memset to 0, losing all the data and memory allocations inside the QEMUIOVector, which leads to a memory leak. Create a new function to specifically reset ioreq.

Backport to qemu-xen-traditional.

Quoted 1 line

Do you have any further suggestions / ideas based on this?

Unfortunately the qemu-dm binary seems to have been stripped, which removes much of the useful info from the traces. Please can you make sure you have the following commit to the qemu-xen-traditional tree:
commit 18a08a23da88863435d56a0b14ff72013ef3b003
Author: Olaf Hering <[email protected]>
Date: Tue Oct 15 11:42:26 2013 +0200

Quoted 9 lines

qemu-traditional: do not strip binaries during make install

It is wrong to strip code during make install, unless explicit requested. Introduce a new variable INSTALL_PROG and use it along with an optional STRIP_OPT where currently install -s -m 755 is used. This is what upstream qemu offers in version 1.6.

I am using the qemu-xen-traditional that comes with xen-4.2.3.tar.gz

There are no patches on top of this apart from:

$ cat qemu-xen.tradonly.patch
--- xen-4.2.0/tools/Makefile.orig       2012-05-27 20:29:17.372660785 +0100
+++ xen-4.2.0/tools/Makefile    2012-05-27 20:38:24.066826167 +0100
@@ -35,7 +35,7 @@
 # do not recurse in to a dir we are about to delete
 ifneq "$(MAKECMDGOALS)" "distclean"
 SUBDIRS-$(CONFIG_IOEMU) += qemu-xen-traditional-dir
-SUBDIRS-$(CONFIG_IOEMU) += qemu-xen-dir
+#SUBDIRS-$(CONFIG_IOEMU) += qemu-xen-dir
 endif

SUBDIRS-y += xenpmd

Quoted 4 lines

If you are packaging this as RPM I guess you will also want the accompanying debuginfo RPM installed too, since RPM will have done magic with the unstripped binary.

Quoted 8 lines

Adding --leak-check=full and/or --track-origins=yes to the valgrind options might also be helpful.

The most plausible candidate for a leak would seem to be "Syscall param munmap(length) contains uninitialised byte(s)", but that might just be down to "Warning: noted but unhandled ioctl 0x84501 with no size/direction hints" on the corresponding mmap call. Hopefully with debugging symbols things will become clearer.

Will see what I can get the reporter to discover with this...

--
Steven Haigh

Email: [email protected]
Web: https://www.crc.id.au
Phone: (03) 9001 6090 - 0412 935 897
Fax: (03) 8338 0299

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#9 lore raw
Quoted 44 lines · Steven Haigh
Quoted 43 lines · Ian Campbell
Quoted 2 lines · Steven Haigh

Valgrind log available here:
http://xen.crc.id.au/bugs/view.php?id=25

Thanks.

Before we go any further, can you confirm that you have this commit in your qemu-xen-traditional tree:
commit 96b58a44756a8821c108358439b0f2c06e531159
Author: Matthew Daley <[email protected]>
Date: Wed Dec 4 15:16:18 2013 +1300

xen_disk: fix memory leak

On ioreq_release the full ioreq was memset to 0, losing all the data and memory allocations inside the QEMUIOVector, which leads to a memory leak. Create a new function to specifically reset ioreq.

Backport to qemu-xen-traditional.

Quoted 1 line

Do you have any further suggestions / ideas based on this?

Unfortunately the qemu-dm binary seems to have been stripped, which removes much of the useful info from the traces. Please can you make sure you have the following commit to the qemu-xen-traditional tree:
commit 18a08a23da88863435d56a0b14ff72013ef3b003
Author: Olaf Hering <[email protected]>
Date: Tue Oct 15 11:42:26 2013 +0200

qemu-traditional: do not strip binaries during make install

It is wrong to strip code during make install, unless explicit requested. Introduce a new variable INSTALL_PROG and use it along with an optional STRIP_OPT where currently install -s -m 755 is used. This is what upstream qemu offers in version 1.6.

Quoted 4 lines
Quoted 2 lines

I am using the qemu-xen-traditional that comes with xen-4.2.3.tar.gz

And have you confirmed that this does or does not contain the above fix?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw
Quoted 45 lines · Ian Campbell
Quoted 44 lines · Steven Haigh
Quoted 43 lines · Ian Campbell
Quoted 2 lines · Steven Haigh

Valgrind log available here:
http://xen.crc.id.au/bugs/view.php?id=25

Thanks.

Before we go any further, can you confirm that you have this commit in your qemu-xen-traditional tree:
commit 96b58a44756a8821c108358439b0f2c06e531159
Author: Matthew Daley <[email protected]>
Date: Wed Dec 4 15:16:18 2013 +1300

xen_disk: fix memory leak

On ioreq_release the full ioreq was memset to 0, losing all the data and memory allocations inside the QEMUIOVector, which leads to a memory leak. Create a new function to specifically reset ioreq.

Backport to qemu-xen-traditional.

Quoted 1 line

Do you have any further suggestions / ideas based on this?

Unfortunately the qemu-dm binary seems to have been stripped, which removes much of the useful info from the traces. Please can you make sure you have the following commit to the qemu-xen-traditional tree:
commit 18a08a23da88863435d56a0b14ff72013ef3b003
Author: Olaf Hering <[email protected]>
Date: Tue Oct 15 11:42:26 2013 +0200

qemu-traditional: do not strip binaries during make install

It is wrong to strip code during make install, unless explicit requested. Introduce a new variable INSTALL_PROG and use it along with an optional STRIP_OPT where currently install -s -m 755 is used. This is what upstream qemu offers in version 1.6.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I am using the qemu-xen-traditional that comes with xen-4.2.3.tar.gz

And have you confirmed that this does or does not contain the above fix?

http://xenbits.xen.org/gitweb/?p=qemu-xen-4.2-testing.git;a=summary

So qemu-traditional in Xen 4.2.3 does NOT have the fix. The fix is included in Xen 4.2.4.

-- Pasi

#11 lore raw
Quoted 51 lines · Pasi Kärkkäinen
Quoted 50 lines · Ian Campbell
Quoted 48 lines · Steven Haigh
Quoted 36 lines · Ian Campbell
Quoted 2 lines · Steven Haigh

Valgrind log available here:
http://xen.crc.id.au/bugs/view.php?id=25

Thanks.

Before we go any further, can you confirm that you have this commit in your qemu-xen-traditional tree:
commit 96b58a44756a8821c108358439b0f2c06e531159
Author: Matthew Daley <[email protected]>
Date: Wed Dec 4 15:16:18 2013 +1300

xen_disk: fix memory leak

On ioreq_release the full ioreq was memset to 0, losing all the data and memory allocations inside the QEMUIOVector, which leads to a memory leak. Create a new function to specifically reset ioreq.

Backport to qemu-xen-traditional.

Quoted 1 line

Do you have any further suggestions / ideas based on this?

Unfortunately the qemu-dm binary seems to have been stripped, which removes much of the useful info from the traces. Please can you make sure you have the following commit to the qemu-xen-traditional tree:
commit 18a08a23da88863435d56a0b14ff72013ef3b003
Author: Olaf Hering <[email protected]>
Date: Tue Oct 15 11:42:26 2013 +0200

Quoted 9 lines

qemu-traditional: do not strip binaries during make install

It is wrong to strip code during make install, unless explicit requested. Introduce a new variable INSTALL_PROG and use it along with an optional STRIP_OPT where currently install -s -m 755 is used. This is what upstream qemu offers in version 1.6.

I am using the qemu-xen-traditional that comes with xen-4.2.3.tar.gz

Quoted 7 lines
Quoted 2 lines

And have you confirmed that this does or does not contain the above fix?

http://xenbits.xen.org/gitweb/?p=qemu-xen-4.2-testing.git;a=summary

So qemu-traditional in Xen 4.2.3 does NOT have the fix. The fix is included in Xen 4.2.4.

Thanks - I think I missed the release announcement of 4.2.4. Ian clued me onto this yesterday. I've rebuilt the packages based on 4.2.4 and am awaiting confirmation that this does fix the error.

--
Steven Haigh

Email: [email protected]
Web: http://www.crc.id.au
Phone: (03) 9001 6090 - 0412 935 897
Fax: (03) 8338 0299

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel