From patchwork Mon Sep 28 17:54:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 11804483 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 896D56CA for ; Mon, 28 Sep 2020 17:56:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 41B9C221E7 for ; Mon, 28 Sep 2020 17:56:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sent.com header.i=@sent.com header.b="MVxKSB4G"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Qv2pOgr/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41B9C221E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 11273900018; Mon, 28 Sep 2020 13:55:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 04CDE90000D; Mon, 28 Sep 2020 13:55:29 -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 E110E900019; Mon, 28 Sep 2020 13:55:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id C790E900018 for ; Mon, 28 Sep 2020 13:55:29 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8B1561E02 for ; Mon, 28 Sep 2020 17:55:29 +0000 (UTC) X-FDA: 77313222378.20.pump03_5e16cc727183 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 61645180C07A3 for ; Mon, 28 Sep 2020 17:55:29 +0000 (UTC) X-Spam-Summary: 1,0,0,7b9e5fca5846e363,d41d8cd98f00b204,zi.yan@sent.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1535:1543:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:3138:3139:3140:3141:3142:3354:3867:3871:3872:3874:4118:4321:4385:4605:5007:6117:6119:6120:6261:6653:6742:7576:7875:7901:8957:9592:10004:11026:11473:11658:11914:12043:12291:12296:12438:12555:12679:12683:12895:12986:13894:14096:14110:14181:14721:21080:21627:21990:30054:30064,0,RBL:64.147.123.17:@sent.com:.lbl8.mailshell.net-62.18.0.100 64.100.201.100;04yfgb3tjz8gsjay6fknq9azwcs17yc5g67oifmshzs6miunc9xmhmxgfs3ocok.zjh96e1kees41ibsu87oazkjtt3ednsu3oomurh6aj6gyi3mmq4gm5cfog6ifpi.h-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:22,LUA_SUMMARY:none X-HE-Tag: pump03_5e16cc727183 X-Filterd-Recvd-Size: 7565 Received: from wnew3-smtp.messagingengine.com (wnew3-smtp.messagingengine.com [64.147.123.17]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Mon, 28 Sep 2020 17:55:28 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id BB344EA0; Mon, 28 Sep 2020 13:55:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 28 Sep 2020 13:55:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=from :to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; s=fm1; bh=n6jp16hT4oTH1 dxVIOY600H59pcJD1Ay2zwRoDXWqKs=; b=MVxKSB4GH5gmkQT5B/PviITHQj+X5 iQhMIQQGBGQqOH14ZUf8fjssIBRB8fPKYaJsoyu1TbzJW0SY83g2r+pIQHbG2j8L 2VIkFQUPYRw37yia2BZPJvEB3o6Q6KRJkDB0B47a+U95sechbkVDhN5uQwtjPc87 vePnt9Yw08q84BLbZSXbt2fG1hcw8elLooLaKZlCp3mfVe7tB7Z3L6jcjlEXZpmo QjXOF+wthQNjz/VdicXz92zyYK2HISx2seEmChC7Oe4LuP+WBuRu2+SWmBncxYbE ymjC15ggxyvaLozPGm2OqyiTakkQEE33OXB6Je3CyH5oObtDTSrYhbiEQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:reply-to:subject :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=n6jp16hT4oTH1dxVIOY600H59pcJD1Ay2zwRoDXWqKs=; b=Qv2pOgr/ SGuyEf0woWJpgrCAYYd82mBfIZuASR/78LOMlx9tRCv81jWke6LhdAK9V1VZb7dV 4vcefVPgcFm0zgBWhXmuPtUW/bhlYW1DfSx1yX2q5hmNX56H7oSQvM9blKgE1Z4Q wt3xjsATwsLWxQCSBCSXVwkIATM7h4htQftSlLU5qIohzGtMf9ZNeksNA3yV+Nw3 l3FbjV+U15qIIBymx9xspFV0AAv4nDSnQ+NeukDWV+EmyJpuMYz7D6RjC1n4Pv6H hsACRgIQWLkC1OYbd5dkqywSPy6beMrBoQdZBlpYkW1zjUo5If37UdPmxV5M+cD4 J4dcIhMuUFQyQg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdeigdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpegkihcujggr nhcuoeiiihdrhigrnhesshgvnhhtrdgtohhmqeenucggtffrrghtthgvrhhnpeduhfffve ektdduhfdutdfgtdekkedvhfetuedufedtgffgvdevleehheevjefgtdenucfkphepuddv rdegiedruddtiedrudeigeenucevlhhushhtvghrufhiiigvpeduvdenucfrrghrrghmpe hmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Received: from nvrsysarch6.NVidia.COM (unknown [12.46.106.164]) by mail.messagingengine.com (Postfix) with ESMTPA id DBDD43064682; Mon, 28 Sep 2020 13:55:25 -0400 (EDT) From: Zi Yan To: linux-mm@kvack.org Cc: "Kirill A . Shutemov" , Roman Gushchin , Rik van Riel , Matthew Wilcox , Shakeel Butt , Yang Shi , Jason Gunthorpe , Mike Kravetz , Michal Hocko , David Hildenbrand , William Kucharski , Andrea Arcangeli , John Hubbard , David Nellans , linux-kernel@vger.kernel.org, Zi Yan Subject: [RFC PATCH v2 22/30] mm: thp: split PUD THPs at page reclaim. Date: Mon, 28 Sep 2020 13:54:20 -0400 Message-Id: <20200928175428.4110504-23-zi.yan@sent.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928175428.4110504-1-zi.yan@sent.com> References: <20200928175428.4110504-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 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: From: Zi Yan We cannot swap PUD THPs, so split them before swap them out. PUD THPs will be split into PMD THPs, so that if THP_SWAP is enabled, PMD THPs can be swapped out as a whole. Signed-off-by: Zi Yan --- mm/swap_slots.c | 2 ++ mm/vmscan.c | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/mm/swap_slots.c b/mm/swap_slots.c index 3e6453573a89..65b8742a0446 100644 --- a/mm/swap_slots.c +++ b/mm/swap_slots.c @@ -312,6 +312,8 @@ swp_entry_t get_swap_page(struct page *page) entry.val = 0; if (PageTransHuge(page)) { + if (compound_order(page) == HPAGE_PUD_ORDER) + return entry; if (IS_ENABLED(CONFIG_THP_SWAP)) get_swap_pages(1, &entry, HPAGE_PMD_NR); goto out; diff --git a/mm/vmscan.c b/mm/vmscan.c index eae57d092931..12e169af663c 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1244,7 +1244,21 @@ static unsigned int shrink_page_list(struct list_head *page_list, if (!PageSwapCache(page)) { if (!(sc->gfp_mask & __GFP_IO)) goto keep_locked; - if (PageTransHuge(page)) { + if (!PageTransHuge(page)) + goto try_to_swap; + if (compound_order(page) == HPAGE_PUD_ORDER) { + /* cannot split THP, skip it */ + if (!can_split_huge_pud_page(page, NULL)) + goto activate_locked; + /* Split PUD THPs before swapping */ + if (split_huge_pud_page_to_list(page, page_list)) + goto activate_locked; + else { + sc->nr_scanned -= (nr_pages - HPAGE_PMD_NR); + nr_pages = HPAGE_PMD_NR; + } + } + if (compound_order(page) == HPAGE_PMD_ORDER) { /* cannot split THP, skip it */ if (!can_split_huge_page(page, NULL)) goto activate_locked; @@ -1254,14 +1268,17 @@ static unsigned int shrink_page_list(struct list_head *page_list, * tail pages can be freed without IO. */ if (!compound_mapcount(page) && - split_huge_page_to_list(page, - page_list)) + split_huge_page_to_list(page, + page_list)) goto activate_locked; } +try_to_swap: if (!add_to_swap(page)) { if (!PageTransHuge(page)) goto activate_locked_split; /* Fallback to swap normal pages */ + VM_BUG_ON_PAGE(compound_order(page) != HPAGE_PMD_ORDER, + page); if (split_huge_page_to_list(page, page_list)) goto activate_locked; @@ -1278,6 +1295,7 @@ static unsigned int shrink_page_list(struct list_head *page_list, mapping = page_mapping(page); } } else if (unlikely(PageTransHuge(page))) { + VM_BUG_ON_PAGE(compound_order(page) != HPAGE_PMD_ORDER, page); /* Split file THP */ if (split_huge_page_to_list(page, page_list)) goto keep_locked; @@ -1303,9 +1321,12 @@ static unsigned int shrink_page_list(struct list_head *page_list, enum ttu_flags flags = ttu_flags | TTU_BATCH_FLUSH; bool was_swapbacked = PageSwapBacked(page); - if (unlikely(PageTransHuge(page))) - flags |= TTU_SPLIT_HUGE_PMD; - + if (unlikely(PageTransHuge(page))) { + if (compound_order(page) == HPAGE_PMD_ORDER) + flags |= TTU_SPLIT_HUGE_PMD; + else if (compound_order(page) == HPAGE_PUD_ORDER) + flags |= TTU_SPLIT_HUGE_PUD; + } if (!try_to_unmap(page, flags)) { stat->nr_unmap_fail += nr_pages; if (!was_swapbacked && PageSwapBacked(page))