From patchwork Mon Jan 29 07:09:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13535063 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 D0D39C47DDF for ; Mon, 29 Jan 2024 07:10:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0033B6B0087; Mon, 29 Jan 2024 02:10:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF6D76B0083; Mon, 29 Jan 2024 02:09:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C83C56B0083; Mon, 29 Jan 2024 02:09:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A32366B0082 for ; Mon, 29 Jan 2024 02:09:59 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6F59C1203E3 for ; Mon, 29 Jan 2024 07:09:59 +0000 (UTC) X-FDA: 81731474118.21.98E8F42 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf19.hostedemail.com (Postfix) with ESMTP id 1095D1A0003; Mon, 29 Jan 2024 07:09:55 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1706512197; 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=QqTIOlrtZkjnZBOy56NFsfvPFGoBl6IsNXFc+pSsR3w=; b=JDAro+LrmQ2Vr9VIXftvdiDpbWPJvDNOSLyuOQzUw2hDN4vX7q5cgGpjIV1pYeNRtdPVvB tXmkMvJiQoZ5IZWbT8IgmX8hYETdCMQ3or2Pzp54LUzLJTT7aekEx2bDkHK3ofr2CdJ/n5 JtNx78OQumDHgJvvSe6ybc5rwwwr9lY= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706512197; a=rsa-sha256; cv=none; b=tVgr9gQkKmYCoxyQEEnT6+TpMDX9tX4vimJCQgC8Wcc/HBZcaCCq7r63B8LpZHB5DUfAJk I49XEfin0R4X+max6jy6b4M0ZNwRruYGjYrlsbg//PtlCO5B5WFWFQi7mUGHcvi/5cSo+I ihsj9WlaW2rrDFeketR7oNp+bMk+OBU= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TNfXB0VdCzvTXb; Mon, 29 Jan 2024 15:08:10 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 80BAD18005E; Mon, 29 Jan 2024 15:09:47 +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_128_GCM_SHA256) id 15.1.2507.35; Mon, 29 Jan 2024 15:09:46 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfc 2/9] mm: migrate_device: use more folio in __migrate_device_pages() Date: Mon, 29 Jan 2024 15:09:27 +0800 Message-ID: <20240129070934.3717659-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 1095D1A0003 X-Rspam-User: X-Stat-Signature: t6snbhsxgpgsuq5t6y7s6axa5me9tjmi X-Rspamd-Server: rspam01 X-HE-Tag: 1706512195-737792 X-HE-Meta: U2FsdGVkX1/VY107gooTBOIXpapyitpIHmsa100y+z8AD7l1dyezMFplW5BRk/tJUTBFDzvw6g6gGMSAbRP4wldAs3Git4y48MV50P72CNPS4LajlpGyyTgZuLxOkMACST/Mvic+6CSGSJCvZ4PWNPkOU2NsD55rwWO2gtwwe+6mQx/458WlHn5+fzPDp8V3VHjyZ8t/1lLDgzIrVLK8GIUB4xd4FzPkKEP5ZDTCzbmfpJcDG8wWUSzsoAWPANh88x6D2SrMT0iEhnTMM+6jn6UKDIef391s1WX1zaG1SYEZuOMujYYzeAJwa8OY5TeW81At1YuA8IApJlC2vTJEm/yVp/V4M86ALlFqUtC1HulOcksi8OB9JbBoBooKNRSPO0t5nUtEbXsPqvuI555fSh+9ZCd8G+KIKJykhiP8mfz17qCI8u1rh+TB1U+4/038uXwyyzx3sgYW+TBAww8SjH+ZoWEUV3T3MriUOilRB9Jv1ezG3Y3iZWebDtVG0m1CPbw+Mif1lXeDmAiB467aHHxfqt/Z/OEVys0GDKB4jQiyqzSjqajkz0YZo7906nzAf+gl1bUdLK23fxKuUYt7X/l7MF/vePIKB2nPAw3Yg9F+hNv3vPzFHCAhUWBlApGDQzYa+WrvymOL3B61+7iT6yP1Wytu7MAy0y1QemaDtcOGcwtOg4OL+R60A4gUpx/TAhsbJwlrxEzyP/Ap5/1EGGzgw0FFuXUJ1NwaXDbcv4F4nMtJ3yAyXtzPdggY7Cbo+TBarC44v5jYb6uN0wJutKoAGoIU7aZ/V0YkBy0DKbCUXtd8FGt7M9H9bPySqRaI4l/WT3DEu8dkexl3MV3ruKfDoyK8ZAtVgWps96lE6Ahjl0RA4CjHcGvmOr+E0a4jzM4/mUZ0ttX72Em9KFwGOBZ+rClRGLJGOPlIHZosBd8KD2HVC7f0m38YkgXhDKnBTvRHvwdNOYRJuVLT//T iCAw+4P+ +qDu4LKS59Xsl0dEgh9bwqky590B8jES5yFPAtp6BRdBiSsXxhh2W79nrBKo4AaD7CFHdE4QC0dm2m/YYzdjzSAZ1P8/o/A0vGfTGUvHSupFNlY7yjmlZ3T0SiS+OSo2MvD3b/ox25/eVBelpLH39df+g31J8xr22PiQnn/Dz3aJ+MFPNkO+mWY9vqnuYlT3NRTLof0R/55KcXvg= 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 three compound_head() calls. Signed-off-by: Kefeng Wang Reviewed-by: Matthew Wilcox (Oracle) --- mm/migrate_device.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index b6c27c76e1a0..d49a48d87d72 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) { @@ -729,13 +730,12 @@ static void __migrate_device_pages(unsigned long *src_pfns, } mapping = page_mapping(page); + folio = page_folio(page); + newfolio = page_folio(newpage); - 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; }