From patchwork Wed Aug 2 09:53:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13337932 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 73F97C001DE for ; Wed, 2 Aug 2023 09:45:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF9C1280145; Wed, 2 Aug 2023 05:45:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D59EE280143; 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 BD496280145; Wed, 2 Aug 2023 05:45:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A097E280143 for ; Wed, 2 Aug 2023 05:45:29 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7CCE3160D7B for ; Wed, 2 Aug 2023 09:45:29 +0000 (UTC) X-FDA: 81078681978.20.EC7F3BD Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf18.hostedemail.com (Postfix) with ESMTP id 0E45A1C0010 for ; Wed, 2 Aug 2023 09:45:25 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.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=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=sKA63lWYPN2MF+P3BEUtg/sR22zgj0WfA+RU7kxoC38=; b=W8+obUt5UbtiIuNhV6q+y1xUbf7YM/78oiSyYD2W76+R7xvooEQTe6fQL9ZtBX2UNvV/h7 hLVyEmaNNhk0o6r8Gu9ThyHBIyOjVtvz0gK62kTZn4xITu4glfA6mU0ePyIdmcCFWEaoKB w5KnqmxYbs6sicpX/CrbIRhDqxrmVFA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690969526; a=rsa-sha256; cv=none; b=5yhMNlGC9ilIKD5eWgWHewXHxS8jjP9tmUzZOdbkkrReDIu4P9QvU+/YQg+z2594rnmN+Z y09sSgkzy9rGaGPFIpy8gAGodvoWSsOHqI6dtBpR1+0NOjqg7AY++F14NV5ghTWqlADnQ+ 1I4LnsDZq94Q/QAIdwumo9eXfhgJ8YU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.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 dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RG6TT1cQ1zLnxK; Wed, 2 Aug 2023 17:42:37 +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:19 +0800 From: Kefeng Wang To: Andrew Morton , , CC: Huang Ying , David Hildenbrand , Matthew Wilcox , Kefeng Wang Subject: [PATCH 1/4] mm: migrate: use a folio in add_page_for_migration() Date: Wed, 2 Aug 2023 17:53:43 +0800 Message-ID: <20230802095346.87449-2-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-Rspamd-Queue-Id: 0E45A1C0010 X-Rspam-User: X-Stat-Signature: 7oidiis1ui4nxafkr5pn9rpm7bfp5c6z X-Rspamd-Server: rspam03 X-HE-Tag: 1690969525-61908 X-HE-Meta: U2FsdGVkX19lCbSRzTo7Jljieb6N2pH5BeqnwcIhL/WM77MEDkDPNjHUFsQuf8+t7vsg4Q26jXogIRnAgw9cNXvXOe4pi9BvuV6s3E1qR5H4eehoe5mTo6/vMvyalwwcqiWTpAlY8FSPIxjs7C8Nsz69QWuJH76iaJexnLmIzGg17fD9D1vMKHzlBDQV9M2zMhdI4lyliRCVJT3K5UJp9kaXFwc4Kb563IfMdxTm8dd+36LIAFDOO4BjVFruSOwLwmpvnaT/2qIoeHTyKjd8uMx55X7xdJ7fydgyQPFyOP7whCjDWgDSQp7K3qAMRNlIOvpngQUbHZ1po8MG4YoWR8Bjbzay6SrLmqh3wK9KPuU2wkiCyXfb31Ku7xOvsip2NsetQ97PhBTtfqSMHaWX0LN/V2aNIAcs6QyuKn8JO4qgaYQVOXytSnw1vy6SM61P0WSqYYQYFqsqUuOFRQwm20bcpRC8XIpaTQ11s0eWrNHtYIYIbe2Zj9DKrQ/zefJp7MW564A73ISggULiwcJr9vtkxU5/8W+dQbXzvui1lljyMyGWPbIpT/lMsGJS1lScOH0Q5kCpRgWjF/cJ64cxEj7rPoj4I0BMgvMoTUMZf0UmR1/HaiTO3vOIZ6Oz47gG3a+GyuLQ4vITYc1vNIpbURU/zTtqtFQEAAau+oEBqkqW95uwx6RYWVDBFIekwG1gVnU09OU4jl2NeZHDBB5fxmGs9yTT7q1fqUHDmH74IBcAqrYv6GT5VKyrXKIv4/zTm12GSEacdNqv9gsxD5O5qvmfMnewrIAQ96KGf9Z2tfFVGnZlw02Dlg0xgOZElCYYAQYIhapG6qlhGMY+tApXicp0/FaPRR0qc1qeUUDlquEIfUzAm+I/l05m0is7qRZjCK/7kR0gK+hKwSoDZZrEdthD+qUz8Vb0PTI5Tjkvib7B2ZpEWKl93mONNRF82ohGlGnmdrsmuflBvbzDK2R FMaaz7fU QB98jkfDGvBnjAUAWsPSlWk16eC9R4RwkIcLesw+a1TqMcQYyegSJOO5vVv91u4BlaV/XQ6IDTmKOuIUSN8tJL/+ceA7cedv9YuoJ2KEuL+4RULW00meeNjUQ+65x2APLyDpdAc72L6J2zrolzE0uTlo2hwSt3oP/CdTdV50EXkYrGdQk9ujT9im3BJy/lULGUKmA 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 add_page_for_migration() to save compound_head() calls. Signed-off-by: Kefeng Wang --- mm/migrate.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index e21d5a7e7447..b0c318bc531c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2057,6 +2057,7 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, struct vm_area_struct *vma; unsigned long addr; struct page *page; + struct folio *folio; int err; bool isolated; @@ -2079,45 +2080,42 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, if (!page) goto out; - if (is_zone_device_page(page)) - goto out_putpage; + folio = page_folio(page); + if (folio_is_zone_device(folio)) + goto out_putfolio; err = 0; - if (page_to_nid(page) == node) - goto out_putpage; + if (folio_nid(folio) == node) + goto out_putfolio; err = -EACCES; - if (page_mapcount(page) > 1 && !migrate_all) - goto out_putpage; + if (folio_estimated_sharers(folio) > 1 && !migrate_all) + goto out_putfolio; - if (PageHuge(page)) { - if (PageHead(page)) { - isolated = isolate_hugetlb(page_folio(page), pagelist); + if (folio_test_hugetlb(folio)) { + if (folio_test_large(folio)) { + isolated = isolate_hugetlb(folio, pagelist); err = isolated ? 1 : -EBUSY; } } else { - struct page *head; - - head = compound_head(page); - isolated = isolate_lru_page(head); + isolated = folio_isolate_lru(folio); if (!isolated) { err = -EBUSY; - goto out_putpage; + goto out_putfolio; } err = 1; - list_add_tail(&head->lru, pagelist); - mod_node_page_state(page_pgdat(head), - NR_ISOLATED_ANON + page_is_file_lru(head), - thp_nr_pages(head)); + list_add_tail(&folio->lru, pagelist); + node_stat_mod_folio(folio, + NR_ISOLATED_ANON + folio_is_file_lru(folio), + folio_nr_pages(folio)); } -out_putpage: +out_putfolio: /* - * Either remove the duplicate refcount from - * isolate_lru_page() or drop the page ref if it was - * not isolated. + * Either remove the duplicate refcount from folio_isolate_lru() + * or drop the folio ref if it was not isolated. */ - put_page(page); + folio_put(folio); out: mmap_read_unlock(mm); return err; From patchwork Wed Aug 2 09:53:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13337929 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 C2F69C04A94 for ; Wed, 2 Aug 2023 09:45:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67D84280141; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62DA6280112; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D4E0280143; Wed, 2 Aug 2023 05:45:28 -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 284DB280141 for ; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E2F171C951A for ; Wed, 2 Aug 2023 09:45:27 +0000 (UTC) X-FDA: 81078681894.03.E3C3E9E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 312158001F for ; Wed, 2 Aug 2023 09:45:24 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=f7DiKVRoTUN5O+c/eQv/0iW0L2QwEutWFkDqyujwY4o=; b=btKOJqVhn+tP/QwhePCwxQ303IE9ML96a3LTSbd0Q99B3SKqf93zDSEinbFehUZVu+bjfW hBmKx+CPjLQHRj2GqRgfxl+zCCyd1rGZgcKegNqP5alKwcBjIC+FFNxDg5L7iCmrgKet3z LMVr64Z2FeJeIOD1+G4ZUqt4JQms16c= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=UJ+f6cWap7PE9NMORwAzokI1L8GpA1LY1/COeJnP4g7DbPpmriJN9b7vJjJdg8jMlCgLp7 1xyzHjiAmfzF2HRiq5eGknoOtSYUd5C8Jf+k2gaIkof2moPNLpJaiTTAzrrijqLNvN5pVm zXFHK91zSHNIrHiwXJAbOu7d326G7NU= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RG6Vb57BczVk0q; Wed, 2 Aug 2023 17:43:35 +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:19 +0800 From: Kefeng Wang To: Andrew Morton , , CC: Huang Ying , David Hildenbrand , Matthew Wilcox , Kefeng Wang Subject: [PATCH 2/4] mm: migrate: convert numamigrate_isolate_page() to numamigrate_isolate_folio() Date: Wed, 2 Aug 2023 17:53:44 +0800 Message-ID: <20230802095346.87449-3-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-Rspamd-Queue-Id: 312158001F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cz8jmapxz94g358q4oameq464p4fk5a1 X-HE-Tag: 1690969524-565787 X-HE-Meta: U2FsdGVkX18vJqHDUKCywIUibfyGmtzYeLqF0EfJ0axhgVEzrLTsNCjCCqv2MVb4tLV5lWM4lDK91PxW48tso9TfIpI+pH/d5LKvX7Nyie8FQSNDsedDgjxgmjKryFE/XDF2M7g4VYxuCT3O0JUv9UmbPuuV2BnBrdWcxeNWYmN3hPhzRL164kuTObkKrPxpC+qJCp1JNhsjgbAkYWbdLDxpREHk2d6bx+4wwyAYGFjMFuZWqSon71oXEn8zE/LXwz4s5xxWFYJq3UWnPoq2o3OwllgyX85qlhF3iPZhSC4IqTxCa9J7FGSzGxr+p/GC593uO0K/rhZ+D8gn8lU4vU0CBrPKdkWSnsn9AijgG20jZvd8ESSn6ubZJhVXDD8vcdunnK+uOiQRjYHS6MEFFqKchR0QsjvkpmKeGVlVjNYlzqdtH9Dka5l/eOTcbzpC7TBVGOgyIOJEOVEKzXPpzgWXIwxVG729+FGwh12AmJJ9fta20C0lvrd2qxGfrI0L3cB2/6z9UW9YFBB9KX4DSAEwA4rw3hGU/KskbVStdDhF66rJdBK07FZJ+j2+MPaDy7PHtDox5V+IOqXiFHC3WMwgbsjyDIisK+8rDM9m3tz83wLntwhdVEnapxlBoQxiSqUyRYVmXrEvjgv2dd+5UD4oflU6n42Ktrc1Jm4EEcZBVOYo/r2yrWhu4dfsf3XwrI3EdShwKSTg9ywbYVTa1f1PwH+isfyVwTCgOxXG0ztqFZi1TZnUpS298IjKRebx79kmNPrMxaIdLhaqaVWd772hRncLh6pzgnSAy22YZRsA4lBdvPDm/fmcFIctvzf4B4cFv3K16FDkuvltXHF7wu+ZqkZsjLLL7IA1hUlhXIg3HeDrTgWLvWGiYoxlrdjDEM+P/4S1oCifxeTrA0wjIdE7Qo8ZDTJ1mo34VmEtifPjTWK8RjXHi7F9O5VcGChJa/IY+C5/SPLMHjE8EXv wGq8aKl7 0vwsqfWkd4jN8h3EMg32uJZVM5bfvYCvLXHTRSzvwvrn8mbe2qGq5Z/q377EyX60Br6OyRyJSjTI/bbCsDx+yrCjICCf2su07neIy7fN2htc43HCI9VgugnzFDMlR5K7MQQ4ByvOLoAflk5Ar6S4BljcXdx5yEwt4+sKvuBXwAyoYe2Z8Rul5Wg4hPywBnVe0PQ3P 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: Rename numamigrate_isolate_page() to numamigrate_isolate_folio(), then make it takes a folio and use folio API to save compound_head() calls. Signed-off-by: Kefeng Wang --- mm/migrate.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index b0c318bc531c..39e0d35bccb3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2476,15 +2476,15 @@ static struct folio *alloc_misplaced_dst_folio(struct folio *src, return __folio_alloc_node(gfp, order, nid); } -static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) +static int numamigrate_isolate_folio(pg_data_t *pgdat, struct folio *folio) { - int nr_pages = thp_nr_pages(page); - int order = compound_order(page); + int nr_pages = folio_nr_pages(folio); + int order = folio_order(folio); - VM_BUG_ON_PAGE(order && !PageTransHuge(page), page); + VM_BUG_ON_FOLIO(order && !folio_test_pmd_mappable(folio), folio); /* Do not migrate THP mapped by multiple processes */ - if (PageTransHuge(page) && total_mapcount(page) > 1) + if (folio_test_pmd_mappable(folio) && folio_estimated_sharers(folio) > 1) return 0; /* Avoid migrating to a node that is nearly full */ @@ -2501,18 +2501,18 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) return 0; } - if (!isolate_lru_page(page)) + if (!folio_isolate_lru(folio)) return 0; - mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + page_is_file_lru(page), + node_stat_mod_folio(folio, NR_ISOLATED_ANON + folio_is_file_lru(folio), nr_pages); /* - * Isolating the page has taken another reference, so the - * caller's reference can be safely dropped without the page + * Isolating the folio has taken another reference, so the + * caller's reference can be safely dropped without the folio * disappearing underneath us during migration. */ - put_page(page); + folio_put(folio); return 1; } @@ -2546,7 +2546,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, if (page_is_file_lru(page) && PageDirty(page)) goto out; - isolated = numamigrate_isolate_page(pgdat, page); + isolated = numamigrate_isolate_folio(pgdat, page_folio(page)); if (!isolated) goto out; 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 */ From patchwork Wed Aug 2 09:53:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13337930 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 AD08AC001DE for ; Wed, 2 Aug 2023 09:45:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBB0E280144; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E6C0B280143; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0B8F280144; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BC045280112 for ; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7CD07C0DF4 for ; Wed, 2 Aug 2023 09:45:28 +0000 (UTC) X-FDA: 81078681936.29.0B43677 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf22.hostedemail.com (Postfix) with ESMTP id 39E50C0005 for ; Wed, 2 Aug 2023 09:45:25 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=C9SLzI1jBQxZ3MenzIaKU+m294r5B3MM6jSUBENnZOM=; b=2hoYdvHsatABphCExfUcMpsyTe/9EEXUVpXcUXzIeALUp8Xy05fIBw+ENFAKVYSvgXyFj4 btrdgGg42Lp92SAH74BwtaXIOOXr0qB+fyM9X/HZzL0hAIw06LviDwQH1zCNOV8Nj6HNqS dyF2gsjVpWxEhp3ytXiZ5wgG65vKJOU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=xXonfRRohHz5diLjuNdVUjK7s45dUtPu6gH1+eRenSJhIuGvKGI3KCogmFP1LRiQ3oucP/ vil0LOKeb2sh4z8C+H9oOlTDY2yTAIhqdrukR6wxfAnoHcJsczzD3ddb27hvKSYnXaicab bgV3oWELOGCEkruD4roPipZFyfMcdNA= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RG6WQ2pXczrS1v; 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 4/4] mm: migrate: use __folio_test_movable() Date: Wed, 2 Aug 2023 17:53:46 +0800 Message-ID: <20230802095346.87449-5-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-Rspamd-Queue-Id: 39E50C0005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 8g91c3c1otgype94fm3kd4s8isb8ba7u X-HE-Tag: 1690969525-689809 X-HE-Meta: U2FsdGVkX1+4jYZbsPtSyGj5SBcONAol4G17+cZYU8CQqzFbnWysjb9fjT/4psgNJJBpe8EZBrJfcnzrqJp3K7MfXt1psIy/rhWVqVQL7fS+pxSDJRhPbFemybwjxKOdQK8NRTtmpph0HRoqL8qPWeQVdzHjY8Z2SLQVwxYCckOt3+MI7LnhmcDzGbsiaMTHgzOgqKuDwo/dv+ntzG8BuSjvBPqZmCCcHKniLddIh8AmF28QWlOPMDxU95vexV7LI989OjixCPd4eNca9++icPvJQoRCvY16X9JvYDJim9o9Mjy9+4LMdgO05OdS1BTKBD4zui5X4PycqAeXTzt7i+D+mD7FVTULr6WXi95/i0eJhHuoRFpCZz8Kjj11WbGhiCnXGbzhgSOjnh0bkJafwV+z8GBqaJvycK3yMPVHlRlWvVHFtPzDy3pmG4KlErZ2qBW/QunNvk8McjplDRIoenz6wHYnen7xlMnsikY/YvKAL/PRXY7Bv4ccJG0fcI6GZa/bDiEY6301tKsbddwB29OGjCHihsUi+D68rymfRYsyFLwgF78Z+CndiD46CHe4Y+0uvByHPK8DknjOm/RUOt0spqB3nGZRcPKdiae9sOey+fkjN39++NvOFsMK4hpa37Pc1GSnpAONo18qOlISjIvD2nbm6QsptItTlAqBoSD+4hLe8+FAKEHkVQ9NbQT9PSOuIK/qpfz7e4pyRGDm9uWD1q5ee774rGZCEG13ogux3O2y3G4VSH/NVAAMPpDN7bSI924GZAs1LUJt1g4jm6YY5HIToi5W7ff5/8ntp2kHDDmYuTiAu3IaJyw1Ho3+eo/JV5PD0TFW9K5QjqTlIQNIzzw6/q0C7K8LYlCNHmM2a6ogx+ZkGrE0USL8jpV8zzGzmZei7j9CIikO7MtwTwrC2hkSPPzYWqxIhWzsfIt8FB+zov55/5e1+tV8tR6KNRVz4ujt0gBzgm4wTZx bGGH+Vea xnmdNWtvVBV65rP+edkxeV0BR7/JUJaT3dm7JeVTR+kSc60rhmbIanhJBoTHxViaTxq82GnXp7bbTiHvEbDkj649GF9YMenLGC54Bb+E4H7O5lSTqxC04XYv8tGuEq/ILw7DHnx0JD2Od3iP2hqAufBDrMLBBh1y2o4g5GAtVFPaOylyCV0TCeWmwacsAWTDrIcwD 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 __folio_test_movable(), no need to convert from folio to page. Signed-off-by: Kefeng Wang Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- mm/migrate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 4be61f944cac..8590e6f68cf3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -157,8 +157,8 @@ void putback_movable_pages(struct list_head *l) list_del(&folio->lru); /* * We isolated non-lru movable folio so here we can use - * __PageMovable because LRU folio's mapping cannot have - * PAGE_MAPPING_MOVABLE. + * __folio_test_movable because LRU folio's mapping cannot + * have PAGE_MAPPING_MOVABLE. */ if (unlikely(__folio_test_movable(folio))) { VM_BUG_ON_FOLIO(!folio_test_isolated(folio), folio); @@ -943,7 +943,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src, enum migrate_mode mode) { int rc = -EAGAIN; - bool is_lru = !__PageMovable(&src->page); + bool is_lru = !__folio_test_movable(src); VM_BUG_ON_FOLIO(!folio_test_locked(src), src); VM_BUG_ON_FOLIO(!folio_test_locked(dst), dst); @@ -990,7 +990,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src, * src is freed; but stats require that PageAnon be left as PageAnon. */ if (rc == MIGRATEPAGE_SUCCESS) { - if (__PageMovable(&src->page)) { + if (__folio_test_movable(src)) { VM_BUG_ON_FOLIO(!folio_test_isolated(src), src); /* @@ -1082,7 +1082,7 @@ static void migrate_folio_done(struct folio *src, /* * Compaction can migrate also non-LRU pages which are * not accounted to NR_ISOLATED_*. They can be recognized - * as __PageMovable + * as __folio_test_movable */ if (likely(!__folio_test_movable(src))) mod_node_page_state(folio_pgdat(src), NR_ISOLATED_ANON + @@ -1103,7 +1103,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio, int rc = -EAGAIN; int page_was_mapped = 0; struct anon_vma *anon_vma = NULL; - bool is_lru = !__PageMovable(&src->page); + bool is_lru = !__folio_test_movable(src); bool locked = false; bool dst_locked = false; @@ -1261,7 +1261,7 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, int rc; int page_was_mapped = 0; struct anon_vma *anon_vma = NULL; - bool is_lru = !__PageMovable(&src->page); + bool is_lru = !__folio_test_movable(src); struct list_head *prev; __migrate_folio_extract(dst, &page_was_mapped, &anon_vma);