Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp911803ybz; Wed, 15 Apr 2020 22:19:38 -0700 (PDT) X-Google-Smtp-Source: APiQypI9QPmlKTQ8X1YE3wNNukYYQG49Z9MnI900zdVQOKiQOYbCya5TorOsjbt3eSoEf0LZJkf0 X-Received: by 2002:a17:906:2f03:: with SMTP id v3mr7980274eji.105.1587014378537; Wed, 15 Apr 2020 22:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587014378; cv=none; d=google.com; s=arc-20160816; b=FyEWqqqhwwZ1kMF9BTaIHzyTvRjhAil2RTm00ENdaXLGEqMQ2vSex56ri+zFa+6/qa LisP7qyDVXKiB/5DnLz+DToLB8Qzre/UgLmFm2XzG6pLzu/wA+l1rH1Z2yxx1iGOUeFV J0YAGnltAJY8pFbMGxyqpUgu2yvQ64bOm5vn9q4nfqXM11GMlU9qdy7e0xO5c92dF1UV E59NHXqOXi9EUmArPkopJD0hwZXPEwq/uL4hni9WaBFxk7ZLBCori3/SiCSVGyf2zgDX ssFD23iJIbRJHs07ZCx/U/Tlt7Df1kX2U5WZq7dLiXjT2PVZzfO2NqmskyXBgYEOBLeX BKfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter; bh=JjHChKzGJY+Pr+qRpva3bX9JQbfmcsF9pYyB07kf9Ks=; b=I4+CJtkRKXx//D54d6sR7zuarGVlPa76m60GMle1T2qiBFEPGSYza+2+OsrGvzE5oL tc4q2U9GltEMQs2R26L0EXBd79GAYze33NnORsvvx7ROOvC0WWFDs5G+Tkn9oh1HGqBV brCqaF+QKJEcW0FwowrWpgdY/NRtbHZmSGzCHV6i3S0LpazLfm/chGosxfWnnT6dr1cj 27r2O5vxiqr91T205hTg5inFDzKn1rHGn0sEXc7Bg/nrbqTRerTty1+w8x1SSqhc7NMj tWoA0ueeJB3XYAVEpp5OZ6/WPZX7dwjgwVFJASaPJ3b3//WgFX0d501ZDuCsitDb0fvC HTJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="Cp/Nxb6w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a72si12244234edf.28.2020.04.15.22.19.13; Wed, 15 Apr 2020 22:19:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="Cp/Nxb6w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406223AbgDPFSI (ORCPT + 99 others); Thu, 16 Apr 2020 01:18:08 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:19159 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405531AbgDPFSD (ORCPT ); Thu, 16 Apr 2020 01:18:03 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200416051758epoutp04ff9c12e36ca3d767307832ebafdd41ae~GNRQEwPYn1856618566epoutp04U for ; Thu, 16 Apr 2020 05:17:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200416051758epoutp04ff9c12e36ca3d767307832ebafdd41ae~GNRQEwPYn1856618566epoutp04U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1587014278; bh=JjHChKzGJY+Pr+qRpva3bX9JQbfmcsF9pYyB07kf9Ks=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=Cp/Nxb6whZqS0+nBOOOKiPC7l7wmPas3qyX6FFgvNbFmtsYrBoPcC7OBc8DXGHoOi 0lxIEbEPYQJj+wFxeYu0ylwsjjZxhaK40ebbmGBkZNgN9PLB4Juu/gvX3HZcCHAQzy WlRE5BtXQG02EmWndK1/Haoz7IvQ62h8pnFUsMDI= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20200416051758epcas1p29ca8461ac8318c4fc6c7360a77ca64f2~GNRPqI-N91700117001epcas1p23; Thu, 16 Apr 2020 05:17:58 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.40.159]) by epsnrtp4.localdomain (Postfix) with ESMTP id 492nYK272WzMqYkk; Thu, 16 Apr 2020 05:17:57 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id 90.2D.04648.58AE79E5; Thu, 16 Apr 2020 14:17:57 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20200416051756epcas1p37b66d9feeb0cc5631a78ff7ec71d5e83~GNROSCCCF2145221452epcas1p36; Thu, 16 Apr 2020 05:17:56 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200416051756epsmtrp224d7921d5e52f120b8592f5b77a83f01~GNRORReiu0159501595epsmtrp2C; Thu, 16 Apr 2020 05:17:56 +0000 (GMT) X-AuditID: b6c32a37-1f3ff70000001228-98-5e97ea85f560 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id F3.E3.04158.48AE79E5; Thu, 16 Apr 2020 14:17:56 +0900 (KST) Received: from [10.253.104.82] (unknown [10.253.104.82]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200416051756epsmtip2311bd26cacc910e230800d3f7a1546ee~GNRN_Rkn10259202592epsmtip2M; Thu, 16 Apr 2020 05:17:56 +0000 (GMT) Subject: Re: [PATCH] mm/vmscan: skip layzfree page on reclaim_clean_pages_from_list 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 From: Jaewon Kim Message-ID: <5E97EA84.8040303@samsung.com> Date: Thu, 16 Apr 2020 14:17:56 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <20200416033514.6366-1-jaewon31.kim@samsung.com> Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDJsWRmVeSWpSXmKPExsWy7bCmvm7rq+lxBvdW81vMWb+GzaJ780xG i8u75rBZ3Fvzn9Vi7ZG77BaT3z1jtFhwvIXVYtnX9+wWf6+sZ7F4vJ7bgctj56y77B6bVnWy eWz6NInd48SM3ywe6/68YvJ4v+8qm0ffllWMHptPV3t83iQXwBmVY5ORmpiSWqSQmpecn5KZ l26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+TiE6DrlpkDdKeSQlliTilQKCCxuFhJ386mKL+0 JFUhI7+4xFYptSAlp8DQoECvODG3uDQvXS85P9fK0MDAyBSoMiEn4/DrV2wF8yUrnm6NamD8 LtLFyMkhIWAicarnOWsXIxeHkMAORok9t+8xQzifGCU6jx9mgnC+MUq0LOxmhWnZd/43VGIv o8T0mZdYQBJCAm8ZJbrn84PYwg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S7xdMYgWxeQW0JD7+PswCYrMIqEo0318GZosKREisXneNGaJGUOLkzCdgcU4BW4lL e+9CzVSX+DPvEjOELS/RvHU28wRGwVlIWmYhKZuFpGwBI/MqRsnUguLc9NxiwwKjvNRyveLE 3OLSvHS95PzcTYzgSNLS2sF44kT8IUYBDkYlHt6O19PihFgTy4orcw8xSnAwK4nw7vCfHifE m5JYWZValB9fVJqTWnyIUZqDRUmcVz7/WKSQQHpiSWp2ampBahFMlomDU6qBUShp+fec2syA PQorP9bcTXjNKpmvHbNVKNv3cqEEW9JX9msqMn4B8wRvTbrvoXNrhqKkUNiTrMP/GeqiHums 2XDk5rZjuQzGd77t2bzgeP2No7+17hSKPf6bf4p5u29Lanq63SNDnU9PfmxelLtGQc116aKs /9UBL7sWLDr7OUfEmLMm6MZCNyWW4oxEQy3mouJEANfIwh6gAgAA X-CMS-MailID: 20200416051756epcas1p37b66d9feeb0cc5631a78ff7ec71d5e83 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200416033543epcas1p2b256bef770bb1310a9bf62bda80a976a References: <20200416033514.6366-1-jaewon31.kim@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020년 04월 16일 12:35, Jaewon Kim wrote: > 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 Sorry, I think I pointed a wrong commit, the SwapBacked was recovered by commit 802a3a92ad7a ("mm: reclaim MADV_FREE pages"). > 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);