From patchwork Thu Apr 25 08:40:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642973 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 9D043C4345F for ; Thu, 25 Apr 2024 08:41:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4484B6B0096; Thu, 25 Apr 2024 04:41:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D02C6B0098; Thu, 25 Apr 2024 04:41:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FBB36B0099; Thu, 25 Apr 2024 04:41:00 -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 EAA496B0096 for ; Thu, 25 Apr 2024 04:40:59 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id ADD67A02BD for ; Thu, 25 Apr 2024 08:40:59 +0000 (UTC) X-FDA: 82047409038.13.A7763A9 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf24.hostedemail.com (Postfix) with ESMTP id 3EF8C180006 for ; Thu, 25 Apr 2024 08:40:56 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1714034457; 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=E7dPOxBvOKe8/N4E9S0tVuEJ4SDbdNO2vHKS/hkN1eM=; b=a9zUhtXgLcaGlLjy3w22jmvn/cSGarMoE91z0AdGdE7khtJD6xM11NeTCkV2m3uY5wU8uQ 3CPTD9hdCPtbUsaRRDSjmX9sjRK2o2KWHcJFGLGOf6IGh5KV8rGJvBH3ZfXMRjoFgUPBhi 3twfxTNwhgVBCi/pp01hK+yJiII/DD4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034457; a=rsa-sha256; cv=none; b=wkvpIhTuqSxVB7VfFv8uiP2PveT6aqq/vH1JEHLhZJiYnVwI2IuO2FDt5Wc/ZKjUrzwuO7 DIQObAEjrJ1EPIpUqhbtEmEDREscHTzae4KZzBX3JGk7hz8vYXfnO9VXxi/WuuMYzhXWRP 7o1VCmWJ2qbXXDSOGZzR1ibI6Jfs3wk= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4VQ8Rq67s7z1wtZw; Thu, 25 Apr 2024 16:39:51 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id D9F9A1402CB; Thu, 25 Apr 2024 16:40:53 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 25 Apr 2024 16:40:53 +0800 From: Kefeng Wang To: Andrew Morton CC: , David Hildenbrand , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Zi Yan , Hugh Dickins , Jonathan Corbet , , Vishal Moola , Kefeng Wang Subject: [PATCH v2 10/10] mm: remove isolate_lru_page() Date: Thu, 25 Apr 2024 16:40:28 +0800 Message-ID: <20240425084028.3888403-11-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240425084028.3888403-1-wangkefeng.wang@huawei.com> References: <20240425084028.3888403-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-Stat-Signature: kbdncamno33pn7kreubgqfn7p5azfjwn X-Rspamd-Queue-Id: 3EF8C180006 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1714034456-550037 X-HE-Meta: U2FsdGVkX18kFzKpDh8KhcaIMq5Hwf3NrYAOAAet2SM7WJGe7P4qbhtdVnduZ/jd7n9o/nNn2jgp9LuE7Z5MP4RZ5bwZUHj0A45K7fff8Bvp8i+deFmJ/5Nic/Vv2mGKX+YNmcz3+k9ZQo9HOV8THo+JyJD4tcnix3k4+AH7oocvywDUukJ/z1w4uAuWxiyMRPNlUubGMfNfKpXt9BjqVugBLurVhQVx5O/ZQjrcPKcQ74kRNf4p469CScLuD35qW49cudV+e1rKyw+z1TgIKcs+/6QvP2uB/vOtM6pjdP76tB7ZZj7Tf8dq45mtISVS/4J8iAW1nbxuBayboG5H2UfT2cK3/DM+AamEQa8WEgGyoxoK/UmuC0DNILZUgWauEXzswlFzFL6tN+kL6DN3vdIbm1RsSAGRIip1r7mb0EzMt+4PkYp2/Hm9skEpM+FcJohe/Ig1688R6yaUM3acjj3JI7RksjADQCku3LwHERk4+04aBB4t4U8Mmreb0DUMC240F/VwuxYtHSmw/yYCeffrtCtzwf21ew7O4yVb6Yo9RJV2kHaizrr8gkqq8UkO6c83aUcEcHeqw2td2oVk3qQ8N9oNVOYCnCjPtw/u/XK7GV8h6jyMceoeWqOs0WMIG9TKtTqo+8ED6fKva6Is6ge15OyMM0Qw1ndKxssn7LUVYUj81KfaDVzBB8vcTcxIDjaJFA96jtACTS6PbjkfdhEMKL6NguEsWysLoipovs2oG73vecGRmxWSL4sprfogKGkspIkU+emryh+vPhrNdg7S1+45RhkcRNhmwlOCKilo5a/XDZAos7lmpROoRgo9dLLbNzRvqtfOyNUXsAAxpUCeD6+0iDST3dohbeT5Up4hFALw7Ga4mSEvAzIMd/FFmjgg3louy1xkvvmsRvvq8kwx8PiR6RQRAEKuqqSKIm0RTyUGo2cvAsMctGh6ShJUYU5Zaa8TniwEuW/utWh R3b/NKAa JtDHsOAt4q626KE4yLreoeyKn/0p1WYHTmPYult6Rqq4zRGQG6OqYQUrjI0SfarjPCKe0diPYSm6feRs/Kn+02D8TFdUYqJRQJKoeXjQzQa3CBRrVYjoO6cPZ0T0rDI0OmHWnQv+gnk5P2Y7mjOvvfjeCrZHlfR6zTt2KebKLJuZvxPE3+AQbKMlGgOyNYcPDJcjpk8McJ9Kx/Nye6J1mrckY60stdBeoRUbig8YbEQGCbfBdYfMwz43HI4Ipqi5idqD9ntwpRcE5BJ5zg2+vMB6u7flKoSKJWTr0PxkqK4iXRnw= 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: There are no more callers of isolate_lru_page(), remove it. Signed-off-by: Kefeng Wang --- Documentation/mm/page_migration.rst | 6 +++--- Documentation/mm/unevictable-lru.rst | 2 +- Documentation/translations/zh_CN/mm/page_migration.rst | 6 +++--- mm/filemap.c | 2 +- mm/folio-compat.c | 7 ------- mm/internal.h | 1 - mm/khugepaged.c | 6 +++--- mm/migrate_device.c | 2 +- mm/swap.c | 2 +- 9 files changed, 13 insertions(+), 21 deletions(-) diff --git a/Documentation/mm/page_migration.rst b/Documentation/mm/page_migration.rst index f1ce67a26615..0046bbbdc65d 100644 --- a/Documentation/mm/page_migration.rst +++ b/Documentation/mm/page_migration.rst @@ -67,8 +67,8 @@ In kernel use of migrate_pages() Lists of pages to be migrated are generated by scanning over pages and moving them into lists. This is done by - calling isolate_lru_page(). - Calling isolate_lru_page() increases the references to the page + calling folio_isolate_lru(). + Calling folio_isolate_lru() increases the references to the page so that it cannot vanish while the page migration occurs. It also prevents the swapper or other scans from encountering the page. @@ -86,7 +86,7 @@ How migrate_pages() works migrate_pages() does several passes over its list of pages. A page is moved if all references to a page are removable at the time. The page has -already been removed from the LRU via isolate_lru_page() and the refcount +already been removed from the LRU via folio_isolate_lru() and the refcount is increased so that the page cannot be freed while page migration occurs. Steps: diff --git a/Documentation/mm/unevictable-lru.rst b/Documentation/mm/unevictable-lru.rst index b6a07a26b10d..de3511c8d82d 100644 --- a/Documentation/mm/unevictable-lru.rst +++ b/Documentation/mm/unevictable-lru.rst @@ -230,7 +230,7 @@ In Nick's patch, he used one of the struct page LRU list link fields as a count of VM_LOCKED VMAs that map the page (Rik van Riel had the same idea three years earlier). But this use of the link field for a count prevented the management of the pages on an LRU list, and thus mlocked pages were not migratable as -isolate_lru_page() could not detect them, and the LRU list link field was not +folio_isolate_lru() could not detect them, and the LRU list link field was not available to the migration subsystem. Nick resolved this by putting mlocked pages back on the LRU list before diff --git a/Documentation/translations/zh_CN/mm/page_migration.rst b/Documentation/translations/zh_CN/mm/page_migration.rst index f95063826a15..8c8461c6cb9f 100644 --- a/Documentation/translations/zh_CN/mm/page_migration.rst +++ b/Documentation/translations/zh_CN/mm/page_migration.rst @@ -50,8 +50,8 @@ mbind()设置一个新的内存策略。一个进程的页面也可以通过sys_ 1. 从LRU中移除页面。 - 要迁移的页面列表是通过扫描页面并把它们移到列表中来生成的。这是通过调用 isolate_lru_page() - 来完成的。调用isolate_lru_page()增加了对该页的引用,这样在页面迁移发生时它就不会 + 要迁移的页面列表是通过扫描页面并把它们移到列表中来生成的。这是通过调用 folio_isolate_lru() + 来完成的。调用folio_isolate_lru()增加了对该页的引用,这样在页面迁移发生时它就不会 消失。它还可以防止交换器或其他扫描器遇到该页。 @@ -65,7 +65,7 @@ migrate_pages()如何工作 ======================= migrate_pages()对它的页面列表进行了多次处理。如果当时对一个页面的所有引用都可以被移除, -那么这个页面就会被移动。该页已经通过isolate_lru_page()从LRU中移除,并且refcount被 +那么这个页面就会被移动。该页已经通过folio_isolate_lru()从LRU中移除,并且refcount被 增加,以便在页面迁移发生时不释放该页。 步骤: diff --git a/mm/filemap.c b/mm/filemap.c index fc784259f278..a28d05c54dd4 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -113,7 +113,7 @@ * ->private_lock (try_to_unmap_one) * ->i_pages lock (try_to_unmap_one) * ->lruvec->lru_lock (follow_page->mark_page_accessed) - * ->lruvec->lru_lock (check_pte_range->isolate_lru_page) + * ->lruvec->lru_lock (check_pte_range->folio_isolate_lru) * ->private_lock (folio_remove_rmap_pte->set_page_dirty) * ->i_pages lock (folio_remove_rmap_pte->set_page_dirty) * bdi.wb->list_lock (folio_remove_rmap_pte->set_page_dirty) diff --git a/mm/folio-compat.c b/mm/folio-compat.c index f31e0ce65b11..3e72bec05415 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -99,13 +99,6 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping, } EXPORT_SYMBOL(grab_cache_page_write_begin); -bool isolate_lru_page(struct page *page) -{ - if (WARN_RATELIMIT(PageTail(page), "trying to isolate tail page")) - return false; - return folio_isolate_lru((struct folio *)page); -} - void putback_lru_page(struct page *page) { folio_putback_lru(page_folio(page)); diff --git a/mm/internal.h b/mm/internal.h index e3968061010b..2a6c451cab97 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -383,7 +383,6 @@ bool isolate_folio_to_list(struct folio *folio, struct list_head *list); /* * in mm/vmscan.c: */ -bool isolate_lru_page(struct page *page); bool folio_isolate_lru(struct folio *folio); void putback_lru_page(struct page *page); void folio_putback_lru(struct folio *folio); diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 2f73d2aa9ae8..bdd926fac5f4 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -607,7 +607,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, } /* - * We can do it before isolate_lru_page because the + * We can do it before folio_isolate_lru because the * page can't be freed from under us. NOTE: PG_lock * is needed to serialize against split_huge_page * when invoked from the VM. @@ -1847,7 +1847,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, result = SCAN_FAIL; goto xa_unlocked; } - /* drain lru cache to help isolate_lru_page() */ + /* drain lru cache to help folio_isolate_lru() */ lru_add_drain(); } else if (folio_trylock(folio)) { folio_get(folio); @@ -1862,7 +1862,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, page_cache_sync_readahead(mapping, &file->f_ra, file, index, end - index); - /* drain lru cache to help isolate_lru_page() */ + /* drain lru cache to help folio_isolate_lru() */ lru_add_drain(); folio = filemap_lock_folio(mapping, index); if (IS_ERR(folio)) { diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 423d71ad736a..a625f4694b56 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -328,7 +328,7 @@ static bool migrate_vma_check_page(struct page *page, struct page *fault_page) /* * One extra ref because caller holds an extra reference, either from - * isolate_lru_page() for a regular page, or migrate_vma_collect() for + * folio_isolate_lru() for a regular page, or migrate_vma_collect() for * a device page. */ int extra = 1 + (page == fault_page); diff --git a/mm/swap.c b/mm/swap.c index f0d478eee292..b298af23d713 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -918,7 +918,7 @@ atomic_t lru_disable_count = ATOMIC_INIT(0); /* * lru_cache_disable() needs to be called before we start compiling - * a list of pages to be migrated using isolate_lru_page(). + * a list of pages to be migrated using folio_isolate_lru(). * It drains pages on LRU cache and then disable on all cpus until * lru_cache_enable is called. *