[PATCH] mm/memory.c, 2.4.1 : memory leak with swap cache (updated)

Richard Jerrell (jerrell@missioncriticallinux.com)
Thu, 22 Mar 2001 17:21:46 -0500 (EST)


This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.

--17458952-1346124290-982275034=:1390
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.LNX.4.21.0102151740301.1390@jerrell.lowell.mclinux.com>

2.4.1 has a memory leak (temporary) where anonymous memory pages that have
been moved into the swap cache will stick around after their vma has been
unmapped by the owning process. These pages are not free'd in free_pte()
because they are still referenced by the page cache. In addition, if the
pages are dirty, they will be written out to the swap device before they
are reclaimed even though the owning process no longer will be using the
pages.

free_pte in mm/memory.c has been modified to check to see if the page is
only being referenced by the swap cache (and possibly buffers). If so,
the buffers (if existant) are free'd and the page and swap cache
entry are removed immediately.

Essentially, this is the same patch as before, but there was one condition
in which case we would leak and extra reference to the targeted page if
the counts would not allow us to remove the swap cache entry. The leak in
2.4.1 also applies to 2.4.2 and 2.4.3-pre5.

Rich Jerrell
jerrell@missioncriticallinux.com

--17458952-1346124290-982275034=:1390
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="2.4.1-paging-fix-22.03.01.patch"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.21.0103221721461.20061@jerrell.lowell.mclinux.com>
Content-Description:
Content-Disposition: attachment; filename="2.4.1-paging-fix-22.03.01.patch"

ZGlmZiAtLXJlY3Vyc2l2ZSAtdSAtTiBsaW51eC0yLjQuMS9tbS9tZW1vcnku
YyBsaW51eC0yLjQuMS1wYWdpbmctZml4L21tL21lbW9yeS5jDQotLS0gbGlu
dXgtMi40LjEvbW0vbWVtb3J5LmMJU2F0IEphbiAyNyAyMjoxMjozNSAyMDAx
DQorKysgbGludXgtMi40LjEtcGFnaW5nLWZpeC9tbS9tZW1vcnkuYwlUaHUg
RmViIDE1IDEzOjM2OjA2IDIwMD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w0KKwkJCWlmKChwYWdlLT5idWZmZXJzKSkgew0KKwkJ
CQlpZighdHJ5X3RvX2ZyZWVfYnVmZmVycyhwYWdlLDEpKSB7CS8qIENhbid0
IGdldCByaWQgb2YgYnVmZmVycyAgICovDQorCQkJCQlwYWdlX2NhY2hlX3Jl
bGVhc2UocGFnZSk7CS8qIGdldCByaWQgb2Ygb3VyIHJlZmVyZW5jZSAgICov
DQorCQkJCQlyZXR1cm4gMDsJCQkvKiBhbmQgbGV0IHNvbWVvbmUgZWxzZSBk
byBpdCAqLw0KKwkJCQl9DQorCQkJfQ0KKwkJCWZyZWVfcGFnZV9hbmRfc3dh
cF9jYWNoZShwYWdlKTsJLyogRXhwZWN0cyB0aGUgcGFnZSB0byBiZSBtYXBw
ZWQsIHNvIHdpbGwgKi8NCisJCQlyZXR1cm4gMTsJCQkvKiBhY2NvdW50IGZv
ciB0aGUgcmVmZXJlbmNlIHdlIGhhdmUgICAgICAqLw0KKwkJfQ0KKwkJcGFn
ZV9jYWNoZV9yZWxlYXNlKHBhZ2UpOyAgICAgICAvKiBSZW1vdmUgb3VyIHJl
ZmVyZW5jZSwgd2UgY2FuJ3QgZG8gYW55dGhpbmcgKi8NCisJfQ0KIAlyZXR1
cm4gMDsNCiB9DQogDQo=
--17458952-1346124290-982275034=:1390--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/