From patchwork Tue Feb 6 11:21:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547057 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 1436FC48297 for ; Tue, 6 Feb 2024 11:21:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02B7E6B0089; Tue, 6 Feb 2024 06:21:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA77B6B0083; Tue, 6 Feb 2024 06:21:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 754456B0075; Tue, 6 Feb 2024 06:21:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1CA066B0087 for ; Tue, 6 Feb 2024 06:21:52 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6ACD3C0B73 for ; Tue, 6 Feb 2024 11:21:51 +0000 (UTC) X-FDA: 81761139222.25.A3ED8DC Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf14.hostedemail.com (Postfix) with ESMTP id 3669F10001F; Tue, 6 Feb 2024 11:21:47 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 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=1707218509; 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=RdTsyGDionxebasJBQDb3Ax7lgZoxcsIOSPkDhbUJzQF+rVR275rJy2rbZ4x1544l7zVDO Neqt4LF0wmWDDOcLiEVls161kN8kQ6Dh0hgS0P0FRqCOX1ExoWGyVC4cXO3mb2LB2DYt3c iZ4mmW2o2ICnwKnZQO+H2+l422nnuLg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707218509; a=rsa-sha256; cv=none; b=nWoZorOou0PdIfVGS5UCJeK9DDDn9JxJ10eXRq6mmOF+4NIXkbL3L6MUxJgydZMXhh5UK2 6e01dAybLUtzuAqHmyCHLQvDerVdii+mqo2H55FXttQ15gjFNeXNJ5JTZduQgG5lBf8lK+ lbZxTy2QiSyhqJuUk1/N47awMXa5zaM= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 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.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TTggm22wyz1FKQL; Tue, 6 Feb 2024 19:17:08 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id D97971402C7; Tue, 6 Feb 2024 19:21:43 +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; Tue, 6 Feb 2024 19:21:43 +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 rfcv2 02/11] mm: migrate_device: use more folio in __migrate_device_pages() Date: Tue, 6 Feb 2024 19:21:25 +0800 Message-ID: <20240206112134.1479464-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-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-Stat-Signature: tuafkzboc4gzynxnefarzi1o47599cwt X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 3669F10001F X-Rspam-User: X-HE-Tag: 1707218507-854357 X-HE-Meta: U2FsdGVkX1/gVQsjkhbEzh/AxVfAfAFPI09LF1ek9UblRpeEr0h2ThHN+OyoYbNtqqyJwFvdMcFPc4PGedaAKtKzLlLBCM+5KOyHM7jbQqXBZrS4icprQJSFHgM0A3q/iDVmsLo36tyekFLnznR6pImd/vywu0JyMPt7cAwJ+ycovR21vtOf25I+1S7JKRtyiGDRwqOo04goizRQv66kcbNYh2eDrxFlE6gT8Fr0jpI7defXNyuhCRzRsHKB3y9Iy0mgy2WDX2Irwblywb6OpHulBrkV8uVBMD8KexgmW6obMXwHGAF/PWs2AyQFTKVMiTX+rxjKA4Db39GYT2bodqLB+X7NQlcfuIH802BnyeFEO3Y/7c8eAgSUzaLPAfwV3V6v0emBoin6XzccAk+yc6WJaDte0eJaGGZ879k1H6PVJQ8gsrK7RXpjn3QfIaZtfDRbOjkRcg0Yt99nenXi2o6wupg3UliYnkQeKO6p33gjWPJcoANd/Uc9ej2U8aFoo+diCelR1ITzyHCvIoPE8GoHxmmj6Uwcm5CTtlgqnk4QTDuiJYwMGikQfq8m7h3hY+R/PEYQQBv4M8KYYEljb5YbfEy7tLlIdrJqD7o85go3Mn/UhXO7vmBguay0hznpdHlortDy1CzApHj5zkG6xZijtsnxMtJPwU3tSHifbeY4g99HXD9bhnFJ07QxqJBZ/r85GVcXaUqpmg+d+BKmOC9suF9jAFP+Hz9PKML8Bnq1YnT5N4BZHppF37lJzUfgOYjyjYh+abgJbVtapUB59LdO4SVyKloeXiehy/cVuybr9Z3b25NCF7YHXKU982ALIqhkL4eckPsdeyzxK9WTqarXPyuDcMud9QQiijFVEnIRNVFFvO+PoBLI+Y7yVWMJWV4GGxuzarGJt0taJH8ENQcinDwI8/aGOPEpLJcdCByoxMtwhYyHP1tY+0vcO6NVpFDJxziTT+C+T1D7Y9R AILJLrGX IYIyxtv0taHp/IAeL+JKMySSOdgmBONLbzIwLhIIDMc4Sw4lDE3UPu8zvQlrgYZYmdMd0gL/NYgghvlzEDQ/Jwbu6cTyQPaBbVCdbGOrOlcFl6FO+mNq+nUVtV1LhDMj3Sd0Gy6ORw/3ghgZv/CfFMfVrXzLpXlXFaZ+wkU9FrexuJVjtgTr+yV4xS7f1vuq0iBoDtR5V/B/ObG8MKBJGH3f35UcHjaYg4+pLcee8JDsy0k/h4FHZHese3kzzuYr6v3k/ 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 --- 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; }