From patchwork Sun Jan 2 21:57:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12702363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 860C2C433FE for ; Sun, 2 Jan 2022 21:57:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 200D16B0073; Sun, 2 Jan 2022 16:57:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CED06B007D; Sun, 2 Jan 2022 16:57:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E59156B007B; Sun, 2 Jan 2022 16:57:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id CD91A6B0075 for ; Sun, 2 Jan 2022 16:57:36 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8BDBA8248D52 for ; Sun, 2 Jan 2022 21:57:36 +0000 (UTC) X-FDA: 78986709312.30.15193A0 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id B082840005 for ; Sun, 2 Jan 2022 21:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=OIYZTtL5z9IBnWXwCyTZcTYVTvNGO7oeHGEs35IwMTE=; b=jcx0YmZ7o3ZZYfl3nRoJhy5Q50 bPaISejmfAU8j/t1x9GWuLMPuKHPNAGLHhYkwWbSxsVErn0TEBdlbEkJI6o+rXkL0yOrUghhszMdT +zRi3I6PvMVgol2hlPDciihFXTI4NF0VRjZ5hMytRkHFhaxAYCZDE/KPPejynkeRrQFGWosSPlmvu Vlwhl1jIFy4JS5+mLfGgs3qHQBEcNVecj21CAtVGiOUS8z2jWTNPrcGlp2+GPlzbuD0SI92jpDf0s AbxEJkWqcUIQ7SdtqEIShgfLMJGyDXc8xNNvK8HbvrxaXRO5/fjkeqYxN2wzE6uW00C3+EKwixevA OEweFkgg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n48r7-00CLos-AR; Sun, 02 Jan 2022 21:57:33 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , John Hubbard , Andrew Morton Subject: [PATCH 17/17] gup: Convert check_and_migrate_movable_pages() to use a folio Date: Sun, 2 Jan 2022 21:57:29 +0000 Message-Id: <20220102215729.2943705-18-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220102215729.2943705-1-willy@infradead.org> References: <20220102215729.2943705-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B082840005 X-Stat-Signature: artbt4aht4n4duuz7da79oppumrqxc6s Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=jcx0YmZ7; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1641160636-423385 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: Switch from head pages to folios. This removes an assumption that THPs are the only way to have a high-order page. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Reviewed-by: John Hubbard --- mm/gup.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 76717e05413d..eb7c66e2b785 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1822,41 +1822,41 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages, bool drain_allow = true; LIST_HEAD(movable_page_list); long ret = 0; - struct page *prev_head = NULL; - struct page *head; + struct folio *folio, *prev_folio = NULL; struct migration_target_control mtc = { .nid = NUMA_NO_NODE, .gfp_mask = GFP_USER | __GFP_NOWARN, }; for (i = 0; i < nr_pages; i++) { - head = compound_head(pages[i]); - if (head == prev_head) + folio = page_folio(pages[i]); + if (folio == prev_folio) continue; - prev_head = head; + prev_folio = folio; /* * If we get a movable page, since we are going to be pinning * these entries, try to move them out if possible. */ - if (!is_pinnable_page(head)) { - if (PageHuge(head)) { - if (!isolate_huge_page(head, &movable_page_list)) + if (!is_pinnable_page(&folio->page)) { + if (folio_test_hugetlb(folio)) { + if (!isolate_huge_page(&folio->page, + &movable_page_list)) isolation_error_count++; } else { - if (!PageLRU(head) && drain_allow) { + if (!folio_test_lru(folio) && drain_allow) { lru_add_drain_all(); drain_allow = false; } - if (isolate_lru_page(head)) { + if (isolate_lru_folio(folio)) { isolation_error_count++; continue; } - list_add_tail(&head->lru, &movable_page_list); - mod_node_page_state(page_pgdat(head), + list_add_tail(&folio->lru, &movable_page_list); + node_stat_mod_folio(folio, NR_ISOLATED_ANON + - page_is_file_lru(head), - thp_nr_pages(head)); + folio_is_file_lru(folio), + folio_nr_pages(folio)); } } }