Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1839530pxk; Tue, 1 Sep 2020 09:01:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7Fsgc97r2aWcaQKZpFxrpcviHrCigKYO+EwD6aOPNGUBbZMoG8X5MxQvrNgk/Jbrl6Qci X-Received: by 2002:a05:6402:3075:: with SMTP id bs21mr2396838edb.236.1598976077447; Tue, 01 Sep 2020 09:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598976077; cv=none; d=google.com; s=arc-20160816; b=NayD3RGO0iDh/NY7C8ID8RH2PVFt7FKe1flnrOBWyUXIyU1xFMuNpYDRHrA/QWlMwZ JtmcqrHN2hCuHLgMfDtccjHD/zpuTbJOE6GvDnGUiVad7T44hmxukU6qVQ0zgwYqsuRk 4RrtN3vxo1Qda3/UCxCUdTsmRvhtouwkpipZNBUnilwJjEQiHwdNqQvnuKDKjjhctias Y/XQYdXpP94/MDFDUZ70peftluagUh0blZGpg6btzefYP03Wan18EAvFwmhQ23kwXMdR NaMx/wNParcDqh3fGO+RuThJvGU/k+c1H3b7NuKoDSm/WOlX0SyJA8bTYp3K85ktAkKO 0Z9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ja1Ngj7NH47x40mFJlmmy6/fspeTMYwfVXDFlvDZIns=; b=KFcyF3ginLLvjNGRVRKxhf+kOD3XKTPu+BMWLHQolTQd6uyBbxzEmqCamlSdXEThXV LTcWye+gn/kWe2BXNWBj+M8+xbtA2MhuL3lyG0ug6lChajoDkgcPamPn/89YHTEzZRjE XDu+HhgLBr6S3/hI96cBcpd9PCRgZoFVPukJXAc6mhpT++wsQ48zk5jAAR2YIqLxC5Jq qGhKkHw1KF+9fXAaYi3t53dyW5PhIZPd4gK8wkPXwpwMJVDfZv6XBKYivbfC0w9nGekN d55ylmlMhnzygTVkvlKF6Ns7deQ1qop/HIGCYYcaeaPYS+/6RwKhX7fdW0gmDgrE3LeA zjxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="R5Ah/xy7"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb13si989624edb.446.2020.09.01.09.00.52; Tue, 01 Sep 2020 09:01:17 -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=@gmail.com header.s=20161025 header.b="R5Ah/xy7"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731259AbgIAP5h (ORCPT + 99 others); Tue, 1 Sep 2020 11:57:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731507AbgIAP5a (ORCPT ); Tue, 1 Sep 2020 11:57:30 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1F38C061244 for ; Tue, 1 Sep 2020 08:57:28 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id i26so2361405ejb.12 for ; Tue, 01 Sep 2020 08:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ja1Ngj7NH47x40mFJlmmy6/fspeTMYwfVXDFlvDZIns=; b=R5Ah/xy7z0CYa/cOPWoKydl55+5AZx0X0xQJSi7oXsefEDGnUWoEmUvrBgHDB6qi9M /0BqPFsX1uD16ZqQrlqlFY/brxotDPaHIoOx5hvvLGC7lSE/Rn1VXNwev5SZpYADEWZW xGNROhES6O3tp7K9FtFb1rbn1WTcgV36Lmdx4vC4Z9L++ntjEsM9CkS30Xkv7gD8IL23 xj71aaX3htYZQSlf+C1O1oREaf7eGZp+A5SifAfa3S5foT+pHlv7zElngZUgc2r/DNbI 3ceu3otruVt5OiOnce89EX+sGUkJIuxUfOEGdYo8PjqYYHV/c0UHcQUPFJI8vhhJiyUW Uyvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ja1Ngj7NH47x40mFJlmmy6/fspeTMYwfVXDFlvDZIns=; b=PhXA+m9Yy3s282lhu/WpyNXMLv88oBE0fw0WiezpZAu1zA752w6MGeYeYv+kQBCu5C SBjN/D2Cwpi2fdH2v3zZ6xsmJ+2lajHHg5U6lfLQ/Kg/gFEeeauohUBE6wfTtaOZ+bCa GrU5pIP0VwFdnDoMQs/6gbtYM34pMjK7me0xxOIGbTraNDWiUl2Xgphc2Hln1x48GT2O 9cXXVxA/rG12JAqBPzH8YoVmMpdTiS7hjSNQYI7A7H9uA2PZTv+SRsczDWFrFnpL178x jp8/m3mj0KBJWuxaIElc4IMRuFcTve61soqaLZdrehIQBDi2T70p+iYUFFF8wWVKlteH 9cEw== X-Gm-Message-State: AOAM533e+xXXZBhZRfi/bB1XNR0woJrC+nflWq/LUgsDBVfSllRMweJW EZT9H6fpRDUyya5VWnErwDjcAVhgxrEfVhtg36I= X-Received: by 2002:a17:906:edd6:: with SMTP id sb22mr1911092ejb.499.1598975847689; Tue, 01 Sep 2020 08:57:27 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yang Shi Date: Tue, 1 Sep 2020 08:57:15 -0700 Message-ID: Subject: Re: [PATCH 4/5] mm: fix check_move_unevictable_pages() on THP To: Hugh Dickins Cc: Andrew Morton , Alex Shi , Johannes Weiner , Michal Hocko , Mike Kravetz , Shakeel Butt , Matthew Wilcox , Qian Cai , Chris Wilson , Kuo-Hsin Yang , Linux Kernel Mailing List , Linux MM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 30, 2020 at 2:08 PM Hugh Dickins wrote: > > 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 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; > } > } > >