From patchwork Mon Aug 21 11:56:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13359341 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 33B33EE49AA for ; Mon, 21 Aug 2023 11:45:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29D718E0006; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 273EB8E0002; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0ED4B8E0006; Mon, 21 Aug 2023 07:45:41 -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 DAA468D0002 for ; Mon, 21 Aug 2023 07:45:41 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AC35F120BBB for ; Mon, 21 Aug 2023 11:45:41 +0000 (UTC) X-FDA: 81147932082.07.4C0484C Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf20.hostedemail.com (Postfix) with ESMTP id A257E1C001B for ; Mon, 21 Aug 2023 11:45:38 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1692618339; 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=b6a5Lr7QxakE11InEGULrgvVA3wroipO65uNIXOCIbY=; b=QyQuiewH9eeYgpPBOta2e+BLFD/35HKhindVgfFCB+ngZRDiut6Nq1M2q0uYJoqEq2Cg2R BsaBy2BH+oza20qa8j/KevFoGglxV7UkjLo4Si5RnqCs7ytasrdc2OKolteg/cNnCn2ZM1 rhFqeE7ps7eg2m9xn0DLzUNZ9eo8ViM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618339; a=rsa-sha256; cv=none; b=N4eQwotMh1gue6+morSaOt0mpAYVlEItiwLafgsoN3FaOTU7S5LpG4FqlUWKQYfeNmcVB5 BwoK/zrJWsRMXEZv5pzapGv8JvzB+Sxo+Gk1wmPoatV8aoujyM2CiP+T7KBN/OB3JInkeh uBLiAWV0XLb+1VLpyyw+KBl+Pp01nxo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RTrGw2d0Lz1L9R0; Mon, 21 Aug 2023 19:44:08 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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.31; Mon, 21 Aug 2023 19:45:34 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 4/8] mm: migrate: use a folio in migrate_misplaced_page() Date: Mon, 21 Aug 2023 19:56:20 +0800 Message-ID: <20230821115624.158759-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: A257E1C001B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 8317g7oqib9sjexnzf71tmsstrk5cm8m X-HE-Tag: 1692618338-264858 X-HE-Meta: U2FsdGVkX19QIYlyFeyuPw4CAwpucFyzAXGHFrHqQDBqzjmVk8vRhKBJj5zTVK1/aPRNPEJprhAsE28RzYTwJMiABFuIxh6WxQcgtnyJU1Jt/OiXbPhnEdEpNrGwb/ruJTjrcEslT35aWHjXLuhmi4LnOYTUv1M+vMFDLebASiRqloWyzPO9pcwwK2SS+sjGBX26fiLHttMPFcGiR9y9dN27x/vKZoljwanlPiYNHRVQAcYoqbDM3IfNLYfHjz1oyj855pOng3wJ87BhCV+VuwsDEE2f7TcBD9vX1dg+hQPWVblgCTJXWwcL4yRYC7beTLIksmZnPT2Y2hFKDvMhYj+pT7CP7RUEjIyJoHyEz0kPI7rYMht5wHn42U1LRuraqc0QZ0MiVmgmsEKbm0BA1Yko3WLmqylicoHWcR0cmG/NDHhmF9Jx7NBkE9/zk/n3sMhoAcZcBBFqtzexQzxsy0WcELcKXImeLS3JAfldtvmRIKwkxrHrTGciZc7SoWaZ8mVIQ8uU7KFfX6TmCA4cLI0t3xzwCutU44r2ST81a/wgC9rLlTOiQktLnWXQDyjzTq5lEiXcoqmlzI9tJmle48FyKUgnpsmvQsRNbGqAukFXKtSJG5fBAmUiqQ/IY7uG6dxAQQBmOoD5BSg8bR5ff8gUUpskbvsi3+ZOBQmb8c1XncBYRS/i+DNO6qSNu7iIvJn6iiipC3d60JP1LMhDX9QdyxeeLYge8vnKvMMB4GaPZ4zWkgskjZjvEApUee4N947aynCydjmvnUqhaYufZLFtX0NzBnP2cNgpmaSLCra0QInDVPZkQvZmpIiZWQjJtKt16lbokgYDVGx14sFI++VJxpydE0paHtpMYvPGOcLH8L9VUa5t6++/btokIvkCkAwMcXEjJoNlnekJcYyEOZyEHXveFzIcvdSoCiGk+gcb7GcqM485kFU4zdrRfH96Xr1IelnglCXG3vIRR1y zh3w9ed6 xXgTyPly6QBheuI+d/uTuuSdm3+8IS7FqSzf+2rcZtRl9M4Cz1qoCkKzQCYuYPHDO8YO7t4MEkw4zl3vo/ektJ83+yuLYzljIvtjwsMiCORVFICqeoq3RFAOyf4XK4BTrw6YP8AIsw34loxD5J+jZi3EOb52Rp0AehxuFg7ghqnncDHQL9yCTFHSDsr3NxyxTuw50 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: Use a folio in migrate_misplaced_page() to save compound_head() calls. Signed-off-by: Kefeng Wang --- mm/migrate.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 281eafdf8e63..fc728f9a383f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2521,17 +2521,18 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, int node) { pg_data_t *pgdat = NODE_DATA(node); + struct folio *folio = page_folio(page); int isolated; int nr_remaining; unsigned int nr_succeeded; LIST_HEAD(migratepages); - int nr_pages = thp_nr_pages(page); + int nr_pages = folio_nr_pages(folio); /* * Don't migrate file pages that are mapped in multiple processes * with execute permissions as they are probably shared libraries. */ - if (page_mapcount(page) != 1 && page_is_file_lru(page) && + if (page_mapcount(page) != 1 && folio_is_file_lru(folio) && (vma->vm_flags & VM_EXEC)) goto out; @@ -2539,29 +2540,29 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, * Also do not migrate dirty pages as not all filesystems can move * dirty pages in MIGRATE_ASYNC mode which is a waste of cycles. */ - if (page_is_file_lru(page) && PageDirty(page)) + if (folio_is_file_lru(folio) && folio_test_dirty(folio)) goto out; - isolated = numamigrate_isolate_folio(pgdat, page_folio(page)); + isolated = numamigrate_isolate_folio(pgdat, folio); if (!isolated) goto out; - list_add(&page->lru, &migratepages); + list_add(&folio->lru, &migratepages); nr_remaining = migrate_pages(&migratepages, alloc_misplaced_dst_folio, NULL, node, MIGRATE_ASYNC, MR_NUMA_MISPLACED, &nr_succeeded); if (nr_remaining) { if (!list_empty(&migratepages)) { - list_del(&page->lru); - mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + - page_is_file_lru(page), -nr_pages); - putback_lru_page(page); + list_del(&folio->lru); + node_stat_mod_folio(folio, NR_ISOLATED_ANON + + folio_is_file_lru(folio), -nr_pages); + folio_putback_lru(folio); } isolated = 0; } if (nr_succeeded) { count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded); - if (!node_is_toptier(page_to_nid(page)) && node_is_toptier(node)) + if (!node_is_toptier(folio_nid(folio)) && node_is_toptier(node)) mod_node_page_state(pgdat, PGPROMOTE_SUCCESS, nr_succeeded); } @@ -2569,7 +2570,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, return isolated; out: - put_page(page); + folio_put(folio); return 0; } #endif /* CONFIG_NUMA_BALANCING */