• M
    mm/vmscan.c: fix trying to reclaim unevictable LRU page · a58f2cef
    Minchan Kim 提交于
    There was the below bug report from Wu Fangsuo.
    
    On the CMA allocation path, isolate_migratepages_range() could isolate
    unevictable LRU pages and reclaim_clean_page_from_list() can try to
    reclaim them if they are clean file-backed pages.
    
      page:ffffffbf02f33b40 count:86 mapcount:84 mapping:ffffffc08fa7a810 index:0x24
      flags: 0x19040c(referenced|uptodate|arch_1|mappedtodisk|unevictable|mlocked)
      raw: 000000000019040c ffffffc08fa7a810 0000000000000024 0000005600000053
      raw: ffffffc009b05b20 ffffffc009b05b20 0000000000000000 ffffffc09bf3ee80
      page dumped because: VM_BUG_ON_PAGE(PageLRU(page) || PageUnevictable(page))
      page->mem_cgroup:ffffffc09bf3ee80
      ------------[ cut here ]------------
      kernel BUG at /home/build/farmland/adroid9.0/kernel/linux/mm/vmscan.c:1350!
      Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 0 PID: 7125 Comm: syz-executor Tainted: G S              4.14.81 #3
      Hardware name: ASR AQUILAC EVB (DT)
      task: ffffffc00a54cd00 task.stack: ffffffc009b00000
      PC is at shrink_page_list+0x1998/0x3240
      LR is at shrink_page_list+0x1998/0x3240
      pc : [<ffffff90083a2158>] lr : [<ffffff90083a2158>] pstate: 60400045
      sp : ffffffc009b05940
      ..
         shrink_page_list+0x1998/0x3240
         reclaim_clean_pages_from_list+0x3c0/0x4f0
         alloc_contig_range+0x3bc/0x650
         cma_alloc+0x214/0x668
         ion_cma_allocate+0x98/0x1d8
         ion_alloc+0x200/0x7e0
         ion_ioctl+0x18c/0x378
         do_vfs_ioctl+0x17c/0x1780
         SyS_ioctl+0xac/0xc0
    
    Wu found it's due to commit ad6b6704 ("mm: remove SWAP_MLOCK in
    ttu").  Before that, unevictable pages go to cull_mlocked so that we
    can't reach the VM_BUG_ON_PAGE line.
    
    To fix the issue, this patch filters out unevictable LRU pages from the
    reclaim_clean_pages_from_list in CMA.
    
    Link: http://lkml.kernel.org/r/20190524071114.74202-1-minchan@kernel.org
    Fixes: ad6b6704 ("mm: remove SWAP_MLOCK in ttu")
    Signed-off-by: NMinchan Kim <minchan@kernel.org>
    Reported-by: NWu Fangsuo <fangsuowu@asrmicro.com>
    Debugged-by: NWu Fangsuo <fangsuowu@asrmicro.com>
    Tested-by: NWu Fangsuo <fangsuowu@asrmicro.com>
    Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
    Acked-by: NMichal Hocko <mhocko@suse.com>
    Cc: Pankaj Suryawanshi <pankaj.suryawanshi@einfochips.com>
    Cc: <stable@vger.kernel.org>	[4.12+]
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    a58f2cef
vmscan.c 121.4 KB