From patchwork Thu Mar 21 03:27:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598365 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 476DDC54E58 for ; Thu, 21 Mar 2024 03:29:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2C8A6B009A; Wed, 20 Mar 2024 23:28:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC1236B0099; Wed, 20 Mar 2024 23:28:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96BA36B0095; Wed, 20 Mar 2024 23:28:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 28ACC6B009B for ; Wed, 20 Mar 2024 23:28:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 001A7141451 for ; Thu, 21 Mar 2024 03:28:56 +0000 (UTC) X-FDA: 81919614672.14.E0DD555 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf13.hostedemail.com (Postfix) with ESMTP id 85F7520014; Thu, 21 Mar 2024 03:28:53 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710991734; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p7Rro21SYby9XQmy5UCrRBauBgvvyMJXUQxLJbnZyHA=; b=IBd1QEyGHByizuCl95Sl+ByBnfTgYBHDEPfvE0oYZlh0zCb6iZ3lKpkvUBS5ZrdZQLGa7d eVCAMmrInCnNeyVBtMcCMrgikRCyH5tcgGDKPYwqb3cGleEgWo8/05H6Qlg8CWBg3WsbUF MUXnr/O8y5ahRw1pOUTFmUh0OsGVNZM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710991734; a=rsa-sha256; cv=none; b=PxBnxRlOZaetkMGe0QwI4XlaenoFfYS5UZ+L/5DXwAA5GMOoQHsek3g06VUQ/TnKQWFUps +bcAlyw4A9CIvY9VN2444K2ssHvFYwW9ghX1GRTe9hWwXzWZF3EaAq0FJAupNZAFd7ezed q+/gjYyOw7eUnVicKRsjyNZuiF81gW4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4V0W8t6T32zNm8T; Thu, 21 Mar 2024 11:26:54 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id F186014011F; Thu, 21 Mar 2024 11:28:48 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:48 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 02/11] mm: migrate_device: use more folio in __migrate_device_pages() Date: Thu, 21 Mar 2024 11:27:38 +0800 Message-ID: <20240321032747.87694-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 85F7520014 X-Rspam-User: X-Stat-Signature: hcnp9wpsxfprujzknoxaifzgngg5kctd X-Rspamd-Server: rspam03 X-HE-Tag: 1710991733-541388 X-HE-Meta: U2FsdGVkX1/TXWJcY89xyx/q2jru8oGBvXWFRrItUjbe4TPivH1xEDQ5qs2uby65PpZnOocq25c5pppLOChWWnbz3+bTG69wiJudARECZVsZT6/edy+zQC72ZQi/+V43lIqQp4yVmtmvRn1J9A5RFtDevuhraLp2tApW5yytWjzqj725Tl196yTIIgOqxW1LV7jpW08/Pk2EyTIFRYoun0C2WUMrySbWf2M10fRaCthK9QuZGdyTHzTUik1TGN8+pJKPt57sVy/7/SrJ9Oxi6GFdnv1+uGaTKkLwNpERcEFQQeKym1BODl/Ey8zf4hSnuWSdsH48xSBHWhF0eZ/F3OZSx1O47eY16FtTZNOJ7aYl3MXWa0u9Om8H4Tg6IGbXtggLPe0gEB0Ajf/6hM26b2CbSWCE6tyvNiDNciGeTrVefc8u0WcC5P/FSqS9M3DpWRHf1EbxZCti93Z/MOldaf8QcpoyllVHaybxGuataoTEXIxu1KSRFgADyASSVP52GGrM2t5RUNNX2Ke24Mssz4AxDs7kgEi2t5s+60aTLY1W+GUxZwQp1RzlCn/RtHBbTmkqJFi1Remhmo2B9JRzq3/VjRrmJwZzhy5MrPeYIiwOBbkCyZeHNr8BICJRRrllFgb3ns3mhgnE1fzncvVGuuC58/bRzZjd/gFexbzuML3LVG/jVT8/ZWl3teXqX8+HbYJf9lGFCco+yOFw0N9bB7VxeoCt6Ce1kQOVqvttbY/KYHRrJ1tPbLLaCV8lh6mwtGwKBSkEy5P8aU0lIPMZoKGjs9Se/+HJ2AsfyS15xLbg16aujDbURO6e7Kzsik8TpR354OdYysVn9+vQRqLLVl3Pt2RhJE316R4XU0pUkzdg8TNER5F7YXqp4kPq6DZdKD+IfTeEl0EB1UwF7GQVxJ3CoZptyLnBy6yE32IW9USsAnMI47zmgQoH4ozeDEwDFYPlko6MIYL+LtGie+k TcH4PdxG bb3x89vp+JPzOHYrM41tI0nWkj7MMYchpq1COLou/1FNDwa+JXWx493JKGYQV96Spzc3TeoSZfTMfSQUKDzCAEM4+X+RTw2zK2u+EsiLvHe0AAbSwJhSeIvpO91j3SRCAQBL3W+TesjVDH8g5sNHXVcfCEBtbWZDSih251CT/3r9i4Z+SY57kElESramis+Ry1W0tb+SlgHx3QZpQMzkjcps50qbkAMuTRUy3oCfuItYkwfJGCdz5MrWay3Rx4bnOC4ph 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: List-Subscribe: List-Unsubscribe: Use newfolio/folio for migrate_folio_extra()/migrate_folio() to save four compound_head() calls. Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: Kefeng Wang Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Miaohe Lin --- mm/migrate_device.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index b6c27c76e1a0..ee4d60951670 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -694,6 +694,7 @@ static void __migrate_device_pages(unsigned long *src_pfns, struct page *newpage = migrate_pfn_to_page(dst_pfns[i]); struct page *page = migrate_pfn_to_page(src_pfns[i]); struct address_space *mapping; + struct folio *newfolio, *folio; int r; if (!newpage) { @@ -728,14 +729,13 @@ static void __migrate_device_pages(unsigned long *src_pfns, continue; } - mapping = page_mapping(page); + newfolio = page_folio(newpage); + folio = page_folio(page); + mapping = folio_mapping(folio); - if (is_device_private_page(newpage) || - is_device_coherent_page(newpage)) { + if (folio_is_device_private(newfolio) || + folio_is_device_coherent(newfolio)) { if (mapping) { - struct folio *folio; - - folio = page_folio(page); /* * For now only support anonymous memory migrating to @@ -749,7 +749,7 @@ static void __migrate_device_pages(unsigned long *src_pfns, continue; } } - } else if (is_zone_device_page(newpage)) { + } else if (folio_is_zone_device(newfolio)) { /* * Other types of ZONE_DEVICE page are not supported. */ @@ -758,12 +758,11 @@ static void __migrate_device_pages(unsigned long *src_pfns, } if (migrate && migrate->fault_page == page) - r = migrate_folio_extra(mapping, page_folio(newpage), - page_folio(page), + r = migrate_folio_extra(mapping, newfolio, folio, MIGRATE_SYNC_NO_COPY, 1); else - r = migrate_folio(mapping, page_folio(newpage), - page_folio(page), MIGRATE_SYNC_NO_COPY); + r = migrate_folio(mapping, newfolio, folio, + MIGRATE_SYNC_NO_COPY); if (r != MIGRATEPAGE_SUCCESS) src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; }