]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.14/mm-vmscan.c-fix-trying-to-reclaim-unevictable-lru-page.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.14 / mm-vmscan.c-fix-trying-to-reclaim-unevictable-lru-page.patch
CommitLineData
80ae7e1e
GKH
1From a58f2cef26e1ca44182c8b22f4f4395e702a5795 Mon Sep 17 00:00:00 2001
2From: Minchan Kim <minchan@kernel.org>
3Date: Thu, 13 Jun 2019 15:56:15 -0700
4Subject: mm/vmscan.c: fix trying to reclaim unevictable LRU page
5
6From: Minchan Kim <minchan@kernel.org>
7
8commit a58f2cef26e1ca44182c8b22f4f4395e702a5795 upstream.
9
10There was the below bug report from Wu Fangsuo.
11
12On the CMA allocation path, isolate_migratepages_range() could isolate
13unevictable LRU pages and reclaim_clean_page_from_list() can try to
14reclaim them if they are clean file-backed pages.
15
16 page:ffffffbf02f33b40 count:86 mapcount:84 mapping:ffffffc08fa7a810 index:0x24
17 flags: 0x19040c(referenced|uptodate|arch_1|mappedtodisk|unevictable|mlocked)
18 raw: 000000000019040c ffffffc08fa7a810 0000000000000024 0000005600000053
19 raw: ffffffc009b05b20 ffffffc009b05b20 0000000000000000 ffffffc09bf3ee80
20 page dumped because: VM_BUG_ON_PAGE(PageLRU(page) || PageUnevictable(page))
21 page->mem_cgroup:ffffffc09bf3ee80
22 ------------[ cut here ]------------
23 kernel BUG at /home/build/farmland/adroid9.0/kernel/linux/mm/vmscan.c:1350!
24 Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
25 Modules linked in:
26 CPU: 0 PID: 7125 Comm: syz-executor Tainted: G S 4.14.81 #3
27 Hardware name: ASR AQUILAC EVB (DT)
28 task: ffffffc00a54cd00 task.stack: ffffffc009b00000
29 PC is at shrink_page_list+0x1998/0x3240
30 LR is at shrink_page_list+0x1998/0x3240
31 pc : [<ffffff90083a2158>] lr : [<ffffff90083a2158>] pstate: 60400045
32 sp : ffffffc009b05940
33 ..
34 shrink_page_list+0x1998/0x3240
35 reclaim_clean_pages_from_list+0x3c0/0x4f0
36 alloc_contig_range+0x3bc/0x650
37 cma_alloc+0x214/0x668
38 ion_cma_allocate+0x98/0x1d8
39 ion_alloc+0x200/0x7e0
40 ion_ioctl+0x18c/0x378
41 do_vfs_ioctl+0x17c/0x1780
42 SyS_ioctl+0xac/0xc0
43
44Wu found it's due to commit ad6b67041a45 ("mm: remove SWAP_MLOCK in
45ttu"). Before that, unevictable pages go to cull_mlocked so that we
46can't reach the VM_BUG_ON_PAGE line.
47
48To fix the issue, this patch filters out unevictable LRU pages from the
49reclaim_clean_pages_from_list in CMA.
50
51Link: http://lkml.kernel.org/r/20190524071114.74202-1-minchan@kernel.org
52Fixes: ad6b67041a45 ("mm: remove SWAP_MLOCK in ttu")
53Signed-off-by: Minchan Kim <minchan@kernel.org>
54Reported-by: Wu Fangsuo <fangsuowu@asrmicro.com>
55Debugged-by: Wu Fangsuo <fangsuowu@asrmicro.com>
56Tested-by: Wu Fangsuo <fangsuowu@asrmicro.com>
57Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
58Acked-by: Michal Hocko <mhocko@suse.com>
59Cc: Pankaj Suryawanshi <pankaj.suryawanshi@einfochips.com>
60Cc: <stable@vger.kernel.org> [4.12+]
61Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
62Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
63Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
64
65---
66 mm/vmscan.c | 2 +-
67 1 file changed, 1 insertion(+), 1 deletion(-)
68
69--- a/mm/vmscan.c
70+++ b/mm/vmscan.c
71@@ -1393,7 +1393,7 @@ unsigned long reclaim_clean_pages_from_l
72
73 list_for_each_entry_safe(page, next, page_list, lru) {
74 if (page_is_file_cache(page) && !PageDirty(page) &&
75- !__PageMovable(page)) {
76+ !__PageMovable(page) && !PageUnevictable(page)) {
77 ClearPageActive(page);
78 list_move(&page->lru, &clean_pages);
79 }