From patchwork Fri Feb 4 19:58:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12735540 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 6974DC433FE for ; Fri, 4 Feb 2022 20:00:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 212058D0008; Fri, 4 Feb 2022 14:59:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BE516B009F; Fri, 4 Feb 2022 14:59:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 755628D000F; Fri, 4 Feb 2022 14:59:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 0E0448D000C for ; Fri, 4 Feb 2022 14:59:09 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C367A96F2E for ; Fri, 4 Feb 2022 19:59:08 +0000 (UTC) X-FDA: 79106161176.19.6283997 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id 6E086140003 for ; Fri, 4 Feb 2022 19:59:08 +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=7lCdDpwYdKDkLlbslxBRg+2wOD2EjKVgpCEmaUyy+oM=; b=QwfwufgSXk6f+sdolDtZP+fdSy 0fpEMthi/hNNBIpZDavPRrrnFKpzDge8xNVnjkWzTocuexNJjAS/TWxrOFtQ1tvRmiehHabY0lDjE TlWM/nsV/WE6cplK2QqPAUwHPvNJx7/ga9XwlrKkha5pmb3Z0Rc6msOCHpL2v47s3gEAfHa0+/qpq VzwDGcKx2ESs7sEahSmI8MKSWjhixRG4YAOdw/+cMeWIgxx0OwYi3Om2L7IzeGghQ0DxcuU3B0QoU QK4nlFZJp/rBlVTTkeOnYvAm4e791rtqywqKOv7ix2+XRLLrm2LdnK7ZauqGEWb/6VoKmyR5DQdiu /iUrolLQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG4jW-007Lm7-66; Fri, 04 Feb 2022 19:59:02 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, Christoph Hellwig , John Hubbard , Jason Gunthorpe , William Kucharski Subject: [PATCH 28/75] mm/gup: Convert check_and_migrate_movable_pages() to use a folio Date: Fri, 4 Feb 2022 19:58:05 +0000 Message-Id: <20220204195852.1751729-29-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220204195852.1751729-1-willy@infradead.org> References: <20220204195852.1751729-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6E086140003 X-Stat-Signature: bsfzw8mzzw5opap37koy9nrdanki53co X-Rspam-User: nil Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QwfwufgS; spf=none (imf26.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: 1644004748-68082 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 Reviewed-by: Jason Gunthorpe Reviewed-by: William Kucharski --- mm/gup.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index edec7356b965..9f2f8d765c58 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1815,41 +1815,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 (folio_isolate_lru(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)); } } }