From patchwork Sun Aug 30 21:08:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 11745335 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 AAC4614E5 for ; Sun, 30 Aug 2020 21:08:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 745B02083E for ; Sun, 30 Aug 2020 21:08:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="c4OqQCxX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 745B02083E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AEA396B0002; Sun, 30 Aug 2020 17:08:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A9A396B0003; Sun, 30 Aug 2020 17:08:21 -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 98A336B0005; Sun, 30 Aug 2020 17:08:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id 810986B0002 for ; Sun, 30 Aug 2020 17:08:21 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 442A4180AD815 for ; Sun, 30 Aug 2020 21:08:21 +0000 (UTC) X-FDA: 77208473202.17.war31_600def32708a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 16172180D0180 for ; Sun, 30 Aug 2020 21:08:21 +0000 (UTC) X-Spam-Summary: 1,0,0,0ff3d1fdf091adef,d41d8cd98f00b204,hughd@google.com,,RULES_HIT:41:355:379:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:2895:2898:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:6261:6653:6742:7903:8957:10004:10400:11026:11232:11658:11914:12043:12114:12296:12297:12438:12517:12519:12555:12679:12740:12895:12986:13161:13229:13439:14093:14097:14181:14394:14659:14721:21060:21063:21080:21444:21450:21451:21627:21796:21939:21987:30034:30036:30054:30056:30070:30090,0,RBL:209.85.167.193:@google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yr8e865wz8ymowep73c898u11edoc14rhxdf65a1b1t9ykfm98xg11uj3kix3.166ttzmkxeozbzn4t8iutdxd7kr4g7t5qjes7yee9f7xsea7baafkqcdogq1etx.g-lbl8.mailshell.net-223.238.255.100,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_S UMMARY:n X-HE-Tag: war31_600def32708a X-Filterd-Recvd-Size: 5672 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Sun, 30 Aug 2020 21:08:20 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id k4so5503438oik.2 for ; Sun, 30 Aug 2020 14:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=SQ10D8PXryeEKHHcl5IvJgd6P48aMcyJPD1+SoD+oOw=; b=c4OqQCxXIwZCv3JjpmkYk1C/CeDsSc970MD8kj38easVa+rgeXjtnreeKAvbX5dnN9 d2uuNuM4vPcJmTcVou5fUb4QsSDGIo0I3jzh7ZNG+qN6GK/hSQ+UkqXT4pYaGthcv1VY 89WTQRrQljR99h7ywkXXy3vo2t9LlTpEqqRthmrCKuytS4dvmws+u25TJBxt6AwCfwvX bT4yk0N1mRAjDTukMmYU2jHo7PXwaeoqAUCooMsaalgiXLhzYKEMF9PsTlbNZOGJBrAa PFUs3sGOo/dZLqlr4+danZhsgj+kTFIxVg381SJZ22wuz518PSM0dkFR3E6QF7kOlmHp TUfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=SQ10D8PXryeEKHHcl5IvJgd6P48aMcyJPD1+SoD+oOw=; b=UtdV8WTKR0hmXKHBetKzwH5rWvmJZnaq20FgXY5oNaDRJ1eebWphcHnPAifKIw6GIe EotBCq9fsHWk6u5dpCkLu95Xmn723vp6Gu72XVrSvn/g24WVjmpgGUcwp85eqw4H7WZY qGOWwBYyjWfPu74rlxfL1PLUZQQdFT9HiyeGlpdOQtTAjXXnpltMXG1AcsNjmGF9qZ0B S1Ik/Zjf6ZE9x3HdUqVuGbZ8N0IP4sKQwpQhZkRUAu6dEA4iixDf3cOiJk2L+g/Gvm+X 8kR4HutLx6rTLeriUEUcRT4liN0q7yj8v1dN+o2hRXY67d1Va77aC7t9VLW/Z4U4eCNV AmyA== X-Gm-Message-State: AOAM531r9G5x/xTJvwy4ttS+uRqjLgKU9DmRTu3jvtWav2dEoQ7PDYyu 3agDje7uk6A3Tj1Co05gTlMDhw== X-Google-Smtp-Source: ABdhPJxF1SCIvzAbelWpBIoB9i54xpvq6aZj7/FIsSEv2EFOm/IpDLQv50VMevxq6JU/ORrsgv5lJQ== X-Received: by 2002:aca:fc85:: with SMTP id a127mr1801672oii.148.1598821699723; Sun, 30 Aug 2020 14:08:19 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 63sm1408348ooj.32.2020.08.30.14.08.17 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Sun, 30 Aug 2020 14:08:18 -0700 (PDT) Date: Sun, 30 Aug 2020 14:08:16 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Alex Shi , 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 Subject: [PATCH 4/5] mm: fix check_move_unevictable_pages() on THP In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 X-Rspamd-Queue-Id: 16172180D0180 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: 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 Reviewed-by: Shakeel Butt Acked-by: Yang Shi --- 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); - pgrescued++; + pgrescued += nr_pages; } }