From mboxrd@z Thu Jan 1 00:00:00 1970 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 E2550C433EF for ; Mon, 4 Apr 2022 19:31:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AA756B0074; Mon, 4 Apr 2022 15:30:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 159E86B0075; Mon, 4 Apr 2022 15:30:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 022D16B0078; Mon, 4 Apr 2022 15:30:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id E7F896B0074 for ; Mon, 4 Apr 2022 15:30:28 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A71F7ACF73 for ; Mon, 4 Apr 2022 19:30:18 +0000 (UTC) X-FDA: 79320187716.16.1948FAA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 41413180023 for ; Mon, 4 Apr 2022 19:30:18 +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=zGKU3GX4K8cLnPSJeQb0clMP2eDTdoqf6QidgEjwTGg=; b=fbUPRaeA8zq1jA/TU/IGcDhe4f sSQIiha3tsQwkm9KOa1LMqar+iCoeZscOv3ZvKjkHxwqILelhwxprSDIYruf6xwM3OW3lzLaMvUTZ IaFywqd4u/5u0Zb1Kxr6SXR2QSp4UUb1rSQREeuwU33SGS+RI1gEK5fASUK5Sj2HUMEMrRYjaO5iR g76KOdxQocEp5dGcuqw1OC3+CqykbRDIzwAnYpBWvebB8qVO5aHBY9dcRMFmsoxGmV8VIVso+oTq6 9S/qncGCMadJ+gg76mAdXxJy903A0BaUCBAvJTATW8YZPeVWmbuxkv3FYH+gZ9IAgovTbUSMSrL6g VeDOMrdw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbSOv-005zqL-9d; 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 2/4] mm/migrate: Use a folio in migrate_misplaced_transhuge_page() Date: Mon, 4 Apr 2022 20:30:04 +0100 Message-Id: <20220404193006.1429250-3-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: b9cjzcmms3ukkemhpmytmfgn5r686od3 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fbUPRaeA; 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; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 41413180023 X-HE-Tag: 1649100618-774796 Content-Transfer-Encoding: quoted-printable 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: Unify alloc_misplaced_dst_page() and alloc_misplaced_dst_page_thp(). Removes an assumption that compound pages are either order 0 or HPAGE_PMD_ORDER. Signed-off-by: Matthew Wilcox (Oracle) --- mm/migrate.c | 58 +++++++++++++++------------------------------------- 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 9894e90db006..6c31ee1e1c9b 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1997,32 +1997,20 @@ static struct page *alloc_misplaced_dst_page(stru= ct page *page, unsigned long data) { int nid =3D (int) data; - struct page *newpage; - - newpage =3D __alloc_pages_node(nid, - (GFP_HIGHUSER_MOVABLE | - __GFP_THISNODE | __GFP_NOMEMALLOC | - __GFP_NORETRY | __GFP_NOWARN) & - ~__GFP_RECLAIM, 0); - - return newpage; -} - -static struct page *alloc_misplaced_dst_page_thp(struct page *page, - unsigned long data) -{ - int nid =3D (int) data; - struct page *newpage; - - newpage =3D alloc_pages_node(nid, (GFP_TRANSHUGE_LIGHT | __GFP_THISNODE= ), - HPAGE_PMD_ORDER); - if (!newpage) - goto out; - - prep_transhuge_page(newpage); + int order =3D compound_order(page); + gfp_t gfp =3D __GFP_THISNODE; + struct folio *new; + + if (order > 0) + gfp |=3D GFP_TRANSHUGE_LIGHT; + else { + gfp |=3D GFP_HIGHUSER_MOVABLE | __GFP_NOMEMALLOC | __GFP_NORETRY | + __GFP_NOWARN; + gfp &=3D ~__GFP_RECLAIM; + } + new =3D __folio_alloc_node(gfp, order, nid); =20 -out: - return newpage; + return &new->page; } =20 static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) @@ -2080,22 +2068,8 @@ int migrate_misplaced_page(struct page *page, stru= ct vm_area_struct *vma, int nr_remaining; unsigned int nr_succeeded; LIST_HEAD(migratepages); - new_page_t *new; - bool compound; int nr_pages =3D thp_nr_pages(page); =20 - /* - * PTE mapped THP or HugeTLB page can't reach here so the page could - * be either base page or THP. And it must be head page if it is - * THP. - */ - compound =3D PageTransHuge(page); - - if (compound) - new =3D alloc_misplaced_dst_page_thp; - else - new =3D alloc_misplaced_dst_page; - /* * Don't migrate file pages that are mapped in multiple processes * with execute permissions as they are probably shared libraries. @@ -2116,9 +2090,9 @@ int migrate_misplaced_page(struct page *page, struc= t vm_area_struct *vma, goto out; =20 list_add(&page->lru, &migratepages); - nr_remaining =3D migrate_pages(&migratepages, *new, NULL, node, - MIGRATE_ASYNC, MR_NUMA_MISPLACED, - &nr_succeeded); + nr_remaining =3D migrate_pages(&migratepages, alloc_misplaced_dst_page, + NULL, node, MIGRATE_ASYNC, + MR_NUMA_MISPLACED, &nr_succeeded); if (nr_remaining) { if (!list_empty(&migratepages)) { list_del(&page->lru); --=20 2.34.1