From: Matthew Rushton Subject: [PATCH v2 2/4] xen-blkback: fix memory leaks Date: Thu, 6 Feb 2014 19:15:06 -0800 (PST) Message-ID: <1391742906.53011.YahooMailNeo@web122601.mail.ne1.yahoo.com> Reply-To: Matthew Rushton Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6098453347174010562==" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WBbuJ-0006WC-5b for xen-devel@lists.xenproject.org; Fri, 07 Feb 2014 03:15:11 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: =?utf-8?B?Um9nZXIgUGF1IE1vbm5lIOKAjuKAjg==?= Cc: =?utf-8?B?SWFuIENhbXBiZWxsIOKAjg==?= , "linux-kernel@vger.kernel.org" , "mrushton@amazon.com" , =?utf-8?B?RGF2aWQgVnJhYmVsIOKAjuKAjuKAjg==?= , "msw@amazon.com" , "xen-devel@lists.xenproject.org" , =?utf-8?B?Qm9yaXMgT3N0cm92c2t5IOKAjg==?= , "aliguori@amazon.com" List-Id: xen-devel@lists.xenproject.org --===============6098453347174010562== Content-Type: multipart/alternative; boundary="-822996273-1973664204-1391742906=:53011" ---822996273-1973664204-1391742906=:53011 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/02/14 10:26, Roger Pau Monne wrote:=0A> I've at least identified two = possible memory leaks in blkback, both=0A> related to the shutdown path of = a VBD:=0A> =0A> - blkback doesn't wait for any pending purge work to finish= before=0A>=C2=A0=C2=A0 cleaning the list of free_pages. The purge work wil= l call=0A>=C2=A0=C2=A0 put_free_pages and thus we might end up with pages b= eing added to=0A>=C2=A0=C2=A0 the free_pages list after we have emptied it.= Fix this by making=0A>=C2=A0=C2=A0 sure there's no pending purge work befo= re exiting=0A>=C2=A0=C2=A0 xen_blkif_schedule, and moving the free_page cle= anup code to=0A>=C2=A0=C2=A0 xen_blkif_free.=0A> - blkback doesn't wait for= pending requests to end before cleaning=0A>=C2=A0=C2=A0 persistent grants = and the list of free_pages. Again this can add=0A>=C2=A0=C2=A0 pages to the= free_pages list or persistent grants to the=0A>=C2=A0=C2=A0 persistent_gnt= s red-black tree. Fixed by moving the persistent=0A>=C2=A0=C2=A0 grants and= free_pages cleanup code to xen_blkif_free.=0A> =0A> Also, add some checks = in xen_blkif_free to make sure we are cleaning=0A> everything.=0A=0ATested-= by: Matt Rushton =0A=0AReviewed-by: Matt Rushton =0A ---822996273-1973664204-1391742906=:53011 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On 04/0= 2/14 10:26, Roger Pau Monne wrote:
=0A=0A> I've at least identified t= wo possible memory leaks in blkback, both
=0A=0A> related to the shut= down path of a VBD:
=0A=0A>
=0A=0A> - blkback doesn't wait for= any pending purge work to finish before
=0A=0A>   cleaning= the list of free_pages. The purge work will call
=0A=0A>  = put_free_pages and thus we might end up with pages being added to
=0A= =0A>   the free_pages list after we have emptied it. Fix this = by making
=0A=0A>   sure there's no pending purge work befo= re exiting
=0A=0A>   xen_blkif_schedule, and moving the fre= e_page cleanup code to
=0A=0A>   xen_blkif_free.
=0A=0A&= gt; - blkback doesn't wait for pending requests to end before cleaning
= =0A=0A>   persistent grants and the list of free_pages. Again = this can add
=0A=0A>   pages to the free_pages list or pers= istent grants to the
=0A=0A>   persistent_gnts red-black tr= ee. Fixed by moving the persistent
=0A=0A>   grants and fre= e_pages cleanup code to xen_blkif_free.
=0A=0A>
=0A=0A> Also, = add some checks in xen_blkif_free to make sure we are cleaning
=0A=0A>= ; everything.

Tested-by: Matt Rusht= on <mrushton@amazon.com>
Reviewed-by: Matt Rushton <mrush= ton@amazon.com>

---822996273-1973664204-1391742906=:53011-- --===============6098453347174010562== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============6098453347174010562==--