From patchwork Thu Apr 25 08:40:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642967 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 A1CCBC4345F for ; Thu, 25 Apr 2024 08:41:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C35486B0089; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D8616B0087; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B9F46B0095; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0C4146B0089 for ; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ABF858045C for ; Thu, 25 Apr 2024 08:40:55 +0000 (UTC) X-FDA: 82047408870.05.267A639 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf10.hostedemail.com (Postfix) with ESMTP id 535D3C000B for ; Thu, 25 Apr 2024 08:40:51 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1714034454; 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=9XE27iMZAYmpUQWxEPn0jlvkOw792lA4y9C2bFT42BE=; b=Ils+gO5VnTYuiiijvJqUf9zkmDJO6M+uiepUyySyKNS8FFNT3GQ7BvG5QSlh9W6rwSX2db 1/Qs5a0/iCSSFcsPjjYdPKy7e6UNnIyJM+b4TT8R+egBNy9XJf9n0M/wIFycwPZQ5RWKDd W38gyPYhGKmv9d13jHcysNSpBRpdksg= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034454; a=rsa-sha256; cv=none; b=1VoVd+SFZlIEYqgW+PCJmBYQpjYZDQ3LqBr++oR1ZpEdRVKVyDuSWOgjuTz9J3+qbwXcV9 azlWhpypd7Zi/7ToEFeOLpTx/2DxavDfkrw7AjZsVa6tNft4rI/RHaHhzs34xbe0uEUbJE jYs2r0/+vq5KACbifi9NVRiQVacH1Fc= Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VQ8Rg4NhDzcbyj; Thu, 25 Apr 2024 16:39:43 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id A16401403D3; Thu, 25 Apr 2024 16:40:48 +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:48 +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 01/10] mm: memory_hotplug: check hwpoisoned page firstly in do_migrate_range() Date: Thu, 25 Apr 2024 16:40:19 +0800 Message-ID: <20240425084028.3888403-2-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-Rspamd-Queue-Id: 535D3C000B X-Stat-Signature: wh5ucy5nyuihdqg97id56u6wgmgewpam X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1714034451-300054 X-HE-Meta: U2FsdGVkX1+uR9vdl/IaTu4BDxdQs0OETIwVkG70XmoKDJ0Tqs9z65YnlojWk/yvb2KhwyzcIDVTsbVehjTyKEN3yENajmfbgeeaVLorwV1WL6nHwuAEajITbiQ9w4MpILS1CSWXoaHjCtmDq2u1sGuorEoCY5qZPVqLkL6TzL0CBboCWksVvOARp+1w+m+UK/8y9XvpbVybMXqJeirkmLv+SI4vu7MZBjw6jd1NJ7mzAd96J5nT7y0pTRDImSGLQ+0OYOogGYfyS2Ttt76lvx6+DyyZHa4ztf4rdbnh5arsYKkhL5q7ng0KiIeM2Et9Mj2xcFBo6GfzZqWpP2WQDJhlW8v11lotaswsorHvG/lM+dJ8PAeBECTdzK+cKHOTpmodYT+RElpSV5rgDTi4q7F21sr34KrZR8UshkcRc6Ua8dl/y5fvo8Mma4JK5hfWfqfKSFHtPWUHhV4aOLfZ32Jf8AtKr4lsG6Ac/NFElb79sgf/voWfunHT+RjIKu+quDa6bnLDZsr1ZU149hWu3ct27NBH0+BjUWNQLh3oEP2/+s4Qj1+6qXEnmcaeh6bx7V3Hk0IwppkjJ7K44ziCaav2O4oECoAweNm0lb1M2mXx/UCaDEVYXdx+Gowc11mkPzbBS+cbCamSgbJUHasta/pahwrnDedorNmDJ0mM68JwNMYuepNrs9499BAgvJNdWKRK74hMYYyN6PCkFO4ApflXJWcc0IEgNHJe5WsTx5rbUSoqq7fyYW0NMyBhFihU8lMXbEGQAB04YHAQniZjpVTAWw3aBbt7rwxTWvHM36GdpnGhNHDkg6Xk+JjziYGEO1j8EE2XBzvj6ou96xr6PvUiv7QWTp43hU87eJw+UZUy0seUZcCAd9OrEYRGxdC6brVBJTEpAafA5TTP7MTmzV5VA5lVRydykwNZf2EEsEPLXLT9n+GTSIjXpaRD01uHZd0vg7hM6KEb21eM6Xb TmLjI7M8 O6kzD3DKWiNjN8mT+FqwthkyIabAvy7NcrGgpx6u9bfwi48qwcldGJRMMUMdjbaThxHFuBk7qJqAsACLar7WeidlUdHcok28gYWjwwB6F60/m+d+UHzATVzztdKhq2bxw4w1YLq8Cv+R8N2IzhmOgwoGxFiPtDGwh+7WTu2DoiKQ1VAJFpTh8UVjImIxQoZaXVLzympPOoPLIf7hH5tzfxTTbHyQmIcFq8JgTaxbpPne4FCXHSRPztox0sZsV4KHFpb/KDmCKNw0tVaU= 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: The commit b15c87263a69 ("hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined") don't handle the hugetlb pages, the dead loop still occur if offline a hwpoison hugetlb, luckly, with commit e591ef7d96d6 ("mm,hwpoison,hugetlb,memory_hotplug: hotremove memory section with hwpoisoned hugepage"), the HPageMigratable of hugetlb page will be clear, and the hwpoison hugetlb page will be skipped in scan_movable_pages(), so the deed loop issue is fixed. However if the HPageMigratable() check passed(without reference and lock), the hugetlb page may be hwpoisoned, it won't cause issue since the hwpoisoned page will be handled correctly in the next scan_movable_pages() loop, it will be isolated in do_migrate_range() and but fails to migrated, In order to avoid this isolation and unify all hwpoisoned page handling. let's unconditionally check hwpoison firstly, and if it is a hwpoisoned hugetlb page, try to unmap it as the catch all safety net like normal page does, also add some warn when the folio is still mapped. Signed-off-by: Kefeng Wang --- mm/memory_hotplug.c | 62 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 431b1f6753c0..1985caf73e5a 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1772,6 +1772,35 @@ static int scan_movable_pages(unsigned long start, unsigned long end, return 0; } +static bool isolate_and_unmap_hwposion_folio(struct folio *folio) +{ + if (WARN_ON(folio_test_lru(folio))) + folio_isolate_lru(folio); + + if (!folio_mapped(folio)) + return true; + + if (folio_test_hugetlb(folio) && !folio_test_anon(folio)) { + struct address_space *mapping; + + mapping = hugetlb_page_mapping_lock_write(&folio->page); + if (mapping) { + /* + * In shared mappings, try_to_unmap could potentially + * call huge_pmd_unshare. Because of this, take + * semaphore in write mode here and set TTU_RMAP_LOCKED + * to let lower levels know we have taken the lock. + */ + try_to_unmap(folio, TTU_IGNORE_MLOCK | TTU_RMAP_LOCKED); + i_mmap_unlock_write(mapping); + } + } else { + try_to_unmap(folio, TTU_IGNORE_MLOCK); + } + + return folio_mapped(folio); +} + static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) { unsigned long pfn; @@ -1790,28 +1819,33 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) folio = page_folio(page); head = &folio->page; - if (PageHuge(page)) { - pfn = page_to_pfn(head) + compound_nr(head) - 1; - isolate_hugetlb(folio, &source); - continue; - } else if (PageTransHuge(page)) - pfn = page_to_pfn(head) + thp_nr_pages(page) - 1; - /* * HWPoison pages have elevated reference counts so the migration would * fail on them. It also doesn't make any sense to migrate them in the * first place. Still try to unmap such a page in case it is still mapped - * (e.g. current hwpoison implementation doesn't unmap KSM pages but keep - * the unmap as the catch all safety net). + * (keep the unmap as the catch all safety net). */ - if (PageHWPoison(page)) { - if (WARN_ON(folio_test_lru(folio))) - folio_isolate_lru(folio); - if (folio_mapped(folio)) - try_to_unmap(folio, TTU_IGNORE_MLOCK); + if (unlikely(PageHWPoison(page))) { + folio = page_folio(page); + if (isolate_and_unmap_hwposion_folio(folio)) { + if (__ratelimit(&migrate_rs)) { + pr_warn("%#lx: failed to unmap hwpoison folio\n", + pfn); + } + } + + if (folio_test_large(folio)) + pfn = folio_pfn(folio) + folio_nr_pages(folio) - 1; continue; } + if (PageHuge(page)) { + pfn = page_to_pfn(head) + compound_nr(head) - 1; + isolate_hugetlb(folio, &source); + continue; + } else if (PageTransHuge(page)) + pfn = page_to_pfn(head) + thp_nr_pages(page) - 1; + if (!get_page_unless_zero(page)) continue; /* From patchwork Thu Apr 25 08:40:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642966 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 1FC88C19F4E for ; Thu, 25 Apr 2024 08:40:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 866596B0092; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 778706B008A; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A8196B008C; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0AE3D6B0087 for ; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 85816140480 for ; Thu, 25 Apr 2024 08:40:55 +0000 (UTC) X-FDA: 82047408870.23.4A648EE Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf02.hostedemail.com (Postfix) with ESMTP id CCE648000B for ; Thu, 25 Apr 2024 08:40:52 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034453; a=rsa-sha256; cv=none; b=13tABhgiqeaR7VCv73JjN4l1Qn3E6dytzMfaLRbiCZi9d2zIci4+EcMqoFKVZh2SJM/2YA e3zhfNFtgM4rJtgn7cy1BignSMprozM4lD1SalXu4Ex5BGUTCTar7YWXWA9uWzOkOUYcT+ mxZhQMHp0IRRf0z5/TBZ5hND+8D+XyE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.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=1714034453; 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=jMcGND5JzvfOIQ3yEYYI6abptlC3TzE6FGd8qMzjE8Q=; b=oIEtyYgm+PvpOoyFVjsqGWPSWCvN+2x54PGkl1l3QdFQeZBKSYbSWruxzWBLdXPEpwmc7Z p8hDMeXU2kSMSzR0kk9mJZUbJPoOaarM7tramFtTXyRpPnDFbzg4GJhxYkvBviX6DOZs4I 85JR8NGDRW3kQBiETGHWTRWCod14S0I= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4VQ8Rk69jJz1HBkD; Thu, 25 Apr 2024 16:39:46 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 40FDA1A016F; Thu, 25 Apr 2024 16:40:49 +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:48 +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 02/10] mm: add isolate_folio_to_list() Date: Thu, 25 Apr 2024 16:40:20 +0800 Message-ID: <20240425084028.3888403-3-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-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CCE648000B X-Stat-Signature: winjwmrhycmecbsyiagi1jwmax8fgwbz X-Rspam-User: X-HE-Tag: 1714034452-784830 X-HE-Meta: U2FsdGVkX1/9Crp3gTGMBqWW4bnNsJS/3RWu+JCGRxc2pywu9A4cfl6vhHObyYyVNFwCbbzScyZ/JkIN4pYzDuQBNOebf7Ty9pFBWHd35QqM8PKpLl3WwktEQJ+6vRNgaF3ZEBnG1U46VDVVtWKNtT1bM1ksrKFB4g9bnQ6TSVMscPFK1+N5FMEoY4mapw5BEzytTGnhFovddkVc75Cfpl1EM25mtsETGGPYQc7RsZX0hCNzq2RiGofn+1b9Y5Og8jsMb7SoyS0uSULretciLP7fmepITKm/MixWdc1obCRen+x+ZYgFc9acr9PFI0OcY9eJ0xAeQ6s0MBPo2R2vlMovgFH3Oawe0+1rMbCMc7bl37d37hf05C+MKAb1shzSK67+cqK47hpbnEQr7esFIjS7F3TH5CNDrqgXA8M2lEC6/eTE/uBoEWeqdx+oqGN2ysr9ZwB7LSAiFy9ECIZGxV6jT+TPzcgKaEnngKWHSmtm0WStciYdan6vwDROyCKi/g2LBu4rjUD1BhlRSO0pGoqbjTNtv+x8+RLlCS4Ep1rgF7lQsIt6XsMGc6h9AOYzinzwy+47/zrxTX7WjvRJTdFYuGST9Rgz9jg0sySiug7yi7oSwO0lL8IauXUJSNSqT4S4APrPsS+C0aGl/R40NDR8VLdDIupG9UkszBInL5WHdgNJIskEQivD7UxLmpguO026ybh3s90dyyNPBCKgbuwHwRld9T/xVLBpVj1oYbEwNFpTp/QSww1yM2Rmt4c/AyLSQ8pPhOBydRJq4IVltwNBKuH2wAgs74v3xI9J13I4U7bEI9fTzt5a3dWVBUSxwOZcGUqxJlLBbgOlbJwWbnHFzCYFHgSeeqV6HQCzg92R/YpOGJ6/F4KS/L6ZDkXjOI+h122BSlKzyvH2KfvcFu+Zi9q4BJ/2toiJRhEfAOl2SSA1Ddz7+1oWdu1+zIOX3fzN5J/PmMFlrrKPOgO jejuAqmr DuQxqZKrT5xujAfe76o6wSet/wXgsksJccQalVRbvJ3lW3mAmbrLcprVmWM1KVbR+GVtBp8cjcAaKH8UOqYbs+oAFxa32p0Pq2pSs8ABL8SEpTc3hFSkeIUmOWAT8bH0aw60TT2tHZc4pmg7FnWO50Qj9fUvdHEP1N1LH7tzPd36xFIDwZhw0W0BCVMoz+27S7lG+m81UTsl8XLIjDrVJBYzr7R07Mxo0XRffidDRRDcHozy+FLfnhyhR09d7z3NSk4sVq+0oFbyceFE= 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: This is to add isolate_folio_to_list() to try to isolate hugepage, no-LRU movable and LRU folios to a list, which will be reused by do_migrate_range() from memory hotplug soon. Signed-off-by: Kefeng Wang --- mm/internal.h | 2 ++ mm/memory-failure.c | 21 +-------------------- mm/migrate.c | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 2adc3f616b71..e3968061010b 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -378,6 +378,8 @@ extern unsigned long highest_memmap_pfn; */ #define MAX_RECLAIM_RETRIES 16 +bool isolate_folio_to_list(struct folio *folio, struct list_head *list); + /* * in mm/vmscan.c: */ diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 68e1fe1c0b72..793c1cf02bd9 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2620,26 +2620,7 @@ EXPORT_SYMBOL(unpoison_memory); static bool mf_isolate_folio(struct folio *folio, struct list_head *pagelist) { - bool isolated = false; - - if (folio_test_hugetlb(folio)) { - isolated = isolate_hugetlb(folio, pagelist); - } else { - bool lru = !__folio_test_movable(folio); - - if (lru) - isolated = folio_isolate_lru(folio); - else - isolated = isolate_movable_page(&folio->page, - ISOLATE_UNEVICTABLE); - - if (isolated) { - list_add(&folio->lru, pagelist); - if (lru) - node_stat_add_folio(folio, NR_ISOLATED_ANON + - folio_is_file_lru(folio)); - } - } + bool isolated = isolate_folio_to_list(folio, pagelist); /* * If we succeed to isolate the folio, we grabbed another refcount on diff --git a/mm/migrate.c b/mm/migrate.c index c7692f303fa7..788747dd5225 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -177,6 +177,33 @@ void putback_movable_pages(struct list_head *l) } } +/* Must be called with an elevated refcount on the folio */ +bool isolate_folio_to_list(struct folio *folio, struct list_head *list) +{ + bool isolated = false; + + if (folio_test_hugetlb(folio)) { + isolated = isolate_hugetlb(folio, list); + } else { + bool lru = !__folio_test_movable(folio); + + if (lru) + isolated = folio_isolate_lru(folio); + else + isolated = isolate_movable_page(&folio->page + ISOLATE_UNEVICTABLE); + + if (isolated) { + list_add(&folio->lru, list); + if (lru) + node_stat_add_folio(folio, NR_ISOLATED_ANON + + folio_is_file_lru(folio)); + } + } + + return isolated; +} + /* * Restore a potential migration pte to a working pte entry */ From patchwork Thu Apr 25 08:40:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642969 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 284F6C4345F for ; Thu, 25 Apr 2024 08:41:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BC266B008A; Thu, 25 Apr 2024 04:40:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B97FA6B008C; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 863346B0089; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 372A86B0093 for ; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DC781A14CC for ; Thu, 25 Apr 2024 08:40:55 +0000 (UTC) X-FDA: 82047408870.22.FD15FF3 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf15.hostedemail.com (Postfix) with ESMTP id 84C87A0012 for ; Thu, 25 Apr 2024 08:40:53 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034454; a=rsa-sha256; cv=none; b=6glpfcBeLwaRG0iYwxr3CNcQX+G6wnvXOo6KFwIDeexsOPejeZj2n5e7I+vqCiYHZGjEuD l0gCL0DqkDqzdJ01Nr2+KQkxn64dZS6ols+inT4RD6fXOVCrIsePV+Q7rxkqC99PhzrVgl 4yHqIuWGPZcZucog+jsEaI2R2Pz0NAU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.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=1714034454; 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=QR17o8ZWSMif88LPZe8fBm/tebFuGlvVlTbjrpnY1mc=; b=fwrmyrr4U2KFJHSf2Psd6neyjbRmhhDh9tbI8Yj34cA0XqeppdF1xGVvYb5RjfwDCBxQof P/jsPnbL56CT8/9XAjeSyivxO+t6ybn8ng3G2f6YRAxv5okja5Jn0ZrvEZq4RZIwaiKA+6 sQx1sVJaOCMup7E2ImvPnC423pvMpWU= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4VQ8Rl38tSz1HBkY; Thu, 25 Apr 2024 16:39:47 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id CD0211401E9; Thu, 25 Apr 2024 16:40:49 +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:49 +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 03/10] mm: memory_hotplug: unify Huge/LRU/non-LRU folio isolation Date: Thu, 25 Apr 2024 16:40:21 +0800 Message-ID: <20240425084028.3888403-4-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-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 84C87A0012 X-Stat-Signature: r3zto9ajykw8x4ax5tm4wduiyjdmq4cq X-Rspam-User: X-HE-Tag: 1714034453-329844 X-HE-Meta: U2FsdGVkX18ybr97O6Yw15GuqkD1vR9D+B0EqMvtMg2cCzzROcArLLfsl6Us/o/umdzW6dUIVe9D+6j6cjdLJOag0Q5QzQDUMWaMPDRyclZhvfydnUqc15bW+G5PKL7bGlMViyk0XbfwQg+67KKTERUfoEMNqpNlgQUExB4Y2zeNVkEH1JWJs2dFG/+moIuDeUuD19ZVwqEFx+TpHzBzPEdcJh6uTP7oKih9mgm1f5kA6xR2eSj6hGnCNzeMt3fZCKLAG1MxT4LxeqiBUL4UnD9t3YG/vtTGdcpgutcxoBFO3k44mIMw33bi1PDAafZeyWrjafuKsyqv4GafM1bu1ZsUdFZNGeNYgWPY3G/PsGXPwRHpiCg2Cad9fsAKwQ//TPopNYmD9jDFA+1chu20ysXppaqQfE0sWWkTZUpeGDPVbv5jTUiPuB/VncpzNCsLmSQyYZBcXhiIhQZNuQoRZ1wzENORqPxf6JMtTb/z+aAQpjkp102prKokrq5H1xIuBvmyI/lq9m6Ve4FQs3oIslqqE4qlZwayzdhaqxpoY2IvZ/SxoMxrJk4tbCOr/n8s/hUl2WwIsbLYI61vu/ZLVh52rHuKy4ULkxqwva9GZe7VSMGJ+HBLATuXBFW3Pn01DLDPMh/YQBaWW8XY2qS0U9v8hInFm4t6aj/XDk0RzQ6WKdFRCdmen2AEwqqvq/GQlqKF8uQhVnZPgXCNPvF+hOw7TgosZcld9qyG7bLce4k8tWthiDHOR2dS6eltP4JOBKTdwyR7GLQNCO7QZPpSVdGod73oBNt27I9FaHUz5uhBvxxWxg1/MKT/atA+RmMDt4qxOZer88ndtA6f28g8dD4rLqa0Q7PocxhxwKUn6TjtodfbI0myUK64OFH/gPPuGIEXJB36mDBFSWMTTuc52Inx/5MOMX7fIzCgrJm9ycGPPbpEFPWOj8rlguKhNRVB1Fi3cNCXcNnpbrFQHoh w52Vr+5o PJuZZ0Yvhcpo5F5gp7+83in80XijWc1EbjNpaw1EEx3eDHe14b9oMnPIxUzEZ985A64UiC/ax9haA1r1lsKD9RE3zwKgBkXe/d/bi04Z30oCFHhpNXZCIhHq3joeMaFHSfjUpSI9z8WB1Kv9FfKGPPLa5yC0G8tCwAb7/RwFu7qNpvYYlnMHeFF2Ip0Aa60TIEuPpWuFmiCtfpgVPPuUcEKCMtHvjClRI4k76rDInmpebaXXZdzqx2UN59UFvESwlxA0nHt7zEDM17VWDcoV3JRbPMZEje7zvBmQvrgbZzbKQjPU= 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: Move isolate_hugetlb() after grab a reference, and use the isolate_folio_to_list() to unify hugetlb/LRU/non-LRU folio isolation, which cleanup code a bit and save a few calls to compound_head(). Signed-off-by: Kefeng Wang --- mm/memory_hotplug.c | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1985caf73e5a..0e40ee39aa88 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1804,20 +1804,17 @@ static bool isolate_and_unmap_hwposion_folio(struct folio *folio) static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) { unsigned long pfn; - struct page *page, *head; LIST_HEAD(source); + struct folio *folio; static DEFINE_RATELIMIT_STATE(migrate_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); for (pfn = start_pfn; pfn < end_pfn; pfn++) { - struct folio *folio; - bool isolated; + struct page *page; if (!pfn_valid(pfn)) continue; page = pfn_to_page(pfn); - folio = page_folio(page); - head = &folio->page; /* * HWPoison pages have elevated reference counts so the migration would @@ -1839,36 +1836,21 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) continue; } - if (PageHuge(page)) { - pfn = page_to_pfn(head) + compound_nr(head) - 1; - isolate_hugetlb(folio, &source); + folio = folio_get_nontail_page(page); + if (!folio) continue; - } else if (PageTransHuge(page)) - pfn = page_to_pfn(head) + thp_nr_pages(page) - 1; - if (!get_page_unless_zero(page)) - continue; - /* - * We can skip free pages. And we can deal with pages on - * LRU and non-lru movable pages. - */ - if (PageLRU(page)) - isolated = isolate_lru_page(page); - else - isolated = isolate_movable_page(page, ISOLATE_UNEVICTABLE); - if (isolated) { - list_add_tail(&page->lru, &source); - if (!__PageMovable(page)) - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_lru(page)); + if (folio_test_large(folio)) + pfn = folio_pfn(folio) + folio_nr_pages(folio) - 1; - } else { + /* Skip free folios, deal with hugetlb, LRU and non-lru movable folios. */ + if (!isolate_folio_to_list(folio, &source)) { if (__ratelimit(&migrate_rs)) { pr_warn("failed to isolate pfn %lx\n", pfn); dump_page(page, "isolation failed"); } } - put_page(page); + folio_put(folio); } if (!list_empty(&source)) { nodemask_t nmask = node_states[N_MEMORY]; @@ -1883,7 +1865,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) * We have checked that migration range is on a single zone so * we can use the nid of the first page to all the others. */ - mtc.nid = page_to_nid(list_first_entry(&source, struct page, lru)); + mtc.nid = folio_nid(list_first_entry(&source, struct folio, lru)); /* * try to allocate from a different node but reuse this node @@ -1896,11 +1878,12 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) ret = migrate_pages(&source, alloc_migration_target, NULL, (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_HOTPLUG, NULL); if (ret) { - list_for_each_entry(page, &source, lru) { + list_for_each_entry(folio, &source, lru) { if (__ratelimit(&migrate_rs)) { pr_warn("migrating pfn %lx failed ret:%d\n", - page_to_pfn(page), ret); - dump_page(page, "migration failure"); + folio_pfn(folio), ret); + dump_page(&folio->page, + "migration failure"); } } putback_movable_pages(&source); From patchwork Thu Apr 25 08:40:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642968 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 E92B0C19F4E for ; Thu, 25 Apr 2024 08:41:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EEBD46B0087; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5F636B0093; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DC776B0096; Thu, 25 Apr 2024 04:40:56 -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 15AF56B008A for ; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C4C97A041C for ; Thu, 25 Apr 2024 08:40:55 +0000 (UTC) X-FDA: 82047408870.27.2240708 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf05.hostedemail.com (Postfix) with ESMTP id 7C8BB100007 for ; Thu, 25 Apr 2024 08:40:53 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1714034454; 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=9/bUAZGbcia7hUeDGEA76soBivbT09Wey2IhVaRzpcE=; b=h9Y9RhNY7eCoaTJDENSeB0ct4tKE7NNUfCxvEBQy0Kq3WexgiX7nYTuNjLNkkxTcxbd5wD npCBvq7hDJApAncL7sMbKLMXxzSLiYrifoCz1YNLmn9s/u2fW0yeQQ54bHqXShTLizTIXL LmIwym5w8Z/lOhqOMw/O1htzwgBJ9Vc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034454; a=rsa-sha256; cv=none; b=MfFNCPs4vwLeMktRC6ZKegtLvECCqZYnENYfHdPbX1nC+mg0SYaGYEQfMg1mxlEw4EbfR0 0fZwVnIfb+GMy6bU5wDtRavX2A8WieJE4Ov6WuU3zcM37kwoQswz8DY2RLeGxBfzuYHiYH HswB2gkQ1DUB0tX4gGGIhWCHJaRcb5I= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4VQ8Q16zCHzNtHh; Thu, 25 Apr 2024 16:38:17 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 64357140257; Thu, 25 Apr 2024 16:40:50 +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:49 +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 04/10] mm: compaction: try get reference before non-lru movable folio migration Date: Thu, 25 Apr 2024 16:40:22 +0800 Message-ID: <20240425084028.3888403-5-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-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 7C8BB100007 X-Stat-Signature: m7pa5g79wdeb5yrce1m8szych7kw9jt1 X-HE-Tag: 1714034453-755605 X-HE-Meta: U2FsdGVkX1/lA5Og18/LoBtn9DA9J2TMazq9wWwM0cw5m0QQ+dVGMgjlUnoAlgI9BsyOTbhUB8xRNiA9Qr9jhfQZRDvNodkZAiOUQ5NafhijGbyMLCcx2tU+UObRRPdhQc49TyYep4oYHFocOlMxxZIjnqNxAcqaZ+FlN/XY0kHsMeVqsRhSj80+NF67pO8Z6Vjc0EPFF+9X7UWQBp8DwjWK6ex8x1+ryyPC5PCOdr6I4ivSvZr3xM/UYpIbyJ0DgugdCFktNtphwZiLGTt+Ca+Ae1XJwvOWUj4cnunq2YAHC/4m9BlePansVACE75jf3l6vCAOgpQPTJGIjzNUf2Fg2Vn1faw98GHExvAplnnQ3U23PlPyxVW2y82I0SeFlhosqOK+krEqUq2K/AAcgejzEq0qYw4UuPWdnnpymKrowNm4iCkNUtUIR7pdnKTvME/b/roIWrxINda9w/FEmSw5kIraVoquR0o1uvG/OK5rV3Kr1DkD9h/uNlsyRUZJz6q+Fwi6hf+73Etbb5i9vWQ52N4fyjavTk8GUKU/9mgbQmSzEF4xD6WUboq6Q1tSddlppdJRIWTvk4x4Xhki6kv47hlF9o3O9e6EdE/1o1ZRMxLFHJom7iqlB2oUka1FarVv5p4hvJVQapZgX9WGhu5LIrzbXbCubjwdj3GSvvNHUoETgnw+1xCw+g4h4tzS4yh1QY8GFd49Z5uko13lAnmF2PrQLZhehTWnqMhbkIHAmLuXYybWRcefgytPw63aMUz5MqRuPmvWx4OKVBLwAc0V2DZU48hitIDJ6m/+lSENmLAEwqpYKFuATyJhtpU89a0Eki7vOOMxgSC7rfYXC254+0bQ8ViZOqA5lBPz15EmGNNqcjjCjMaZCErI3Su3Pfr3qz3UY59yXPMfwpU+c7AeZ5pueiaFVMcIzrfgH/So= 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: Non-lru movable folio migration will fail if !folio_get_nontail_page(), see isolate_movable_page(), so does lru folio, so folio_get_nontail_page() could be called firstly to unify the handling of non-lru movable/lru folios migration a bit, this is also to prepare to convert isolate_movable_page() to take a folio. Since the reference count of the non-lru movable folio is increased, a folio_put() is needed whether the folio is isolated or not. Signed-off-by: Kefeng Wang --- mm/compaction.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index e731d45befc7..4fc5a19b06ad 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1097,41 +1097,41 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, } } + /* + * Be careful not to clear LRU flag until after we're + * sure the folio is not being freed elsewhere -- the + * folio release code relies on it. + */ + folio = folio_get_nontail_page(page); + if (unlikely(!folio)) + goto isolate_fail; + /* * Check may be lockless but that's ok as we recheck later. - * It's possible to migrate LRU and non-lru movable pages. - * Skip any other type of page + * It's possible to migrate LRU and non-lru movable folios. + * Skip any other type of folio */ - if (!PageLRU(page)) { + if (!folio_test_lru(folio)) { /* - * __PageMovable can return false positive so we need - * to verify it under page_lock. + * __folio_test_movable can return false positive so + * we need to verify it under folio lock. */ - if (unlikely(__PageMovable(page)) && - !PageIsolated(page)) { + if (unlikely(__folio_test_movable(folio)) && + !folio_test_isolated(folio)) { if (locked) { unlock_page_lruvec_irqrestore(locked, flags); locked = NULL; } - if (isolate_movable_page(page, mode)) { - folio = page_folio(page); + if (isolate_movable_page(&folio->page, mode)) { + folio_put(folio); goto isolate_success; } } - goto isolate_fail; + goto isolate_fail_put; } - /* - * Be careful not to clear PageLRU until after we're - * sure the page is not being freed elsewhere -- the - * page release code relies on it. - */ - folio = folio_get_nontail_page(page); - if (unlikely(!folio)) - goto isolate_fail; - /* * Migration will fail if an anonymous page is pinned in memory, * so avoid taking lru_lock and isolating it unnecessarily in an From patchwork Thu Apr 25 08:40:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642974 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 E932AC10F15 for ; Thu, 25 Apr 2024 08:41:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BD196B0098; Thu, 25 Apr 2024 04:41:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2486D6B0099; Thu, 25 Apr 2024 04:41:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09BBC6B009B; Thu, 25 Apr 2024 04:41:00 -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 D32DC6B0098 for ; Thu, 25 Apr 2024 04:41:00 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8B6B9A048B for ; Thu, 25 Apr 2024 08:41:00 +0000 (UTC) X-FDA: 82047409080.05.E713AF8 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf14.hostedemail.com (Postfix) with ESMTP id B4214100007 for ; Thu, 25 Apr 2024 08:40:53 +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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034454; a=rsa-sha256; cv=none; b=IT3lU9CMpqyUg3sRr+Xi9Gjtp00vXcyY6V55RHVRCCZN+8+QYQB+n3IsQzqIsp0hA46FRM zVDjoHFcvtq6j/Tono5Ea7Zmvm9+ThIJn13AAHqRCWGHKm8R1nFlv8EosVdtAzYOp6il45 NExB9n7JhyHdQOeG7B+BVKo3vEBfk6w= 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714034454; 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=8ke5/Rdm3ZK+++NF4NT0K/o4iyRBxlIgylQxQBxBqVw=; b=HXBA3nRWgeWscgplK9wt5kNgs5qSQSc+0W7Dy4lnh8Wveh+OGJ88DaG5iEGmPi7dKzr7NS bU9yg46Xxp+FnL0gC5Xmjfq2z6p8/cQEuFsxw35rePYy/KR6m82qLmK1YNmAAgrQMEUhgZ e6DoshHExeXthJ5PYFKGc2B2SeilUCI= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4VQ8PQ0tC2z1j0vS; Thu, 25 Apr 2024 16:37:46 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id F25AA1A016F; Thu, 25 Apr 2024 16:40:50 +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:50 +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 05/10] mm: migrate: add folio_isolate_movable() Date: Thu, 25 Apr 2024 16:40:23 +0800 Message-ID: <20240425084028.3888403-6-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-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B4214100007 X-Stat-Signature: kjxexakarub45eaksyfcqkq75e49buew X-Rspam-User: X-HE-Tag: 1714034453-139524 X-HE-Meta: U2FsdGVkX1/KOCHKFPMLkBnB8ygP0EH2FyThq+8Fle2GJGr2zIlnw5eupLOQNIE9wJNLges266j08Lc8C3oravErAP9YbaU+BUImaRdKejznvoETkUV+nn85kDB7LC/bGmJH54n9XCKMDU0+zCnccqf8alrTxsItQ6UqHheAzqMOr9bN0NXEx84JiEjSrgOoOOd7kzb8gjCBCIEWNdeJtQ3s8MVc6m6k2WzuseYDHqRJsEnX/8mCVN1/+Il/SL9e4Q2FdTs1O/H3eXoJVvSMusQP06IQqK2N1EmUoN9thhrjkJfcqZ0fU9iBK6R3Pd3+MGY0FuSKCkwXtcRf5IiXToTl9n5BBBs9DXwEILaYGIOg+59Va3+3udp1OUiAkvQ3eMpIW0tpSSW+VR7Tq713+eAkqJ5+Z0Cv49HoczlVN1GG6fN/t5Jhls09z3fTnkHmDlDbzNoy0w3WoFQLcPmsJpbOuFIzzd8mpSbHFV3Uzex1E0+S9YYfMmbIvt8UdhUjc7NmpbvMe+XS+4tx20OKLNKpBwWEiq/fZo0hmfrM1wgYv+MyWSpU9GkiQ3IDq2pP/8gKCHcktHNSLlmvhX+sVTOM9WK5lGyu//j8OyqSeyaOA72A061+KyA3EJr3+Fskdf0YN98dMDClHN9AYOI023TYpAQGX7fqa5MOsai7f67CqZvKJDqB2269T4inzvMe1hwKl6KDchn0p/V5r+eIVZbRhpJu+etYKiLUdvyohuF+1RQdgcDvZmQQCzb2Nj/o0NtvfK9fxj7JskiQDzBZhbnRYakkq8eCk49p0r+9XvkQvZ8V+EyWOvTHs2SFuWBFNIgKyoOHUj3CrbZtD702Yx+uFo4A3p5sLK3KOR3D76N9ve6gM+mYjPtbeM1b/LTBZKNEdrz254R4Q42pSFbCv/VDlwBW0HM4W1RkOV23UOK1JR5GnB3lnharvTLW3duQgAz5UMQX94QPUznmWcg FVP0tYoj j+BZ9mA+U+NLSgKsoczWw9vplgjW2J1GHx2ZK4wL0vn7o03MGj4UyxjSOyMF2G14siiuZT95D/oI8N/u5M62rLAdI9qhpX0YiUbd/owzRO7tH18wa5zrc7S7pTo2iW7eVgEsSHolWOXFUVr7qx5sGT7/MuFj3zDkSPDCp/I/72wHr1lRfBJETuJTlBGOIi21Gv0k+96GH44sj3QqFMrB2nS/j/p50s2JFlFo/uAyioErRKZceCFIbFg1flAyGp+wZW1q3fdYqZyJjWM8= 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: Like isolate_lru_page(), make isolate_movable_page() as a wrapper around folio_isolate_movable(), since isolate_movable_page() always fails on a tail page, return immediately for a tail page in the warpper, and the wrapper will be removed once all callers are converted to folio_isolate_movable(). Signed-off-by: Kefeng Wang --- include/linux/migrate.h | 4 ++++ mm/migrate.c | 41 ++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 2ce13e8a309b..4f1bad4379d3 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -72,6 +72,7 @@ int migrate_pages(struct list_head *l, new_folio_t new, free_folio_t free, unsigned int *ret_succeeded); struct folio *alloc_migration_target(struct folio *src, unsigned long private); bool isolate_movable_page(struct page *page, isolate_mode_t mode); +bool folio_isolate_movable(struct folio *folio, isolate_mode_t mode); int migrate_huge_page_move_mapping(struct address_space *mapping, struct folio *dst, struct folio *src); @@ -94,6 +95,9 @@ static inline struct folio *alloc_migration_target(struct folio *src, { return NULL; } static inline bool isolate_movable_page(struct page *page, isolate_mode_t mode) { return false; } +static inline bool folio_isolate_movable(struct folio *folio, + isolate_mode_t mode) + { return false; } static inline int migrate_huge_page_move_mapping(struct address_space *mapping, struct folio *dst, struct folio *src) diff --git a/mm/migrate.c b/mm/migrate.c index 788747dd5225..8041a6acaf01 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -57,21 +57,20 @@ #include "internal.h" -bool isolate_movable_page(struct page *page, isolate_mode_t mode) +bool folio_isolate_movable(struct folio *folio, isolate_mode_t mode) { - struct folio *folio = folio_get_nontail_page(page); const struct movable_operations *mops; /* - * Avoid burning cycles with pages that are yet under __free_pages(), + * Avoid burning cycles with folios that are yet under __free_pages(), * or just got freed under us. * - * In case we 'win' a race for a movable page being freed under us and + * In case we 'win' a race for a movable folio being freed under us and * raise its refcount preventing __free_pages() from doing its job - * the put_page() at the end of this block will take care of - * release this page, thus avoiding a nasty leakage. + * the folio_put() at the end of this block will take care of + * release this folio, thus avoiding a nasty leakage. */ - if (!folio) + if (!folio_try_get(folio)) goto out; if (unlikely(folio_test_slab(folio))) @@ -79,9 +78,9 @@ bool isolate_movable_page(struct page *page, isolate_mode_t mode) /* Pairs with smp_wmb() in slab freeing, e.g. SLUB's __free_slab() */ smp_rmb(); /* - * Check movable flag before taking the page lock because - * we use non-atomic bitops on newly allocated page flags so - * unconditionally grabbing the lock ruins page's owner side. + * Check movable flag before taking the folio lock because + * we use non-atomic bitops on newly allocated folio flags so + * unconditionally grabbing the lock ruins folio's owner side. */ if (unlikely(!__folio_test_movable(folio))) goto out_putfolio; @@ -91,15 +90,15 @@ bool isolate_movable_page(struct page *page, isolate_mode_t mode) goto out_putfolio; /* - * As movable pages are not isolated from LRU lists, concurrent - * compaction threads can race against page migration functions - * as well as race against the releasing a page. + * As movable folios are not isolated from LRU lists, concurrent + * compaction threads can race against folio migration functions + * as well as race against the releasing a folio. * - * In order to avoid having an already isolated movable page + * In order to avoid having an already isolated movable folio * being (wrongly) re-isolated while it is under migration, - * or to avoid attempting to isolate pages being released, - * lets be sure we have the page lock - * before proceeding with the movable page isolation steps. + * or to avoid attempting to isolate folios being released, + * lets be sure we have the folio lock + * before proceeding with the movable folio isolation steps. */ if (unlikely(!folio_trylock(folio))) goto out_putfolio; @@ -128,6 +127,14 @@ bool isolate_movable_page(struct page *page, isolate_mode_t mode) return false; } +bool isolate_movable_page(struct page *page, isolate_mode_t mode) +{ + if (PageTail(page)) + return false; + + return folio_isolate_movable((struct folio *)page, mode); +} + static void putback_movable_folio(struct folio *folio) { const struct movable_operations *mops = folio_movable_ops(folio); From patchwork Thu Apr 25 08:40:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642975 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 656ABC4345F for ; Thu, 25 Apr 2024 08:41:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5334B6B0099; Thu, 25 Apr 2024 04:41:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49B676B009C; Thu, 25 Apr 2024 04:41:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13AB06B009A; Thu, 25 Apr 2024 04:41:01 -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 D35656B0099 for ; Thu, 25 Apr 2024 04:41:00 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AAB141C0E22 for ; Thu, 25 Apr 2024 08:40:56 +0000 (UTC) X-FDA: 82047408912.04.9D0FC21 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf08.hostedemail.com (Postfix) with ESMTP id 75CF216000F for ; Thu, 25 Apr 2024 08:40:54 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034454; a=rsa-sha256; cv=none; b=A1kJdofQMlPKAQZYNGr8yF0Hc/La0fBmfuttlyQLouTOVEpKEzrvuBxWLq/ckYwmRSNgTR D21L1SC7nMC7BFrVhoQHfM+8fVpSFjN7pfjmqj3Iz4d3JDaBcuHA+5pgCaHuwER1ZI/7f3 EfHCT0plFk+7w8zuyEUNZErVm2d4z5c= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1714034454; 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=y1rqkS8LbGjIdNgvbT1hfsVSLaPNpOCwoPB4dAXgHGY=; b=3/BfCeRHppcxI6UFXu0VsxtVyMvmnUsSy7hEC7y/X0DFskGIlAn9JptcYiOHrWzFhdw6jf l5JtzV33KuwaZlzehZBc9w3nPQ8edkWnE+5xIea65Bq6O93zC01TL2fKrXEeTCfh0rszKW KU+FjNAFvym7gFe2cbMZoaLMCkf34EA= Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VQ8PH5KpRzwTkl; Thu, 25 Apr 2024 16:37:39 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 85934140415; Thu, 25 Apr 2024 16:40:51 +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:50 +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 06/10] mm: compaction: use folio_isolate_movable() Date: Thu, 25 Apr 2024 16:40:24 +0800 Message-ID: <20240425084028.3888403-7-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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 75CF216000F X-Stat-Signature: ioqd7gxdb4kupazaj6en53ytrs597ejc X-Rspam-User: X-HE-Tag: 1714034454-413263 X-HE-Meta: U2FsdGVkX1/q6n7++ysFfzpF4q0p37r8n1cj9ubVw1INTFlQ7wuVATh/FRTd3NJIQw+cqG0Otb2lQ8gziVzK5yNfPwhoNbKDlWxv96vOSCsqNEpvgk0bOBty9pmSHrLA28m01AJlLKOi8d7ei5/G3hbdn47MB+kw0uVd/fB8RnYZiTS1SQEyPVF63ncsoxK72t/jgyZmMsyKJi3BTU6CTPNFmywh4CbfJCWlb7JYuoMnep6LOAskZCr15oEAFihukzK/4p/R6UVmsr+BuhD5cwxAOEcenExHO2HDVdXlsBjib1W7zYsIkhapOcugrIBSOnEZO59PNpkG5F/upxXYXl/HqHKGsCrLZ08Tm0RQlyH+R//64WYO1mc0iowjAA67BBmuwyDMsQAfpgk9snf0FN0dVZxiXXvcUzWAMnsMMMD0ujNI7VLuP7Ysm3lgpXOLS/Gfwbni0PnNbk6mNmDRHrl66DbC1Xhd8uZrD7ly3aAvME4/0wS8j0Z2h1tkx/fa0mLGa80lAwW67cXHwF+qsKgXcROWmQcW3TdbLg5kUvqO744qM0QrOLjnOYFgaUTLUTuaoeUegRCiQw/eQmUYvIrqsZNUz/0osTgT1nAFHjCewvQOzyMZneFENS+1eCaDitAlU1Sn/XPN6uCsrfKbNpSo/GGigqeKpv+1K7A2wxVqDMjKYqoKEmhn0ugSquaXJAgHnv4bM/m1MD6VUIiMizn8qPt/73xXBsAlLNUP4OVcLnG5Su1nfEcyjBzqUqxs6n702cD5wKQyWtwwUK3gxafkDvvmvEBHvcGjrQkCSe3Ua4h6L95sdVl/3I0NddH/6UqxA+VECb83mAjuUPLd5WhDeW1dU7VjJ6UERyz1EM7yIr70EMU/tDG+lKx58RzN6M7PKJyGObg7o4LYDCTEWcoxZOMEMtSwhYmxkux0Tbd9zWTMI3IASwL6VvoXRe8Tbo8lirYSJjiKhW8dP8N 3gg== 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: Directly use folio_isolate_movable() helper in isolate_migratepages_block() Signed-off-by: Kefeng Wang --- mm/compaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/compaction.c b/mm/compaction.c index 4fc5a19b06ad..65a98968f681 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1123,7 +1123,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, locked = NULL; } - if (isolate_movable_page(&folio->page, mode)) { + if (folio_isolate_movable(folio, mode)) { folio_put(folio); goto isolate_success; } From patchwork Thu Apr 25 08:40: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: 13642970 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 16AF1C10F15 for ; Thu, 25 Apr 2024 08:41:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5CE916B008C; Thu, 25 Apr 2024 04:40:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C03B6B0095; Thu, 25 Apr 2024 04:40:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15E046B0096; Thu, 25 Apr 2024 04:40:57 -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 DDF466B008A for ; Thu, 25 Apr 2024 04:40:56 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9B9A0A04AA for ; Thu, 25 Apr 2024 08:40:56 +0000 (UTC) X-FDA: 82047408912.14.ED84634 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf05.hostedemail.com (Postfix) with ESMTP id A23F8100009 for ; Thu, 25 Apr 2024 08:40:54 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1714034455; 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=XytKMxC84xL9ec+vAK1PF9I1r7EBscCHkISCjMy35m4=; b=hx0Rd48yWh9dBl0PrK/TcVJJW/Ig6LK5RFURkREiMFueUq28DVljRk+H4bcvsA5Uu21EDL 2njzBDZn0FnCGUlqxgqLmIcj5Z5iqIV/xREVdqb5NoEcGsD8WcduOIuJL14rLKq/I69gFZ zFVb1qHTqy1LeZrZKrVptht4UCIkL0U= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034455; a=rsa-sha256; cv=none; b=MLzdmnS2o/Oqvy7euuXbRFi0G1VoxI6NIlSSirkeBmMpysxYumQzbvFicttddoNrly5X/W GLQkbauOvDZEmmxAy2Q0VBwbDj+jnsx948Np/NfwfRQ6JR9K6T7aMfHEjsR8b2VNMtaztR Y54S5gYuvuDKL1kUNwK0H5uLSJoaI0M= Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VQ8Rl0hSHzcc0S; Thu, 25 Apr 2024 16:39:47 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 20C941401E9; Thu, 25 Apr 2024 16:40:52 +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:51 +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 07/10] mm: migrate: use folio_isolate_movable() Date: Thu, 25 Apr 2024 16:40:25 +0800 Message-ID: <20240425084028.3888403-8-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-Rspamd-Queue-Id: A23F8100009 X-Stat-Signature: zqgq3cnw1xiiniqf86pwb4denhbzw9gf X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1714034454-735726 X-HE-Meta: U2FsdGVkX18kxgs/Suo/0B6jsYnRGd6/od831NNFhQp6itT/yI7FZKbJ9NsO0Ug+8UbDzgXHz3Sdak9O2Jp4CFi/J7t49kbcYg1S9GQz7JGteYUsnU4uS9/0WGzaEfOba3FaPAtG1SpcR1YkftHdIIyXcWWh0Qbgd1UDCgQoLswzpmcETwhqDbtKGW1ntt4MlCLXMaXXaXEGtYcZZDTyI9yBNFFxfd7ox3RQa+i3m6lkAwYjePzzSfPALCsK9T4QT9vIukJMFRiJIr6gpnR9WRBr67oALtyLWNoPDltaMvt2vGSUQjVs0InCtq+D4qS6otTaYIpRmB67BApIPXGrVl4xgEvl4yHgQmcojJMTbAbVpzCUwTn3DOqx8V9wmHWqD96iAldpLqHwWQSJ4dLIDEocyIlslp076KeovXp2LhZqAtZByyQ4bet1YEoklTYYw4fWXYPzdZh1w5o0tu9eRPlW6V4+y/VyTGXBkyMQddGls5M04NW/S0SqsB54oFFMF5H0MSetmLjGgPaQGr079vLNsM2C1TocBL2U7aXg+eBxdu4Nu7aOETsAMkraZb2OI7/Sw6AwPGL0Pwjov4wAI+ff22AfkMg65HX2LjKRhWzXhi/solVyqz0cN/wyOxMBkXeLOG2Xh3ZyrtG3Ys7E6zVNetV7BvQugT4MriOzZja+X8um8j1ITYqLfGV1dfkwuxno2N7gY7qybE2lXqQOnNXPbUddOiTe9mluJ6uBJ3cUr2YISGmfarTOeDAYvVf0IPbid7TvCeuu/UrMb66Q/0ZUgj9E918M8ibPMRMzgz3rtuLuRR4W/egaYaIYM4p6VjwXs0NSnYCmI2+uWYJ2qclPy93PMxtuiZF0xcq9ZmQBOxB2yKu8xuoloD3oLWs7tpq83cnKT/IoaD75QtC1Pu+DjVTpbPczHtI8mgGyM46hrOB4J/RHJaaYM8fsiLipwS8EUAfva/nVJpGNU8l 1Ow== 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: Directly use folio_isolate_movable() helper in isolate_folio_to_list(). Signed-off-by: Kefeng Wang --- mm/migrate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 8041a6acaf01..3d56604594bb 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -197,8 +197,8 @@ bool isolate_folio_to_list(struct folio *folio, struct list_head *list) if (lru) isolated = folio_isolate_lru(folio); else - isolated = isolate_movable_page(&folio->page - ISOLATE_UNEVICTABLE); + isolated = folio_isolate_movable(folio, + ISOLATE_UNEVICTABLE); if (isolated) { list_add(&folio->lru, list); From patchwork Thu Apr 25 08:40:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642971 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 72985C4345F for ; Thu, 25 Apr 2024 08:41:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC14C6B0093; Thu, 25 Apr 2024 04:40:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B709B6B0095; Thu, 25 Apr 2024 04:40:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A11146B0096; Thu, 25 Apr 2024 04:40:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7E8396B0093 for ; Thu, 25 Apr 2024 04:40:57 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2A3408045C for ; Thu, 25 Apr 2024 08:40:57 +0000 (UTC) X-FDA: 82047408954.04.5E5136F Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf12.hostedemail.com (Postfix) with ESMTP id 2BFE440014 for ; Thu, 25 Apr 2024 08:40:54 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.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=1714034455; 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=1wqZSe1foLHx1sU7xYCCg5lvuRL3RZDuMUxX3J9x378=; b=z5dqWGfwuYduNcqrhwCrt3chgoVJWTL1kdP6MHTQNJ6Hr7pqjKW11eviT4oyoLuj99547K 4/vAzkH4XvZhYKICBJZp13h8Mvxw50ynG+TibivaIiLqAzBAyc8waH27WOU9rmsKNrArCD RxM9VJs25BkSMU8YwFUsJktDBD88/R8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034455; a=rsa-sha256; cv=none; b=aakLZmcFpbfdaxUJ0Aa11lcC1Yvb2jRL916gmOgxJTNS+bzBNZ0yncf7l9VgFTNCz5KVdT 8uJs3oqcSIhSzYOTKA98Jcr9ssodx6nrhIe7/vrYZA5X/XLAGdsP6COZdPbDjh3f/tF5SM qkWdyCMEfOptUWpXyOtP398P10Yxrvw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VQ8Nx66YTzXmVn; Thu, 25 Apr 2024 16:37:21 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id B185A1401E9; Thu, 25 Apr 2024 16:40:52 +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:52 +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 08/10] mm: migrate: remove isolate_movable_page() Date: Thu, 25 Apr 2024 16:40:26 +0800 Message-ID: <20240425084028.3888403-9-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: kn8c1unpx31prynr67ufoo5maqudd8jf X-Rspamd-Queue-Id: 2BFE440014 X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1714034454-186944 X-HE-Meta: U2FsdGVkX1+RbgQrvhxuPgO1WpP6bvypL6u/ZEv+xbGUf8CBJXNRXQGRKsAe6hVn/YA/tA+wuTVrjSR27+0d34FR029DnZEAST0qbazlAIJ7tL3i3gEjbldgsiLxPOj2HMX/8DuJtfqFJLn2Ab465bnWB2fgzu6pmHLaSPa8PlVcxCddR/0wyfFQAdp40X+ong8q+05/lRPYxtCUcZrr4edOTQec2CcZFEAMCnhj7fKyXdI/kp3bTy6WqQF/2nQbstGpGD9q1hD7ZzUkWQeV35tSJhd1PiEh6YrtiTNYEKssX+pc0S6NTxC3lkS6keVoB/g2LOrAoTupTg8ui44jW3F1LW32D+v5Z/il76T7d3LxFalDe/wcBl4Cwd/aXIcB9u5zAryWFGuzTJ1i1Zz8msd4dcLQKEe9fF/4z+OGJdaM1JfyysCxcl9dIeTnwLL/M9OhAJgoBGj/6ZmK22u7catIbQTG1X1CLjFCNXeHJSoF3yeBAHf3Z4V+wS5xDpc08bCQfU5A0RgIPWTM27uK0+17vjHXuaP8iCbE4pmG9jyZ/FeiF/kfhUpKdxLlo3nwIaQHO+0Ds0MQ7XS2X+za4Vgv9T0jc6e5qYl1oitZ0dTLmGq93jeKwXZr69IcIHxy0aVGdCUCPHh/LMGyPTIw3xtmyVER5gQVLlz+2tw5cSl7hZkuniqQlaYTZ7g11PhwncBCy2a8ERFLd26GtRe80Hgdz7DwM5WmUBgBFQQJRaJxOcmMq/41muvT+LH2IvfG0rlNPjEsgu4ueT+tl0Kw6gGa+7bvl0osU16h+YivuO/+xNBA2dZjEMPN0ygkgm2qOxPmMS0+tPzKCmu+lMOyHELzClaoECbo2EZtq74mBywNMRMQ1gVft9eZFLGi8K8nMzeTYoz5spJl8gaZrqelGQJGbGyuOcrERKpWPVJcum7J2P9d9o1yMKNtP5Hq4wqPmCn40aNGFsor1maRqJB 8Ig== 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_movable_page(), remove it. Signed-off-by: Kefeng Wang --- include/linux/migrate.h | 3 --- mm/migrate.c | 8 -------- 2 files changed, 11 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 4f1bad4379d3..938efa2fd6d7 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -71,7 +71,6 @@ int migrate_pages(struct list_head *l, new_folio_t new, free_folio_t free, unsigned long private, enum migrate_mode mode, int reason, unsigned int *ret_succeeded); struct folio *alloc_migration_target(struct folio *src, unsigned long private); -bool isolate_movable_page(struct page *page, isolate_mode_t mode); bool folio_isolate_movable(struct folio *folio, isolate_mode_t mode); int migrate_huge_page_move_mapping(struct address_space *mapping, @@ -93,8 +92,6 @@ static inline int migrate_pages(struct list_head *l, new_folio_t new, static inline struct folio *alloc_migration_target(struct folio *src, unsigned long private) { return NULL; } -static inline bool isolate_movable_page(struct page *page, isolate_mode_t mode) - { return false; } static inline bool folio_isolate_movable(struct folio *folio, isolate_mode_t mode) { return false; } diff --git a/mm/migrate.c b/mm/migrate.c index 3d56604594bb..4fbc7ff39da3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -127,14 +127,6 @@ bool folio_isolate_movable(struct folio *folio, isolate_mode_t mode) return false; } -bool isolate_movable_page(struct page *page, isolate_mode_t mode) -{ - if (PageTail(page)) - return false; - - return folio_isolate_movable((struct folio *)page, mode); -} - static void putback_movable_folio(struct folio *folio) { const struct movable_operations *mops = folio_movable_ops(folio); From patchwork Thu Apr 25 08:40:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642972 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 94FB5C10F15 for ; Thu, 25 Apr 2024 08:41:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77DEE6B0095; Thu, 25 Apr 2024 04:40:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72C3B6B0096; Thu, 25 Apr 2024 04:40:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CB506B0098; Thu, 25 Apr 2024 04:40:59 -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 376166B0095 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 DF89EA048B for ; Thu, 25 Apr 2024 08:40:58 +0000 (UTC) X-FDA: 82047408996.13.B0623AC Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf09.hostedemail.com (Postfix) with ESMTP id D8E16140026 for ; Thu, 25 Apr 2024 08:40:56 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.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=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=8g/fjf5Bp9zMfUTVcdih2n/RGFhdyeL3pfeXntoscmc=; b=SDTx7fOtzjO/EanaaJyK5IpYBULtheb12VNNnf68KpyDWeJauGZCP1ypg4iBlB/ZTjnmJ7 ZTt+UyGeeyGlLeDIqxKoyYGa06DSc5QmIVz73vG7JBJVDJW+AbyDaT8/kSJTi/+xMPI8Vt UwoAy18MuZ4y6FQs1+hV2x8rINAq/e8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.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=1714034457; a=rsa-sha256; cv=none; b=wRzpCAx3zBRx9iDkzTOmGwcmOBvECM6zHeVbZtbBmBUEzVUL2uJxWfDg0RjjJeLtRKoA1d jX00RDXhrl0lt45IAwgDjNf9d+Aj+22Dfd31f4D0rXGUXh0MGhj544EsacnxkBIMXGQwEa tRZR1R7Shvw6fOSVtRb4FoNSJSlVEcI= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VQ8PV44kpz1R9Kf; Thu, 25 Apr 2024 16:37:50 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 4A2C5180073; 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:52 +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 09/10] mm: migrate_device: use more folio in migrate_device_unmap() Date: Thu, 25 Apr 2024 16:40:27 +0800 Message-ID: <20240425084028.3888403-10-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: 6xtua4wc5qhnymqz771fj36afexqsxtp X-Rspamd-Queue-Id: D8E16140026 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714034456-911861 X-HE-Meta: U2FsdGVkX1/vHt1EcvWscrZHnxRoxjnpp0Xgd4HZ7Aoif8/efk94NPgAnuCEXXTAIuMJM9VynTjM4RZg1JE9mjwfAYt1DqZUNkHfO79V1tLwsqtFLgrhqgk9W2SnwKOf65oSGpHzZGTK6+SnWJNj7H80/aMriSYxsjAhvvE3gvBP1oQ3i5k8Nmo/m4C+Jsz0OlnoSuHajXpOrP0t2Wkwvey2FbbAo8kcNaUrNXsLrvYJ6oAkqB34+NmNrvZ0V1M87O9ZgR4wYhgGNSpU++Q3x5aeK6p+dBvMJ/ceJTLUN6KE33ptU62SzD3oCSw3LPgqiqqjWk1ClojyTSs+0qXRYhmoNZhvKdAJmm4YHIjHr66zgIQ3ITesriiCE2TPjsaz76Urrcl5G/NUiUb0Rdmy3VxKF4zCsAU1ceN6+zlM/WDXhdo+EjMz/dDdRwm4PYgZ9hcORZ6hYtGEEip/QIjn3RWc4WVI5Da1oJJMqFbRRifHLTptLL8UmGQ/doVetnmOKriF8NXP882vE94LGQXW1btiCFeP9p0BcJLmHSpbLP2yFeWSP8Hgx8lVzJDWCx00Th9u2GBGGnGl818k66wmCkJIP7Ezew/dfOVHIKQe6C0mQCEChpr9rV/HLym51f4Y7ehiY89w+3IA1SpW6c8odZhgleX5DoMqxSw6YakcM3FnVR9Ni6TvsWIkPwFLcr9ZSRU7GmNsoU7+aNl0J69whxsIIpdB0iAoWeT+xkHSnGELXR4IcuYPNdjjGxpXXd5VO+ulkNKs6FrViajZ2fPz9WiAQKm4yntzTaqQ7Js16lsyfmaMDiigfTS+pXgpQd4eUssIk+a0uueKiSVkDEA+Y35Hm9xO390RTfUXomtqMJVKLpQ9/yWCX1zotPyqwvlKNWNaeeM6VjCRjjTTjLFPSZK02x1+Sga7Lk9B1/ClHMVwgNBWC9yyw7GvPjNm8FsLf51Vvxci2wOkC1mLAJ6 1sg== 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: The page for migrate_device_unmap() already has a reference, so it is safe to convert the page to folio to save a few calls to compound_head(), which removes the last isolate_lru_page() call. Signed-off-by: Kefeng Wang --- mm/migrate_device.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index a68616c1965f..423d71ad736a 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -379,33 +379,33 @@ static unsigned long migrate_device_unmap(unsigned long *src_pfns, continue; } + folio = page_folio(page); /* ZONE_DEVICE pages are not on LRU */ - if (!is_zone_device_page(page)) { - if (!PageLRU(page) && allow_drain) { + if (!folio_is_zone_device(folio)) { + if (!folio_test_lru(folio) && allow_drain) { /* Drain CPU's lru cache */ lru_add_drain_all(); allow_drain = false; } - if (!isolate_lru_page(page)) { + if (!folio_isolate_lru(folio)) { src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; restore++; continue; } /* Drop the reference we took in collect */ - put_page(page); + folio_put(folio); } - folio = page_folio(page); if (folio_mapped(folio)) try_to_migrate(folio, 0); if (page_mapped(page) || !migrate_vma_check_page(page, fault_page)) { - if (!is_zone_device_page(page)) { - get_page(page); - putback_lru_page(page); + if (!folio_is_zone_device(folio)) { + folio_get(folio); + folio_putback_lru(folio); } src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; 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. *