From patchwork Thu Apr 16 03:35:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 11492225 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D89F81 for ; Thu, 16 Apr 2020 03:35:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD83E2072D for ; Thu, 16 Apr 2020 03:35:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Rh6nALOY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD83E2072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E17C18E0077; Wed, 15 Apr 2020 23:35:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DC89F8E0001; Wed, 15 Apr 2020 23:35:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C68F88E0077; Wed, 15 Apr 2020 23:35:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id AE70B8E0001 for ; Wed, 15 Apr 2020 23:35:50 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 760132C93 for ; Thu, 16 Apr 2020 03:35:50 +0000 (UTC) X-FDA: 76712304060.20.look27_15b7a71f16a63 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jaewon31.kim@samsung.com,,RULES_HIT:30012:30054:30070,0,RBL:203.254.224.34:@samsung.com:.lbl8.mailshell.net-62.18.1.2 64.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: look27_15b7a71f16a63 X-Filterd-Recvd-Size: 8491 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Apr 2020 03:35:49 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200416033545epoutp0435bbf531a015723b25b8d54f82ae7746~GL4AJljaO2988629886epoutp04N for ; Thu, 16 Apr 2020 03:35:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200416033545epoutp0435bbf531a015723b25b8d54f82ae7746~GL4AJljaO2988629886epoutp04N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1587008145; bh=yWL2MFhV8L3OokKgPk9AaY1d1laWT5u9vlv+KNP6WrQ=; h=From:To:Cc:Subject:Date:References:From; b=Rh6nALOY37FqhyG+kGvlee7yuTbmHcxa4qoD5gwm1XbyvAf+KIwy0+2I/aimRaC+m 1Z62vOltadRramR+reMI4/vODNhuvtNOxT75NZRw+aU9ySMLuJzI/3xe2UxSBYeAI5 C+hTqmfaqiBLFbwmlYnRP+5g3/woX9M6DF+S0nug= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20200416033545epcas1p332be81e5610fcc56866971beec7c4049~GL3-sc_xq1083310833epcas1p3P; Thu, 16 Apr 2020 03:35:45 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.159]) by epsnrtp1.localdomain (Postfix) with ESMTP id 492lHN0QgzzMqYlm; Thu, 16 Apr 2020 03:35:44 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id AB.77.04402.F82D79E5; Thu, 16 Apr 2020 12:35:43 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200416033543epcas1p2b256bef770bb1310a9bf62bda80a976a~GL3_HNYXG0184601846epcas1p2T; Thu, 16 Apr 2020 03:35:43 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200416033543epsmtrp17852f07d8d0bdc6afb12cb19348bea55~GL3_GS-NO2924629246epsmtrp1x; Thu, 16 Apr 2020 03:35:43 +0000 (GMT) X-AuditID: b6c32a35-76bff70000001132-54-5e97d28f4d77 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A6.4D.04024.F82D79E5; Thu, 16 Apr 2020 12:35:43 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200416033543epsmtip23022a73905f0710cb316026c6ce786fd~GL398wvwF0615006150epsmtip2A; Thu, 16 Apr 2020 03:35:43 +0000 (GMT) From: Jaewon Kim To: minchan@kernel.org, mgorman@suse.de, m.szyprowski@samsung.com, mina86@mina86.com, riel@redhat.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, ytk.lee@samsung.com, Jaewon Kim Subject: [PATCH] mm/vmscan: skip layzfree page on reclaim_clean_pages_from_list Date: Thu, 16 Apr 2020 12:35:14 +0900 Message-Id: <20200416033514.6366-1-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GdFrClUm1SvuWc6ePY3/oGVwjZva87/B2UueXLV+cf3wz926uyatVfux4NvunT01 TQu+J9hcOn9ciaU4I9FQi7moOBEAw3QLNZcDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrALMWRmVeSWpSXmKPExsWy7bCSvG7/pelxBqemSFjMWb+GzaJ780xG i973r5gsLu+aw2Zxb81/Vou1R+6yW0x+94zRYsHxFlaLZV/fs1v8vbKexeLxem4Hbo+ds+6y e2xa1cnmsenTJHaPEzN+s3is+/OKyeP9vqtsHn1bVjF6bD5d7fF5k1wAZxSXTUpqTmZZapG+ XQJXxurv/1gKesQrej8ENDBuFO5i5OSQEDCROPL5FUsXIxeHkMBuRomWi8eYIRIyEm/OPwVK cADZwhKHDxdD1HxllJjxeCcTSA2bgLbE+wWTWEESIgJdjBIbrs8Hc5gFJjBKHJ84nRWkW1jA X2L/fxuQBhYBVYmDm/6wgti8AjYSJ27MZYZYIC+x8D/zBEaeBYwMqxglUwuKc9Nziw0LDPNS y/WKE3OLS/PS9ZLzczcxgsNRS3MH4+Ul8YcYBTgYlXh4DV5OixNiTSwrrsw9xCjBwawkwrvD f3qcEG9KYmVValF+fFFpTmrxIUZpDhYlcd6neccihQTSE0tSs1NTC1KLYLJMHJxSDYz9My/4 iysuv7lybtYFG8fCdQx8a1c5dq8Ut+w7U/T57mGu/6ZPfgbw+974obrP7Y54+qlb84PMDxc2 qRx/WqLaa8sY8X5+2LOAxEdTUtQ/FT9bbv/talXM0/8Ke5r2hlfPVa/ePOfeRfvZQTGPlvU/ UWhZdiH29IvvfFN8ru7oeFiqH6pyIWurEktxRqKhFnNRcSIAfs62qEMCAAA= X-CMS-MailID: 20200416033543epcas1p2b256bef770bb1310a9bf62bda80a976a X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200416033543epcas1p2b256bef770bb1310a9bf62bda80a976a References: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This patch fix nr_isolate_* mismatch problem between cma and dirty lazyfree page. If try_to_unmap_one is used for reclaim and it detects a dirty lazyfree page, then the lazyfree page is changed to a normal anon page having SwapBacked by commit 18863d3a3f59 ("mm: remove SWAP_DIRTY in ttu"). Even with the change, reclaim context correctly counts isolated files because it uses is_file_lru to distinguish file. And the change to anon is not happened if try_to_unmap_one is used for migration. So migration context like compaction also correctly counts isolated files even though it uses page_is_file_lru insted of is_file_lru. Recently page_is_file_cache was renamed to page_is_file_lru by commit 9de4f22a60f7 ("mm: code cleanup for MADV_FREE"). But the nr_isolate_* mismatch problem happens on cma alloc. There is reclaim_clean_pages_from_list which is being used only by cma. It was introduced by commit 02c6de8d757c ("mm: cma: discard clean pages during contiguous allocation instead of migration") to reclaim clean file pages without migration. The cma alloc uses both reclaim_clean_pages_from_list and migrate_pages, and it uses page_is_file_lru to count isolated files. If there are dirty lazyfree pages allocated from cma memory region, the pages are counted as isolated file at the beginging but are counted as isolated anon after finished. Mem-Info: Node 0 active_anon:3045904kB inactive_anon:611448kB active_file:14892kB inactive_file:205636kB unevictable:10416kB isolated(anon):0kB isolated(file):37664kB mapped:630216kB dirty:384kB writeback:0kB shmem:42576kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no Like log above, there was too much isolated file, 37664kB, which triggers too_many_isolated in reclaim when there is no isolated file in system wide. It could be reproducible by running two programs, doing MADV_FREE, writing and doing cma alloc, respectively. Although isolated anon is 0, I found that the internal value of isolated anon was the negative value of isolated file. Fix this by skipping anon pages on reclaim_clean_pages_from_list. The lazyfree page can be checked by both PageAnon(page) and page_is_file_lru. But in this case, PageAnon is enough to skip all anon pages. Reported-by: Yong-Taek Lee Signed-off-by: Jaewon Kim --- mm/vmscan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index b06868fc4926..9380a18eef5e 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1497,6 +1497,9 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone, LIST_HEAD(clean_pages); list_for_each_entry_safe(page, next, page_list, lru) { + /* to avoid race with MADV_FREE anon page */ + if (PageAnon(page)) + continue; if (page_is_file_lru(page) && !PageDirty(page) && !__PageMovable(page) && !PageUnevictable(page)) { ClearPageActive(page);