Skip to contentSkip to conversation

Mem issues in 2.6.9 (ever since 2.6.9-rc3) and possible cause

PATCH Javier Marcet 6 participants 7 messages Oct 23, 2004 – Oct 29, 2004

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

I've been following quite closely the development of 2.6.9, testing every -rc release and a lot of -bk's.

Upon changing from 2.6.9-rc2 to 2.6.9-rc3 I began experiencing random oom kills whenever a high memory i/o load took place.
This happened with plenty of free memory, and with whatever values I used for vm.overcommit_ratio and vm.overcommit_memory Doubling the physical RAM didn't change the situation either.

Having traced the problem to 2.6.9-rc3, I took a look at the differences in memory handling between 2.6.9-rc2 and 2.6.9-rc3 and with the attached patch I have no more oom kills. Not a single one.

I'm not saying everything within the patch is needed, not even that it's the right thing to change. Nonetheless, 2.6.9 vanilla was unusable, while this avoids those memory leaks.

Please, review and see what's wrong there :)

Signature · 5 lines
A mother takes twenty years to make a man of her boy, and another woman
makes a fool of him in twenty minutes.
a		-- Frost

Javier Marcet <[email protected]>
mm/highmem.c +0 -2
@@ -300,7 +300,6 @@
 		 */
 		vfrom = page_address(fromvec->bv_page) + tovec->bv_offset;
 
-		flush_dcache_page(tovec->bv_page);
 		bounce_copy_vec(tovec, vfrom);
 	}
 }
@@ -407,7 +406,6 @@
 		if (rw == WRITE) {
 			char *vto, *vfrom;
 
-			flush_dcache_page(from->bv_page);
 			vto = page_address(to->bv_page) + to->bv_offset;
 			vfrom = kmap(from->bv_page) + from->bv_offset;
 			memcpy(vto, vfrom, to->bv_len);
mm/mempolicy.c +0 -3
@@ -132,7 +132,6 @@
 	unsigned long nlongs;
 	unsigned long endmask;
 
-	--maxnode;
 	bitmap_zero(nodes, MAX_NUMNODES);
 	if (maxnode == 0 || !nmask)
 		return 0;
@@ -146,8 +145,6 @@
 	/* When the user specified more nodes than supported just check
 	   if the non supported part is all zero. */
 	if (nlongs > BITS_TO_LONGS(MAX_NUMNODES)) {
-		if (nlongs > PAGE_SIZE/sizeof(long))
-			return -EINVAL;
 		for (k = BITS_TO_LONGS(MAX_NUMNODES); k < nlongs; k++) {
 			unsigned long t;
 			if (get_user(t,  nmask + k))
#1 lore raw
Quoted 6 lines · Javier Marcet

I've been following quite closely the development of 2.6.9, testing
every -rc release and a lot of -bk's.

Upon changing from 2.6.9-rc2 to 2.6.9-rc3 I began experiencing random oom kills whenever a high memory i/o load took place.

Do you have swap online?

What sort of machine is it, and how much memory has it?

Quoted 11 lines

This happened with plenty of free memory, and with whatever values I used for vm.overcommit_ratio and vm.overcommit_memory Doubling the physical RAM didn't change the situation either.

Having traced the problem to 2.6.9-rc3, I took a look at the differences in memory handling between 2.6.9-rc2 and 2.6.9-rc3 and with the attached patch I have no more oom kills. Not a single one.

I'm not saying everything within the patch is needed, not even that it's the right thing to change. Nonetheless, 2.6.9 vanilla was unusable, while this avoids those memory leaks.

That patch only affects NUMA machines?

#2 lore raw
Quoted 10 lines · Andrew Morton
Quoted 5 lines · Javier Marcet

I've been following quite closely the development of 2.6.9, testing every -rc release and a lot of -bk's.

Upon changing from 2.6.9-rc2 to 2.6.9-rc3 I began experiencing random oom kills whenever a high memory i/o load took place.

Do you have swap online?

When he first reported it he said no swap.

Quoted 1 line

What sort of machine is it, and how much memory has it?

Ditto - 1Gb ram.

Con

#3 lore raw
In reply to Javier Marcet
Quoted 2 lines · Javier Marcet

I'm not saying everything within the patch is needed, not even that it's the right thing to change.

I suspect the following (still untested) patch might be needed, too. Basically when the VM gets tight, it could still ignore swappable pages with the referenced bit set. Both really referenced pages and pages from the process that currently has the swap token.

Forcefully deactivating a few pages when we run with priority 0 might get rid of the false OOM kills.

I'm about to test this on a very small system here, and will let you know how things go.

===== mm/vmscan.c 1.231 vs edited =====

mm/vmscan.c +0 -0
@@ -379,7 +379,7 @@
 
		referenced = page_referenced(page, 1);
		/* In active use or really unfreeable?  Activate it. */
-		if (referenced && page_mapping_inuse(page))
+		if (referenced && sc->priority && page_mapping_inuse(page))
			goto activate_locked;

#ifdef CONFIG_SWAP
@@ -715,7 +715,7 @@

		if (page_mapped(page)) {
			if (!reclaim_mapped ||
			    (total_swap_pages == 0 && PageAnon(page)) ||
-			    page_referenced(page, 0)) {
+			    (page_referenced(page, 0) && sc->priority)) {
				list_add(&page->lru, &l_active);
				continue;
			}
#4 lore raw

Review

Quoted 3 lines · Rik van Riel
(quoted diff) +1 -1
-		if (referenced && page_mapping_inuse(page))
+		if (referenced && sc->priority && page_mapping_inuse(page))

Makes heaps of sense, but I'd like to exactly understand why people are getting oomings before doing something like this. I think we're still waiting for a testcase?

#5 lore raw
Quoted 9 lines · Andrew Morton

Review

Quoted 2 lines · Rik van Riel
(quoted diff) +1 -1
-		if (referenced && page_mapping_inuse(page))
+		if (referenced && sc->priority && page_mapping_inuse(page))

Makes heaps of sense, but I'd like to exactly understand why people are getting oomings before doing something like this. I think we're still waiting for a testcase?

I have found that quite often it is because all_unreclaimable gets set, scanning slows down, and the OOM killer goes off.

Rik, I wonder if you can put some printk's where all_unreclaimable is being set to 1, and see if there is any correlation to OOMs?

Aside from that, the patch does make sense, but might be too aggressive. In heavy swapping loads, the "zero priority" scan might make up a significant proportion of the scanning done so you'll want to be careful about regressions there.

#6 lore raw
In reply to Javier Marcet
Quoted 13 lines · Javier Marcet

I've been following quite closely the development of 2.6.9, testing every -rc release and a lot of -bk's.

Upon changing from 2.6.9-rc2 to 2.6.9-rc3 I began experiencing random oom kills whenever a high memory i/o load took place.
This happened with plenty of free memory, and with whatever values I used for vm.overcommit_ratio and vm.overcommit_memory Doubling the physical RAM didn't change the situation either.

Having traced the problem to 2.6.9-rc3, I took a look at the differences in memory handling between 2.6.9-rc2 and 2.6.9-rc3 and with the attached patch I have no more oom kills. Not a single one.

Quoted 5 lines

I'm not saying everything within the patch is needed, not even that it's the right thing to change. Nonetheless, 2.6.9 vanilla was unusable, while this avoids those memory leaks.

Please, review and see what's wrong there :)

The changes in mempolicy.c are unrelated, except you have a NUMA enabled machine.

The flush_dcache_page() is only relevant for non x86, as they result in a NOP there.

tglx