Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp104493pxv; Wed, 14 Jul 2021 23:53:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjeDPp1J3jgb2zc7aINS2JJWhr9swVFHVdxJ8ZRn91k2mTokIE01oHUSYl0+Q7poUFOKyZ X-Received: by 2002:a17:906:d977:: with SMTP id rp23mr3607276ejb.512.1626332027469; Wed, 14 Jul 2021 23:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626332027; cv=none; d=google.com; s=arc-20160816; b=K/PRV0674V+wV4Xt3XFSXiZZowJyoV6WB9g4XamDrPgxoS/Q9mOEAUcECz210HrJj1 m6OP+EzY2uus43KrTe57K9ZJYryh6Th6xICeUQ1NEWdqn9IYKukHcYONHyfbYeae53uq /RLWBZR4mOKra0EdlilHlVR7/O+q2+BD8u1DNyccGmHdSRi8l1A8sklSoNn8dxocD8y3 Az/yBjetIBLBWWO/RCpyjUEpJaNHwAcCj2ViLH++K0fNv+Jhn+O3ufT2YDOW6fF/eQIn Tft4EIoC3JCgrcRedBqbh6jFk8qY5YFzyAaAIpTljXHD/ggHH8QOfFY2xN4T0eiuEpr/ 26rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CFvJkkEN8s/6lLPeZLAt71H4VLu4g1kSLOabcpJEMsA=; b=cPCFXShgkU1IKT6KTYKkOA3MA+jmlpEHJ5UBGDe8GX88B9bwT54x1j7cHAjDJmA1UY dyAhSdpQdGmN1dXMqKziW1jHDk8YOMqlhHAEWN3o7jNMqbnata9a+sXbs7uvxHvirvJa zrP8X5Ruh6CNWFrYBaNC6hLZegOSjfQtx1YT/aowvsCV0nC9iXQWuVg+Ah9TPdaw/bS2 Gb+rNZRMUN2Xd8b+UWiaOeA+JANrbjbI761ARAbMiVx3eh9HyFEvbzBdK31NDp9JQTl6 zjmNcbpOTVdGiKn6s5jWZxTuyVbjH2Hj5xO1c7nKJNIcZpOhngiXZQpCxenyW2iFntTJ 0bww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Dvw4p2WX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df15si6217023edb.542.2021.07.14.23.53.25; Wed, 14 Jul 2021 23:53:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Dvw4p2WX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235774AbhGOEaj (ORCPT + 99 others); Thu, 15 Jul 2021 00:30:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233134AbhGOEai (ORCPT ); Thu, 15 Jul 2021 00:30:38 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51EAAC06175F; Wed, 14 Jul 2021 21:27:46 -0700 (PDT) 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=CFvJkkEN8s/6lLPeZLAt71H4VLu4g1kSLOabcpJEMsA=; b=Dvw4p2WXnfiSw3lLx59yQKyeq3 mlFMF/LTsapJ6bJx94piaLHVRdoSIu3rBa5Y0GCyzh3fhLhtEPepnfiwiTNSPM4WrOSFh3sA8ljpA lG+aBpAajvwUJQgI4ACJh3npYaKzhN6IjpWnybCzNP6Zsy1/HafxfjzME9duHAYu3wLQMYvmUoWU+ 7WMMtuiGtbsCAh56LcbJR0LfLOFplVWw+wagoz3MUpOJIo3qarirx6v0nh0KEvrFvKo6nXUCg7b16 wrmC4m/0TPLEwilNnL5UYQkObwXCsJ3qaNjn46INpn1DnhtiJBbZlLGQO39/39teCFlvLpCOB/2Vv Z8nk9G2Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3sxE-002xIW-0h; Thu, 15 Jul 2021 04:26:40 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v14 062/138] mm/migrate: Add folio_migrate_copy() Date: Thu, 15 Jul 2021 04:35:48 +0100 Message-Id: <20210715033704.692967-63-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is the folio equivalent of migrate_page_copy(), which is retained as a wrapper for filesystems which are not yet converted to folios. Also convert copy_huge_page() to folio_copy(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/migrate.h | 1 + include/linux/mm.h | 2 +- mm/folio-compat.c | 6 ++++++ mm/hugetlb.c | 2 +- mm/migrate.c | 14 +++++--------- mm/util.c | 6 +++--- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index ba0a554b3eae..6a01de9faff5 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -52,6 +52,7 @@ extern int migrate_huge_page_move_mapping(struct address_space *mapping, extern int migrate_page_move_mapping(struct address_space *mapping, struct page *newpage, struct page *page, int extra_count); void folio_migrate_flags(struct folio *newfolio, struct folio *folio); +void folio_migrate_copy(struct folio *newfolio, struct folio *folio); int folio_migrate_mapping(struct address_space *mapping, struct folio *newfolio, struct folio *folio, int extra_count); #else diff --git a/include/linux/mm.h b/include/linux/mm.h index deb0f5efaa65..23276330ef4f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -911,7 +911,7 @@ void __put_page(struct page *page); void put_pages_list(struct list_head *pages); void split_page(struct page *page, unsigned int order); -void copy_huge_page(struct page *dst, struct page *src); +void folio_copy(struct folio *dst, struct folio *src); /* * Compound pages have a destructor function. Provide a diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 3f00ad92d1ff..2ccd8f213fc4 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -64,4 +64,10 @@ void migrate_page_states(struct page *newpage, struct page *page) folio_migrate_flags(page_folio(newpage), page_folio(page)); } EXPORT_SYMBOL(migrate_page_states); + +void migrate_page_copy(struct page *newpage, struct page *page) +{ + folio_migrate_copy(page_folio(newpage), page_folio(page)); +} +EXPORT_SYMBOL(migrate_page_copy); #endif diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 924553aa8f78..b46f9d09aa94 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5200,7 +5200,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, *pagep = NULL; goto out; } - copy_huge_page(page, *pagep); + folio_copy(page_folio(page), page_folio(*pagep)); put_page(*pagep); *pagep = NULL; } diff --git a/mm/migrate.c b/mm/migrate.c index a86be2bfc9a1..36cdae0a1235 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -613,16 +613,12 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) } EXPORT_SYMBOL(folio_migrate_flags); -void migrate_page_copy(struct page *newpage, struct page *page) +void folio_migrate_copy(struct folio *newfolio, struct folio *folio) { - if (PageHuge(page) || PageTransHuge(page)) - copy_huge_page(newpage, page); - else - copy_highpage(newpage, page); - - migrate_page_states(newpage, page); + folio_copy(newfolio, folio); + folio_migrate_flags(newfolio, folio); } -EXPORT_SYMBOL(migrate_page_copy); +EXPORT_SYMBOL(folio_migrate_copy); /************************************************************ * Migration functions @@ -650,7 +646,7 @@ int migrate_page(struct address_space *mapping, return rc; if (mode != MIGRATE_SYNC_NO_COPY) - migrate_page_copy(newpage, page); + folio_migrate_copy(newfolio, folio); else folio_migrate_flags(newfolio, folio); return MIGRATEPAGE_SUCCESS; diff --git a/mm/util.c b/mm/util.c index 149537120a91..904a75612307 100644 --- a/mm/util.c +++ b/mm/util.c @@ -728,13 +728,13 @@ int __page_mapcount(struct page *page) } EXPORT_SYMBOL_GPL(__page_mapcount); -void copy_huge_page(struct page *dst, struct page *src) +void folio_copy(struct folio *dst, struct folio *src) { - unsigned i, nr = compound_nr(src); + unsigned i, nr = folio_nr_pages(src); for (i = 0; i < nr; i++) { cond_resched(); - copy_highpage(nth_page(dst, i), nth_page(src, i)); + copy_highpage(folio_page(dst, i), folio_page(src, i)); } } -- 2.30.2