Commenting out out_of_memory() function in __alloc_pages()

Abu M. Muttalib
2006-07-07T09:46:37Z

[-- Attachment #1: Type: text/plain, Size: 794 bytes --]

Hi,

I am getting the Out of memory.

To circumvent the problem, I have commented the call to "out_of_memory(),
and replaced "goto restart" with "goto nopage".

At "nopage:" lable I have added a call to "schedule()" and then "return
NULL" after "schedule()".

I tried the modified kernel with a test application, the test application is
mallocing memory in a loop. Unlike as expected the process gets killed. On
second run of the same application I am getting the page allocation failure
as expected but subsequently the system hangs.

I am attaching the test application and the log herewith.

I am getting this exception with kernel 2.6.13. With kernel
2.4.19-rmka7-pxa1 there was no problem.

Why its so? What can I do to alleviate the OOM problem?

Thanks in anticipation and regards,
Abu.

[-- Attachment #2: mail_oom_test_6.TXT --]
[-- Type: text/plain, Size: 11528 bytes --]

sh-3.00# ./test1\a

OOM Test: Counter = 0
....
OOM Test: Counter = 6635
, OOM: Out of Memory would have been called....<4>test1: page allocation failure. order:0, mode:0xd2
\rMem-info:
\rDMA per-cpu:
\rcpu 0 hot: low 2, high 6, batch 1 used:2
\rcpu 0 cold: low 0, high 2, batch 1 used:1
\rNormal per-cpu: empty
\rHighMem per-cpu: empty
\rFree pages: 588kB (0kB HighMem)
\rActive:2178 inactive:230 dirty:0 writeback:0 unstable:0 free:147 slab:367 mapped:2178 pagetables:43
\rDMA free:588kB min:512kB low:640kB high:768kB active:8712kB inactive:920kB present:16384kB pages_scanned:4851 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rNormal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rHighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rDMA: 9*4kB 3*8kB 1*16kB 0*32kB 0*64kB 0*128kB 0*256kB 1*512kB 0*1024kB = 588kB
\rNormal: empty
\rHighMem: empty
\rSwap cache: add 0, delete 0, find 0/0, race 0+0
\rFree swap = 0kB
\rTotal swap = 0kB
\rFree swap: 0kB
\r4096 pages of RAM
\r218 free pages
\r625 reserved pages
\r367 slab pages
\r0 pages shared
\r0 pages swap cached
\rVM: killing process test1
\rKilled
sh-3.00# ./test1

OOM Test: Counter = 0
....
OOM Test: Counter = 6416
, OOM: Out of Memory would have been called....<4>test1: page allocation failure. order:0, mode:0x201d0
\rMem-info:
\rDMA per-cpu:
\rcpu 0 hot: low 2, high 6, batch 1 used:2
\rcpu 0 cold: low 0, high 2, batch 1 used:1
\rNormal per-cpu: empty
\rHighMem per-cpu: empty
\rFree pages: 672kB (0kB HighMem)
\rActive:2187 inactive:170 dirty:0 writeback:0 unstable:0 free:168 slab:365 mapped:2125 pagetables:43
\rDMA free:672kB min:512kB low:640kB high:768kB active:8748kB inactive:680kB present:16384kB pages_scanned:2939 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rNormal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rHighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rDMA: 28*4kB 6*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 1*512kB 0*1024kB = 672kB
\rNormal: empty
\rHighMem: empty
\rSwap cache: add 0, delete 0, find 0/0, race 0+0
\rFree swap = 0kB
\rTotal swap = 0kB
\rFree swap: 0kB
\r4096 pages of RAM
\r239 free pages
\r625 reserved pages
\r365 slab pages
\r13 pages shared
\r0 pages swap cached
\rError -5 while decompressing!
\rc01e42f4(2388)->c0754000(4096)
\rError -3 while decompressing!
\rc01e4c48(2531)->c0caf000(4096)
\rError -3 while decompressing!
\rc01e562b(2643)->c0914000(4096)
\r, OOM: Out of Memory would have been called....<4>test1: page allocation failure. order:0, mode:0x201d2
\rMem-info:
\rDMA per-cpu:
\rcpu 0 hot: low 2, high 6, batch 1 used:3
\rcpu 0 cold: low 0, high 2, batch 1 used:1
\rNormal per-cpu: empty
\rHighMem per-cpu: empty
\rFree pages: 600kB (0kB HighMem)
\rActive:2267 inactive:113 dirty:0 writeback:0 unstable:0 free:150 slab:365 mapped:2125 pagetables:43
\rDMA free:600kB min:512kB low:640kB high:768kB active:9068kB inactive:452kB present:16384kB pages_scanned:222 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rNormal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rHighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rDMA: 22*4kB 0*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 1*512kB 0*1024kB = 600kB
\rNormal: empty
\rHighMem: empty
\rSwap cache: add 0, delete 0, find 0/0, race 0+0
\rFree swap = 0kB
\rTotal swap = 0kB
\rFree swap: 0kB
\r4096 pages of RAM
\r222 free pages
\r625 reserved pages
\r365 slab pages
\r13 pages shared
\r0 pages swap cached
\r, OOM: Out of Memory would have been called....<4>init: page allocation failure. order:0, mode:0x201d0
\rMem-info:
\rDMA per-cpu:
\rcpu 0 hot: low 2, high 6, batch 1 used:3
\rcpu 0 cold: low 0, high 2, batch 1 used:1
\rNormal per-cpu: empty
\rHighMem per-cpu: empty
\rFree pages: 696kB (0kB HighMem)
\rActive:2220 inactive:136 dirty:0 writeback:0 unstable:0 free:174 slab:365 mapped:2125 pagetables:43
\rDMA free:696kB min:512kB low:640kB high:768kB active:8880kB inactive:544kB present:16384kB pages_scanned:6729 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rNormal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rHighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rDMA: 44*4kB 1*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 1*512kB 0*1024kB = 696kB
\rNormal: empty
\rHighMem: empty
\rSwap cache: add 0, delete 0, find 0/0, race 0+0
\rFree swap = 0kB
\rTotal swap = 0kB
\rFree swap: 0kB
\r4096 pages of RAM
\r246 free pages
\r625 reserved pages
\r365 slab pages
\r3 pages shared
\r0 pages swap cached
\rError -5 while decompressing!
\rc01e7949(2386)->c040d000(4096)
\rError -3 while decompressing!
\rc01e829b(2297)->c05e9000(4096)
\r, OOM: Out of Memory would have been called....<4>init: page allocation failure. order:0, mode:0x201d2
\rMem-info:
\rDMA per-cpu:
\rcpu 0 hot: low 2, high 6, batch 1 used:4
\rcpu 0 cold: low 0, high 2, batch 1 used:1
\rNormal per-cpu: empty
\rHighMem per-cpu: empty
\rFree pages: 600kB (0kB HighMem)
\rActive:2189 inactive:166 dirty:0 writeback:0 unstable:0 free:150 slab:364 mapped:2125 pagetables:43
\rDMA free:600kB min:512kB low:640kB high:768kB active:8756kB inactive:664kB present:16384kB pages_scanned:7675 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rNormal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rHighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rDMA: 20*4kB 1*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 1*512kB 0*1024kB = 600kB
\rNormal: empty
\rHighMem: empty
\rSwap cache: add 0, delete 0, find 0/0, race 0+0
\rFree swap = 0kB
\rTotal swap = 0kB
\rFree swap: 0kB
\r4096 pages of RAM
\r223 free pages
\r625 reserved pages
\r364 slab pages
\r1 pages shared
\r0 pages swap cached
\r, OOM: Out of Memory would have been called....<4>test1: page allocation failure. order:0, mode:0x201d0
\rMem-info:
\rDMA per-cpu:
\rcpu 0 hot: low 2, high 6, batch 1 used:4
\rcpu 0 cold: low 0, high 2, batch 1 used:1
\rNormal per-cpu: empty
\rHighMem per-cpu: empty
\rFree pages: 600kB (0kB HighMem)
\rActive:2291 inactive:64 dirty:0 writeback:0 unstable:0 free:150 slab:364 mapped:2125 pagetables:43
\rDMA free:600kB min:512kB low:640kB high:768kB active:9164kB inactive:256kB present:16384kB pages_scanned:10106 all_unreclaimable? yes
\rlowmem_reserve[]: 0 0 0
\rNormal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rHighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rDMA: 20*4kB 1*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 1*512kB 0*1024kB = 600kB
\rNormal: empty
\rHighMem: empty
\rSwap cache: add 0, delete 0, find 0/0, race 0+0
\rFree swap = 0kB
\rTotal swap = 0kB
\rFree swap: 0kB
\r4096 pages of RAM
\r223 free pages
\r625 reserved pages
\r364 slab pages
\r2 pages shared
\r0 pages swap cached
\r, OOM: Out of Memory would have been called....<4>init: page allocation failure. order:0, mode:0x201d2
\rMem-info:
\rDMA per-cpu:
\rcpu 0 hot: low 2, high 6, batch 1 used:4
\rcpu 0 cold: low 0, high 2, batch 1 used:0
\rNormal per-cpu: empty
\rHighMem per-cpu: empty
\rFree pages: 512kB (0kB HighMem)
\rActive:2296 inactive:125 dirty:0 writeback:0 unstable:0 free:128 slab:364 mapped:2127 pagetables:43
\rDMA free:512kB min:512kB low:640kB high:768kB active:9184kB inactive:500kB present:16384kB pages_scanned:10106 all_unreclaimable? yes
\rlowmem_reserve[]: 0 0 0
\rNormal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rHighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rDMA: 0*4kB 0*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 1*512kB 0*1024kB = 512kB
\rNormal: empty
\rHighMem: empty
\rSwap cache: add 0, delete 0, find 0/0, race 0+0
\rFree swap = 0kB
\rTotal swap = 0kB
\rFree swap: 0kB
\r4096 pages of RAM
\r200 free pages
\r625 reserved pages
\r364 slab pages
\r34 pages shared
\r0 pages swap cached
\r, OOM: Out of Memory would have been called....<4>init: page allocation failure. order:0, mode:0x201d2
\rMem-info:
\rDMA per-cpu:
\rcpu 0 hot: low 2, high 6, batch 1 used:4
\rcpu 0 cold: low 0, high 2, batch 1 used:0
\rNormal per-cpu: empty
\rHighMem per-cpu: empty
\rFree pages: 512kB (0kB HighMem)
\rActive:2296 inactive:125 dirty:0 writeback:0 unstable:0 free:128 slab:364 mapped:2127 pagetables:43
\rDMA free:512kB min:512kB low:640kB high:768kB active:9184kB inactive:500kB present:16384kB pages_scanned:10106 all_unreclaimable? yes
\rlowmem_reserve[]: 0 0 0
\rNormal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rHighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rDMA: 0*4kB 0*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 1*512kB 0*1024kB = 512kB
\rNormal: empty
\rHighMem: empty
\rSwap cache: add 0, delete 0, find 0/0, race 0+0
\rFree swap = 0kB
\rTotal swap = 0kB
\rFree swap: 0kB
\r4096 pages of RAM
\r200 free pages
\r625 reserved pages
\r364 slab pages
\r34 pages shared
\r0 pages swap cached
\r, OOM: Out of Memory would have been called....<4>test1: page allocation failure. order:0, mode:0x201d2
\rMem-info:
\rDMA per-cpu:
\rcpu 0 hot: low 2, high 6, batch 1 used:4
\rcpu 0 cold: low 0, high 2, batch 1 used:0
\rNormal per-cpu: empty
\rHighMem per-cpu: empty
\rFree pages: 512kB (0kB HighMem)
\rActive:2296 inactive:125 dirty:0 writeback:0 unstable:0 free:128 slab:364 mapped:2133 pagetables:43
\rDMA free:512kB min:512kB low:640kB high:768kB active:9184kB inactive:500kB present:16384kB pages_scanned:10106 all_unreclaimable? yes
\rlowmem_reserve[]: 0 0 0
\rNormal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rHighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
\rlowmem_reserve[]: 0 0 0
\rDMA: 0*4kB 0*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 1*512kB 0*1024kB = 512kB
\rNormal: empty
\rHighMem: empty
\rSwap cache: add 0, delete 0, find 0/0, race 0+0
\rFree swap = 0kB
\rTotal swap = 0kB
\rFree swap: 0kB
\r4096 pages of RAM
\r200 free pages
\r625 reserved pages
\r364 slab pages
\r40 pages shared
\r0 pages swap cached
\r, OOM: Out of Memory would have been called....VM: killing process test1

[-- Attachment #3: test1.c --]
[-- Type: application/octet-stream, Size: 319 bytes --]

#include<stdio.h>
#include<string.h>

main()
{
char* buff;
int count;

count=0;
while(1)
{
printf("\nOOM Test: Counter = %d", count);
buff = (char*) malloc(1024);
// memset(buff,'\0',1024);
count++;

if (buff==NULL)
{
printf("\nOOM Test: Memory allocation error");
}
}
}