From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF399C433E2 for ; Tue, 1 Sep 2020 02:04:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A5E6D208DB for ; Tue, 1 Sep 2020 02:04:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5E6D208DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 28B756B0003; Mon, 31 Aug 2020 22:04:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23CF26B0037; Mon, 31 Aug 2020 22:04:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 151F56B0055; Mon, 31 Aug 2020 22:04:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id F0F3B6B0003 for ; Mon, 31 Aug 2020 22:04:21 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B0C26824556B for ; Tue, 1 Sep 2020 02:04:21 +0000 (UTC) X-FDA: 77212847922.06.guide34_63064ca27094 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 7DE9B100410C9 for ; Tue, 1 Sep 2020 02:04:21 +0000 (UTC) X-HE-Tag: guide34_63064ca27094 X-Filterd-Recvd-Size: 4287 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 02:04:18 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01358;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0U7TxlIk_1598925854; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U7TxlIk_1598925854) by smtp.aliyun-inc.com(127.0.0.1); Tue, 01 Sep 2020 10:04:15 +0800 Subject: Re: [PATCH 4/5] mm: fix check_move_unevictable_pages() on THP To: Hugh Dickins , Andrew Morton Cc: Johannes Weiner , Michal Hocko , Mike Kravetz , Shakeel Butt , Matthew Wilcox , Qian Cai , Chris Wilson , Kuo-Hsin Yang , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: From: Alex Shi Message-ID: <5875bdbe-c1af-737b-9ec2-4b48b3c2465f@linux.alibaba.com> Date: Tue, 1 Sep 2020 10:04:13 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk X-Rspamd-Queue-Id: 7DE9B100410C9 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable 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: =D4=DA 2020/8/31 =C9=CF=CE=E75:08, Hugh Dickins =D0=B4=B5=C0: > check_move_unevictable_pages() is used in making unevictable shmem page= s > evictable: by shmem_unlock_mapping(), drm_gem_check_release_pagevec() a= nd > i915/gem check_release_pagevec(). Those may pass down subpages of a hu= ge > page, when /sys/kernel/mm/transparent_hugepage/shmem_enabled is "force"= . >=20 > That does not crash or warn at present, but the accounting of vmstats > unevictable_pgs_scanned and unevictable_pgs_rescued is inconsistent: > scanned being incremented on each subpage, rescued only on the head > (since tails already appear evictable once the head has been updated). >=20 > 5.8 commit 5d91f31faf8e ("mm: swap: fix vmstats for huge page") has > established that vm_events in general (and unevictable_pgs_rescued in > particular) should count every subpage: so follow that precedent here. >=20 > Do this in such a way that if mem_cgroup_page_lruvec() is made stricter > (to check page->mem_cgroup is always set), no problem: skip the tails > before calling it, and add thp_nr_pages() to vmstats on the head. >=20 > Signed-off-by: Hugh Dickins > --- > Nothing here worth going to stable, since it's just a testing config > that is fixed, whose event numbers are not very important; but this > will be needed before Alex Shi's warning, and might as well go in now. >=20 > The callers of check_move_unevictable_pages() could be optimized, > to skip over tails: but Matthew Wilcox has other changes in flight > there, so let's skip the optimization for now. >=20 > mm/vmscan.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) >=20 > --- 5.9-rc2/mm/vmscan.c 2020-08-16 17:32:50.721507348 -0700 > +++ linux/mm/vmscan.c 2020-08-28 17:47:10.595580876 -0700 > @@ -4260,8 +4260,14 @@ void check_move_unevictable_pages(struct > for (i =3D 0; i < pvec->nr; i++) { > struct page *page =3D pvec->pages[i]; > struct pglist_data *pagepgdat =3D page_pgdat(page); > + int nr_pages; > + > + if (PageTransTail(page)) > + continue; > + > + nr_pages =3D thp_nr_pages(page); > + pgscanned +=3D nr_pages; > =20 > - pgscanned++; > if (pagepgdat !=3D pgdat) { > if (pgdat) > spin_unlock_irq(&pgdat->lru_lock); > @@ -4280,7 +4286,7 @@ void check_move_unevictable_pages(struct > ClearPageUnevictable(page); > del_page_from_lru_list(page, lruvec, LRU_UNEVICTABLE); > add_page_to_lru_list(page, lruvec, lru); So, we might randomly del or add a thp tail page into lru? It's interesting to know here. :) Thanks Alex > - pgrescued++; > + pgrescued +=3D nr_pages; > } > } > =20 >=20