Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1396727pxk; Mon, 31 Aug 2020 19:08:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynDCUcngjcH2jR0tBlqtS/dDHsxQdtt55aQ5vbY/WmA4SPUa2C3h5lOOik7fYnmtGADRlj X-Received: by 2002:a17:906:b210:: with SMTP id p16mr3454218ejz.312.1598926112741; Mon, 31 Aug 2020 19:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598926112; cv=none; d=google.com; s=arc-20160816; b=kvSf75mQsYLbJZuQgKKCg6USVFOmRvahpmEOfGOx9ifcPUIHPrttRrXbxbBaGYGsEz kDVRNjay1dMulaLC7Urgl2+NLUF1mtN2ZQVoFAgI/Fn/pXxRGPw8eSW6KDrByWwBSYwz 5tvm/0rfNEkJWwF4LMlE/hJk/xmNqh9jJHk3iWZnRCH2wl+PwyTHEu0iOw5wx9Gg2m3T ocgvJ8KXd60o/6pueedlArjO4yhj0C7ScuKBMUtMMTYNzgxafz0F41lkwpSuLzkRNPwm lWxbaTBxLTeMy+FqKV+THKKoZ817H2ZjXbPWWU+5fo6B3KpabR+eRilq5GROe73AK8Sb 0b1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=QXO9hHIMJFnbwqlM4rY/gXIlBaxoWUh3q73TgG4MMp8=; b=DM8Kax7mk00g/a9x9Cm/dG5AYrIop2iI5inG4v/+Fbpq0fKgYhKcSYfls9aqpYKqy9 c8JMDakSeBpbgY9r0WImbdwPwoK0pbfKcYEOgYukmcBzK7nvn/CimkcKxo7/803SJAHO lR3ai4U0W83szDjLU40hBW1In5fV215gRvAwCvUJr+0rbNAVFb2Vpy7v1xHC6n3wqFv/ joYTKvC8mfAkjqlQaKe7w1i3P4XlXjWGEDRWVjbIh24TMK0qg6Zwf2LWjgCM94zfxCDy VaxodGFC2hFjwDKFJQKTLrB7g9qSw73FTXS6LTZdIpAZM5WRGcrqo+pYVQFsKKx20CtP XiLg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u16si5661788edb.359.2020.08.31.19.08.06; Mon, 31 Aug 2020 19:08:32 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726074AbgIACEU (ORCPT + 99 others); Mon, 31 Aug 2020 22:04:20 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:54564 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726020AbgIACET (ORCPT ); Mon, 31 Aug 2020 22:04:19 -0400 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2020/8/31 ????5:08, Hugh Dickins ะด??: > check_move_unevictable_pages() is used in making unevictable shmem pages > evictable: by shmem_unlock_mapping(), drm_gem_check_release_pagevec() and > i915/gem check_release_pagevec(). Those may pass down subpages of a huge > page, when /sys/kernel/mm/transparent_hugepage/shmem_enabled is "force". > > 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). > > 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. > > 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. > > 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. > > 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. > > mm/vmscan.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > --- 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 = 0; i < pvec->nr; i++) { > struct page *page = pvec->pages[i]; > struct pglist_data *pagepgdat = page_pgdat(page); > + int nr_pages; > + > + if (PageTransTail(page)) > + continue; > + > + nr_pages = thp_nr_pages(page); > + pgscanned += nr_pages; > > - pgscanned++; > if (pagepgdat != 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 += nr_pages; > } > } > >