title: OOM Killer is triggered despite free memory
body: <p>I am having a problem where the OOM killer is being triggered some times. I have   researched in the internet and have found many related threads. But a few things   still puzzle me. I hope some one could help me. </p>
  
  <p>Environment: iMX6 (32bit). 
  User/Kernelspace split: 2G-2G<br>
  TotalRAm - 4GB  </p>
  
  <p>Some important logs:  </p>
  
  <p><strong>top invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0</strong><br>
  I see that it is trying to allocate 1 page of (contagious) memory (order=0) in the HIGHMEM zone (from gfp_mask). Please correct me if i am wrong.  </p>
  
  <p><strong>DMA free:1322780kB min:4492kB low:5612kB high:6736kB active_anon:0kB inactive_anon:0kB active_file:84kB<br>
  DMA: 941*4kB (UEMC) 1211*8kB (UEMC) 1185*16kB (UEMC) 836*32kB (UEMC) 554*64kB<br>
  (UEMC) 295*128kB (UEMC) 106*256kB<br>
  HighMem free:480kB min:512kB low:2384kB high:4256kB active_anon:2021148kB inactive_anon:70364kB active_file:0kB<br>
  HighMem: 0*4kB 1*8kB (R) 0*16kB 7*32kB (R) 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB 0*8192kB</strong></p>
  
  <p>I believe the OOM-killer is triggered as the free Highmem (480KB) is below the min (512KB). Again please correct me if i am wrong.</p>
  
  <p>My questions:<br>
  1. I thought the DMA_ZONE is only about 16MB, NORMAL_ZONE is upwards from 16MB 
     to about 896MB and the rest is HIGHMEM_ZONE. But the log shows more than 1GB 
     free pages (1322780kB) exist in the DMA_ZONE.<br>
  2. Why does not the kernel utilize this Zone for further allocation?</p>
  
  <p>Morelogs: (taken out from the complete log):<br>
  <strong>DMA per-cpu:<br>
   CPU    0: hi:  186, btch:  31 usd:   0<br>
   CPU    1: hi:  186, btch:  31 usd:   0<br>
   CPU    2: hi:  186, btch:  31 usd:   0<br>
   CPU    3: hi:  186, btch:  31 usd:   0<br>
  HighMem per-cpu:<br>
   CPU    0: hi:  186, btch:  31 usd:  51<br>
   CPU    1: hi:  186, btch:  31 usd:  20<br>
   CPU    2: hi:  186, btch:  31 usd:   4<br>
   CPU    3: hi:  186, btch:  31 usd:  14<br>
  active_anon:505287 inactive_anon:17591 isolated_anon:0<br>
  active_file:21 inactive_file:0 isolated_file:0<br>
  unevictable:0 dirty:0 writeback:0 unstable:0<br>
  free:330815 slab_reclaimable:1134 slab_unreclaimable:3487<br>
  mapped:15956 shmem:25014 pagetables:1982 bounce:0<br>
  25046 total pagecache pages<br>
  983039 pages of RAM<br>
  331349 free pages<br>
  9947 reserved pages<br>
  2772 slab pages<br>
  543663 pages shared<br>
  0 pages swap cached</strong>  </p>
  
  <p>cat /proc/pagetypeinfo<br>
  Page block order: 13<br>
  Pages per block:  8192  </p>
  
  <p>Free pages count per migrate type at order       0      1      2      3      4        5      6      7      8      9     10     11     12     13<br>
  Node    0, zone      DMA, type    Unmovable      1      0      9      8      3        1      0      1      1      1      1      0      1      0
  Node    0, zone      DMA, type  Reclaimable      4      5      5      1      2       0      1      1      1      0      1      0      1      0
  Node    0, zone      DMA, type      Movable      1      6      4      0      0        0      1      1      2      4      3      3      4     28<br>
  Node    0, zone      DMA, type      Reserve      0      0      0      0      0        0      0      0      0      0      0      0      0      1<br>
  Node    0, zone      DMA, type          CMA      1      1      2      0      0        0      0      0      1      1      0      0      1      3<br>
  Node    0, zone      DMA, type      Isolate      0      0      0      0      0        0      0      0      0      0      0      0      0      0<br>
  Node    0, zone  HighMem, type    Unmovable     11      7      2      2      9        6      5      3      3      1      0      1      1      0<br>
  Node    0, zone  HighMem, type  Reclaimable      0      0      0      0      0        0      0      0      0      0      0      0      0      0<br>
  Node    0, zone  HighMem, type      Movable     23    201   4771   4084   1803      403    105     69     57     38     23     21      8     23<br>
  Node    0, zone  HighMem, type      Reserve      0      0      0      0      0        0      0      0      0      0      0      0      0      1<br>
  Node    0, zone  HighMem, type          CMA      0      0      0      0      0        0      0      0      0      0      0      0      0      0<br>
  Node    0, zone  HighMem, type      Isolate      0      0      0      0      0        0      0      0      0      0      0      0      0      0  </p>
  
  <p>Number of blocks type     Unmovable  Reclaimable      Movable      Reserve            CMA      Isolate<br>
  Node 0, zone      DMA            5            1           33            1             16            0<br>
  Node 0, zone  HighMem            2            0           62            1              0            0  </p>
  
  <p>I would be glad to post further logs if necessary.  </p>
  
  <p>Thankyou,<br>
  Srik  </p>