From patchwork Wed Aug 2 09:53:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13337931 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 9542AC001DF for ; Wed, 2 Aug 2023 09:45:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DCDF280112; Wed, 2 Aug 2023 05:45:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 179D9280145; Wed, 2 Aug 2023 05:45:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D824E280112; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BE424280143 for ; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 382D4C0DC9 for ; Wed, 2 Aug 2023 09:45:28 +0000 (UTC) X-FDA: 81078681936.01.1DC5DD5 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf06.hostedemail.com (Postfix) with ESMTP id 4135F180005 for ; Wed, 2 Aug 2023 09:45:24 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690969526; 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=1+Xi+YSKqKVg8IVlzQ0fkNKnjeMm7NKG82xUkYU+qiA=; b=2jqDwklx5F0ZfRr5k963RUMVoLS6CUZu4I6yCKDZ+sNzrf3WaZEfiM8kQcTc586uxj2b3q WabESbhrHik2bCEWZsSp01rJUZLlvdLtVVJ3Cbr+3BRamBu931bbHpYPjCQhsl7sj/OZSq 98NZVPtxjPSfaWOgapagwk84XM3ROGc= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690969526; a=rsa-sha256; cv=none; b=OFcd6stZAnowserkbW7FqsBxVq96jgLRhV6H0Bse2d52f6pQXZmi8NJxE7rptDf+xQOvNO Gorboq35EOvpJTNRlFKQWeu1+5BvxV1CJgUe0rSUIUkH1rcXOCJTzfupbAcf/pimMD/GWx LYuk6qsYe6yJWTKtL0nx8rnWiGRE4Wg= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RG6WQ4xLDz1GDP2; Wed, 2 Aug 2023 17:44:18 +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.27; Wed, 2 Aug 2023 17:45:20 +0800 From: Kefeng Wang To: Andrew Morton , , CC: Huang Ying , David Hildenbrand , Matthew Wilcox , Kefeng Wang Subject: [PATCH 3/4] mm: migrate: make migrate_misplaced_page() to take a folio Date: Wed, 2 Aug 2023 17:53:45 +0800 Message-ID: <20230802095346.87449-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802095346.87449-1-wangkefeng.wang@huawei.com> References: <20230802095346.87449-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: 9hz6bfr7skwa7apywn675mtxbti8zrpr X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4135F180005 X-HE-Tag: 1690969524-889481 X-HE-Meta: U2FsdGVkX1/kBRd6rBUSCZJQGydfB3PsXiKE+pvn0jl9JHax81LohoWIVsQ0qy7u1nRzysJbKcG0r43TLfYqwbkcgW1W3kiIYVJbWByG1lDVUVRy9s2ujL8CuIEn6/Sz+4m3qkepVEb2xGikAUjxlUF7DBlB7btBr/sLLTQ5PUckloGofhGDWLOnr1gWqRrpWi4dSPsRwnEZggXMWnlNt5tBXdQMhNUCKmKvqrtWGY/TCBzecpCcfe9wgf4QHxbIdLN5jGXLrO55Z2enZsQCWol5ej8CzxStYKV82cfZxmF5q1RYUcn5141Vm73GT68XvB+uaQsZNI4wqVaSM44eGhyhcg7ucGOxVxDP+BJ9YwKgBJO6LlwcIyXdQncehn47DSunEYOAfEV8pcAHaeFDUbqPKIrXsBXsV74n3qoU7g8WLnpRMdc8gUlXib1Ztn5cCfGdTwFXS18lSaESDC6VIwK4QML3OpKDmzwBfuV2EHvjb+aEcomZVG+AGMgShFrlckQHMwg8/WXbAYTEi8IuQcH+GfluyukdVKfGEC3JVoUnCFCA2n4Ys70pP7B3RfV+rwSbG+toDDD4Z9EAUcMPrNB7va7Q/bABWksr1oCH93rz0vfcKr0BEhtIeT7+xuuFcZubt1LqdVbh7QkrSNQ0+SzixbP59yp78K/EmRIJUiD2+dP3dsYrzucM8ZTmM8eI/U+3kzKKTSeA1AlKZt/VRuzj6HK03OcolPo069IejZedTZHaXYDonLf1OZ331QOfTAn+qzw6RG6BEcwbZoWI9f7JmlUPA0LilhU63qeK8mG+g/E/xHU/d733xDfsptSPVK/XqDNdON7iy+Z0rpdDSjpMEyWB3GyKXhFZxtRS/V10wzHT9iPUXzHZxMuJ3ZkyLkgBZ6WMulfdt0sUKzxNsfPK97ijFaysKhBlymtHNaiWKQDN4/n52BRTs3eQtQCKQ8L2xjZfoNHmmJDEgji yojGdubL U5qgjczmORwaQwyTwI3DP/CvuFkiNHOAb+8CDDhU0qczmAR3VD+joDonEJmKyXeWiHe6sSfhEBDRdpIskRsQ6JmAMBWKk/jA/QGHdJ9lttn6/5+/e5cgJKLHqcgBEZRYRifqMeYjeQfRG5XMEXDpCu1PM2o96Iqo4siMknN/X8nm1VB90GxmXSZTisRI+Dez36mSJ 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: Make migrate_misplaced_page() to take a folio and use folio API 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 39e0d35bccb3..4be61f944cac 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2525,17 +2525,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 (folio_estimated_sharers(folio) != 1 && folio_is_file_lru(folio) && (vma->vm_flags & VM_EXEC)) goto out; @@ -2543,29 +2544,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); } @@ -2573,7 +2574,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 */