From patchwork Mon Apr 4 19:30:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12800659 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 E1158C433F5 for ; Mon, 4 Apr 2022 19:32:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B7C66B0078; Mon, 4 Apr 2022 15:30:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 466B66B007B; Mon, 4 Apr 2022 15:30:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 331BB6B007D; Mon, 4 Apr 2022 15:30:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id 2605B6B0078 for ; Mon, 4 Apr 2022 15:30:35 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CBF9A824C424 for ; Mon, 4 Apr 2022 19:30:24 +0000 (UTC) X-FDA: 79320187968.22.F6B2520 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 5B4E9180021 for ; Mon, 4 Apr 2022 19:30:24 +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=aaht8wjestcuAz9uUmgOlm+Z6jPOdwv91UY9zwH12ng=; b=j9dXNAVZKFuyzfso72UeyH6GQI NrRnfmMEnBMtzhYp0v59UfMFQgeJMP5euuxVEPEuXoNtFvUfgqfYaqW3vxd6QtH0j6/eLRDGqT6Kt 2WZ/02DJYDNaQQ1lJ+8Lh/2UtQ5XUiFQ5bIDvpy+uY+9Q1P8K8ieTMeD/Jol/GkWtPzpRQ6/J88sA u5SSehhtRCdQLBCbKFUKyC/riArNrkF1Hrzlw6JQv8xFyOodiWBhgIaDF2m++oA0kyLLYApEdhtuQ 5Qr7N5QoySTZFo8QUA6Anw8VOH04fNqurO7GfbaY6+vNZyks7s/hVvmrq8RN0hpY/5D5QyWEjOE7x j8yxiJTg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbSOv-005zqJ-6M; Mon, 04 Apr 2022 19:30:09 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton , Zi Yan Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 1/4] mm/migrate: Use a folio in alloc_migration_target() Date: Mon, 4 Apr 2022 20:30:03 +0100 Message-Id: <20220404193006.1429250-2-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220404193006.1429250-1-willy@infradead.org> References: <20220404193006.1429250-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: cbjh7k435j9tijar19panig7kduarwdx Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=j9dXNAVZ; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 5B4E9180021 X-HE-Tag: 1649100624-411325 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: This removes an assumption that a large folio is HPAGE_PMD_ORDER as well as letting us remove the call to prep_transhuge_page() and a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/migrate.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index de175e2fdba5..9894e90db006 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1520,10 +1520,11 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, struct page *alloc_migration_target(struct page *page, unsigned long private) { + struct folio *folio = page_folio(page); struct migration_target_control *mtc; gfp_t gfp_mask; unsigned int order = 0; - struct page *new_page = NULL; + struct folio *new_folio = NULL; int nid; int zidx; @@ -1531,34 +1532,31 @@ struct page *alloc_migration_target(struct page *page, unsigned long private) gfp_mask = mtc->gfp_mask; nid = mtc->nid; if (nid == NUMA_NO_NODE) - nid = page_to_nid(page); + nid = folio_nid(folio); - if (PageHuge(page)) { - struct hstate *h = page_hstate(compound_head(page)); + if (folio_test_hugetlb(folio)) { + struct hstate *h = page_hstate(&folio->page); gfp_mask = htlb_modify_alloc_mask(h, gfp_mask); return alloc_huge_page_nodemask(h, nid, mtc->nmask, gfp_mask); } - if (PageTransHuge(page)) { + if (folio_test_large(folio)) { /* * clear __GFP_RECLAIM to make the migration callback * consistent with regular THP allocations. */ gfp_mask &= ~__GFP_RECLAIM; gfp_mask |= GFP_TRANSHUGE; - order = HPAGE_PMD_ORDER; + order = folio_order(folio); } - zidx = zone_idx(page_zone(page)); + zidx = zone_idx(folio_zone(folio)); if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE) gfp_mask |= __GFP_HIGHMEM; - new_page = __alloc_pages(gfp_mask, order, nid, mtc->nmask); - - if (new_page && PageTransHuge(new_page)) - prep_transhuge_page(new_page); + new_folio = __folio_alloc(gfp_mask, order, nid, mtc->nmask); - return new_page; + return &new_folio->page; } #ifdef CONFIG_NUMA