[patch 01/26] SLUB: Fix memory leak by not reusing cpu_slab

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg Kroah-Hartman
Date: Monday, November 19, 2007 - 11:18 am

2.6.22-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Christoph Lameter <clameter@sgi.com>

backport of 05aa345034de6ae9c77fb93f6a796013641d57d5 from Linus's tree.

SLUB: Fix memory leak by not reusing cpu_slab

Fix the memory leak that may occur when we attempt to reuse a cpu_slab
that was allocated while we reenabled interrupts in order to be able to
grow a slab cache. The per cpu freelist may contain objects and in that
situation we may overwrite the per cpu freelist pointer loosing objects.
This only occurs if we find that the concurrently allocated slab fits
our allocation needs.

If we simply always deactivate the slab then the freelist will be properly
reintegrated and the memory leak will go away.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 mm/slub.c |   22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1431,28 +1431,8 @@ new_slab:
 	page = new_slab(s, gfpflags, node);
 	if (page) {
 		cpu = smp_processor_id();
-		if (s->cpu_slab[cpu]) {
-			/*
-			 * Someone else populated the cpu_slab while we
-			 * enabled interrupts, or we have gotten scheduled
-			 * on another cpu. The page may not be on the
-			 * requested node even if __GFP_THISNODE was
-			 * specified. So we need to recheck.
-			 */
-			if (node == -1 ||
-				page_to_nid(s->cpu_slab[cpu]) == node) {
-				/*
-				 * Current cpuslab is acceptable and we
-				 * want the current one since its cache hot
-				 */
-				discard_slab(s, page);
-				page = s->cpu_slab[cpu];
-				slab_lock(page);
-				goto load_freelist;
-			}
-			/* New slab does not fit our expectations */
+		if (s->cpu_slab[cpu])
 			flush_slab(s, s->cpu_slab[cpu], cpu);
-		}
 		slab_lock(page);
 		SetSlabFrozen(page);
 		s->cpu_slab[cpu] = page;

-- 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/26] 2.6.22-stable review, Greg Kroah-Hartman, (Mon Nov 19, 11:17 am)
[patch 01/26] SLUB: Fix memory leak by not reusing cpu_slab, Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 02/26] Fix compat futex hangs., Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 03/26] x86: fix TSC clock source calibration error, Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 04/26] writeback: dont propagate AOP_WRITEPAGE_ACTIVATE, Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 06/26] NETFILTER: nf_conntrack_tcp: fix connection ..., Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 07/26] fix the softlockup watchdog to actually work, Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 08/26] Fix TEQL oops., Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 09/26] Fix netlink timeouts., Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 10/26] Fix error returns in sys_socketpair(), Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 11/26] Fix endianness bug in U32 classifier., Greg Kroah-Hartman, (Mon Nov 19, 11:18 am)
[patch 12/26] Fix crypto_alloc_comp() error checking., Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 13/26] ALSA: hdsp - Fix zero division, Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 14/26] ALSA: hda-codec - Add array terminator for d ..., Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 15/26] forcedeth msi bugfix, Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 16/26] hptiop: avoid buffer overflow when returning ..., Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 17/26] USB: kobil_sct: trivial backport to fix libct, Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 18/26] USB: usbserial - fix potential deadlock betw ..., Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 20/26] i4l: Fix random hard freeze with AVM c4 card, Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 21/26] i4l: fix random freezes with AVM B1 drivers, Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 22/26] ide: fix serverworks.c UDMA regression, Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 23/26] ocfs2: fix write() performance regression, Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 24/26] i2c-pasemi: Fix NACK detection, Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 25/26] i2c/eeprom: Hide Sony Vaio serial numbers, Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)
[patch 26/26] i2c/eeprom: Recognize VGN as a valid Sony Va ..., Greg Kroah-Hartman, (Mon Nov 19, 11:19 am)