From patchwork Mon Aug 26 06:58:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13777225 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 73797C5321D for ; Mon, 26 Aug 2024 06:58:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A12C66B03DD; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 999056B03D2; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F8646B03D2; Mon, 26 Aug 2024 02:58:38 -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 50E386B03D1 for ; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E9D371A0C60 for ; Mon, 26 Aug 2024 06:58:37 +0000 (UTC) X-FDA: 82493493474.04.D9DD478 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf01.hostedemail.com (Postfix) with ESMTP id 8A4BC40005 for ; Mon, 26 Aug 2024 06:58:34 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1724655448; 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=OJTdXtQ1TUXxF9kEmOSf5Y2MFDegpTKFciOTdciQMi0=; b=ZhqfJARBrurvCqEbwUjsi63f4RJuAJGJVf/Ovn4YILal25PBEzJcBwwax+S1yPb2go6EvO 96iAPIxPYSzvg84QwEzQVBNCP6YJ06Z4Uxc6AMBcyVZroYlSTczbDNM89b1DW7Ngb7mzXS UjPJbDdN7gHn72s3/goRuHrdJM2Z7TI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1724655448; a=rsa-sha256; cv=none; b=WHMwT28iuXdcGqqTwW/MlevsPrJ3e+70U1kUFxH13CoktpfavuBXCccUcgSpNN5wrdwRfh hGlR8hXCEvy6BRxj4OuiMjkgzTu7UrL6S0zoxg0KGIGZJ+IMkPxpxPxBeEblEnUVCyvCdc sVrAIyeZsGD7uwhsN/k/X9ex7PoYbrU= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WshGc0XNrz20mgl; Mon, 26 Aug 2024 14:53:44 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 1153C18002B; Mon, 26 Aug 2024 14:58:31 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 26 Aug 2024 14:58:30 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Matthew Wilcox , Baolin Wang , Zi Yan , Alistair Popple , Jonathan Corbet , , Kefeng Wang Subject: [PATCH 1/6] mm: migrate_device: convert to migrate_device_coherent_folio() Date: Mon, 26 Aug 2024 14:58:09 +0800 Message-ID: <20240826065814.1336616-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> References: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Stat-Signature: 5erwfa68ex71u5tz34saaychkbyya6ep X-Rspam-User: X-Rspamd-Queue-Id: 8A4BC40005 X-Rspamd-Server: rspam02 X-HE-Tag: 1724655514-544110 X-HE-Meta: U2FsdGVkX18wVOPbxWJdXpvBH8Rq5ByQxCm8cYFrtW5D1el0CjJn44EwMqHO4ZpE4Q+jSAoFviBicPJQVqLtFr43ByZXF2fT9pY/Uj6NcTXTyLZ2u+RRHdl0iLEpM6z1rK0XDTQlr5D53SV0znV9GBOJr5ySzlPgS9uXER9t0kVVQW1Qfj5FOa60jY7ZRRcm7btK4u3tzmZ77UzMZbQHW6o4HCwMkhea+vPuDRAiqXlWITdyEfhSliyWt4nSkvDFZ400FwUw51G4cCB2YQJNEOaUEUqrJVnZTxR2My3OZP2DXPLNGTYQ9aLWMwu3TUHvgGHAMxULxWLy8yKMg6Xk4x/E36bvjbq09/JDEHPul3eNdHJuXaI2g4JHF1k5V6BhyNzUxpyez/AtgRnA+OmvW8ETmn4RmIuBECLOSCT7XR/fCzS4avaQoSI8Jel+W49/7DpOdqx1pKX2r2Yh7c2JMz72ldxdRKK6+xEbDVlHt+xrWeheSvFFts8OwC5ZmvftwdRJcYvj2D7lDqj+0PNfITMy1wRO6Zz6V9PhDBRJJ9cZGkKvcXbZsxtBOGA79+IZg34MPB+UuZsJrkbfH1rZ8mtcpi/7TvveM57a3duuBpBl/isKi5Ok0I8xS2tAzJazZ8JnGagD7g935Fz9sUDe/BsisHY70cQPtT73jpVdFESSbPEobxzJnLDVyXby5GvtbyIh42BUhJKWggbsJ4BimN7pAzrvAB+qMdQqsMzrVD03Ib644VNbgpbJUMVIjgjNhqN+HNrePayn57nhOzoHB78QWUjIwqr6FbTVXYn226Y3NqKOw0O1xLNnEveE3qr3nUv5EjxMQg90fViwXoPl6PALrmD4yv5xG9mKE1mhZIHSqmOYZgx2mI70tessXDLtjf1Kj5bGY7qEscriLEq9Q9gGMUpDvb2a6gn2WxlWf/R5pL8w66DjK5j8xThIB/Aes/znV0wjx0IGAP9E0Uo qBmGJHQt w8UfSjPxR52qoMBVUu7/BN+tD6953DFD2mNPUs4menVQGVzqomgxriRfQJTMJ0CYsv1ItMziHM+mv8mQdz6TxVdl98K+qSdvS2+zMyXrjRgC1v1TTYVuIK5nWfCLkEQX/vmpvzeO8YnxMeqodT5m5xV6Uk9VOQEkTHr0F5n7qaGYIB0WL4FMk9GG/axtk2GzlR49f4quMW2nrFdQnjJvpXvLjisCqb62j+7JHIz+2u1c7JGGB0gvYm3VrvdmZyZBoFFpi9GXO9FC33qSHJ+u2k986nD+WlCXsj8p5XWoiaG1K6i7rPNmk8pG2Ug== 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: Save few calls to compound_head() and use folio throughout. Signed-off-by: Kefeng Wang Acked-by: David Hildenbrand Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Alistair Popple --- mm/gup.c | 2 +- mm/internal.h | 2 +- mm/migrate_device.c | 30 +++++++++++++++--------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index d19884e097fd..5defd5e6d8f8 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2335,7 +2335,7 @@ static int migrate_longterm_unpinnable_folios( folio_get(folio); gup_put_folio(folio, 1, FOLL_PIN); - if (migrate_device_coherent_page(&folio->page)) { + if (migrate_device_coherent_folio(folio)) { ret = -EBUSY; goto err; } diff --git a/mm/internal.h b/mm/internal.h index e1e139e412d1..0f4750f77f59 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1209,7 +1209,7 @@ int numa_migrate_check(struct folio *folio, struct vm_fault *vmf, int *last_cpupid); void free_zone_device_folio(struct folio *folio); -int migrate_device_coherent_page(struct page *page); +int migrate_device_coherent_folio(struct folio *folio); /* * mm/gup.c diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 6d66dc1c6ffa..82d75205dda8 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -708,7 +708,7 @@ static void __migrate_device_pages(unsigned long *src_pfns, /* * The only time there is no vma is when called from - * migrate_device_coherent_page(). However this isn't + * migrate_device_coherent_folio(). However this isn't * called if the page could not be unmapped. */ VM_BUG_ON(!migrate); @@ -921,38 +921,38 @@ int migrate_device_range(unsigned long *src_pfns, unsigned long start, EXPORT_SYMBOL(migrate_device_range); /* - * Migrate a device coherent page back to normal memory. The caller should have - * a reference on page which will be copied to the new page if migration is + * Migrate a device coherent folio back to normal memory. The caller should have + * a reference on folio which will be copied to the new folio if migration is * successful or dropped on failure. */ -int migrate_device_coherent_page(struct page *page) +int migrate_device_coherent_folio(struct folio *folio) { unsigned long src_pfn, dst_pfn = 0; - struct page *dpage; + struct folio *dfolio; - WARN_ON_ONCE(PageCompound(page)); + WARN_ON_ONCE(folio_test_large(folio)); - lock_page(page); - src_pfn = migrate_pfn(page_to_pfn(page)) | MIGRATE_PFN_MIGRATE; + folio_lock(folio); + src_pfn = migrate_pfn(folio_pfn(folio)) | MIGRATE_PFN_MIGRATE; /* * We don't have a VMA and don't need to walk the page tables to find - * the source page. So call migrate_vma_unmap() directly to unmap the - * page as migrate_vma_setup() will fail if args.vma == NULL. + * the source folio. So call migrate_vma_unmap() directly to unmap the + * folio as migrate_vma_setup() will fail if args.vma == NULL. */ migrate_device_unmap(&src_pfn, 1, NULL); if (!(src_pfn & MIGRATE_PFN_MIGRATE)) return -EBUSY; - dpage = alloc_page(GFP_USER | __GFP_NOWARN); - if (dpage) { - lock_page(dpage); - dst_pfn = migrate_pfn(page_to_pfn(dpage)); + dfolio = folio_alloc(GFP_USER | __GFP_NOWARN, 0); + if (dfolio) { + folio_lock(dfolio); + dst_pfn = migrate_pfn(folio_pfn(dfolio)); } migrate_device_pages(&src_pfn, &dst_pfn, 1); if (src_pfn & MIGRATE_PFN_MIGRATE) - copy_highpage(dpage, page); + folio_copy(dfolio, folio); migrate_device_finalize(&src_pfn, &dst_pfn, 1); if (src_pfn & MIGRATE_PFN_MIGRATE) From patchwork Mon Aug 26 06:58:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13777224 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 7F836C5321E for ; Mon, 26 Aug 2024 06:58:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39F7E6B0213; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34F586B0248; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F6C36B03D1; Mon, 26 Aug 2024 02:58:38 -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 F24746B0213 for ; Mon, 26 Aug 2024 02:58:37 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 64B2C40D1C for ; Mon, 26 Aug 2024 06:58:37 +0000 (UTC) X-FDA: 82493493474.01.23BF35C Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 1061EC000D for ; Mon, 26 Aug 2024 06:58:34 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1724655402; 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=VVUobr4dJcZwZQQN4rZjWdwoJekZ8plWFjHhFJeXTQg=; b=Kb+D1PgbLMYIEsKJWNgDP/oPm3U490Qw1nGk+DOLypIYWc/JGcx1bFBK2yBzQg8eBOGDrz xo3+inNaK9XS5uCvXvBwTmu4NsrpRtExhFaNsCGIQqZJysg5U1phZjSLnOeXLIDN4X7yRv aLjihtHMdIo15yZHfEjhOc5vV9PNGX0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1724655402; a=rsa-sha256; cv=none; b=qo43Vq+sOmUKeSriu1o9MPMuVTyuAbUvPwtD2kzGfih2v5x9NZQZW49gdC2M2XWI0aJmW1 +nX1gDKEXAxa9BNl4gsdPpqCYnmc9ZzaH2IoV7YAZLNFOjyI7BdKA2Nh0AC3pvSBLBe5E6 blY6AEvKyCbeBsAqMfNCrLdfPZVnvfY= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4WshKt69Sfz1xvYj; Mon, 26 Aug 2024 14:56:34 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 8CCE81A016C; Mon, 26 Aug 2024 14:58:31 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 26 Aug 2024 14:58:31 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Matthew Wilcox , Baolin Wang , Zi Yan , Alistair Popple , Jonathan Corbet , , Kefeng Wang Subject: [PATCH 2/6] mm: migrate_device: use a folio in migrate_device_range() Date: Mon, 26 Aug 2024 14:58:10 +0800 Message-ID: <20240826065814.1336616-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> References: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1061EC000D X-Stat-Signature: p364q7dqcyjiqc1ecn9fsfyu5bgc53u6 X-Rspam-User: X-HE-Tag: 1724655514-734682 X-HE-Meta: U2FsdGVkX1/JzfyCNC2pCUYL5i6bPbaia5EE6oP3OPCimF7HaqmkyD+zNxjaHqzyrPfU/edPIBOl66v9cWxAegbzO1s648OB2n1ANl4b8Jgd8bEv6QzVQTvIE7o/bhgvJVfbD1zSM9nckp8CgtTvO+UsEEbGStEaB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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Save two calls to compound_head() and use folio throughout. Signed-off-by: Kefeng Wang Acked-by: David Hildenbrand Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Alistair Popple --- mm/migrate_device.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 82d75205dda8..66db28b89f9b 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -898,16 +898,17 @@ int migrate_device_range(unsigned long *src_pfns, unsigned long start, unsigned long i, pfn; for (pfn = start, i = 0; i < npages; pfn++, i++) { - struct page *page = pfn_to_page(pfn); + struct folio *folio; - if (!get_page_unless_zero(page)) { + folio = folio_get_nontail_page(pfn_to_page(pfn)); + if (!folio) { src_pfns[i] = 0; continue; } - if (!trylock_page(page)) { + if (!folio_trylock(folio)) { src_pfns[i] = 0; - put_page(page); + folio_put(folio); continue; } From patchwork Mon Aug 26 06:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13777226 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 549C4C5472F for ; Mon, 26 Aug 2024 06:58:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1B086B0248; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7E0E6B03DF; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0DF76B03D6; Mon, 26 Aug 2024 02:58:38 -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 6FC8F6B03D3 for ; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 255AAC0C6E for ; Mon, 26 Aug 2024 06:58:38 +0000 (UTC) X-FDA: 82493493516.24.4902274 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf29.hostedemail.com (Postfix) with ESMTP id 0483B12000B for ; Mon, 26 Aug 2024 06:58:35 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1724655432; 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=UQLQHJIl4ePQ9CVMJZVMiSf3ev3ADjmuz57PPMeUC98=; b=Ur/zPEdiwCIlfloBXkAgDSW5t09L0Kn5Oqc85rBW8lssIsU3HrVJcMKOL87DFa0GbtiQUp xVfVRcOE9mF6BCTfIQsBIUdqUoytYVU06DO62LDdgujx3aMG6vVR9DOKf0uaTSPtZTwiCn GtGK1AcCup6yQB7a1B7lx2uYa12m6fo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724655432; a=rsa-sha256; cv=none; b=PLBxbp4ObsH0AquzF9MCJe9+SKreBhvLSi1e/uIWHBlehceNzHgRBhBQdWo6hgYLLxcsO5 dH158WgIuiV/5jaXvQzTk833lkpUJ5kLHB9Q78poOehpU9UuZUpXU7rXyEk40HWBCpneIu 3WzoWzZ24Hh3d3lLsz2UCWJPjYXFP68= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WshMz3qTWz2CnZp; Mon, 26 Aug 2024 14:58:23 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 16A24140120; Mon, 26 Aug 2024 14:58:32 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 26 Aug 2024 14:58:31 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Matthew Wilcox , Baolin Wang , Zi Yan , Alistair Popple , Jonathan Corbet , , Kefeng Wang Subject: [PATCH 3/6] mm: migrate_device: use more folio in migrate_device_unmap() Date: Mon, 26 Aug 2024 14:58:11 +0800 Message-ID: <20240826065814.1336616-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> References: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Queue-Id: 0483B12000B X-Stat-Signature: oaarn95s6guxdkqwuaqk1wq7um95ebr6 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724655515-259499 X-HE-Meta: U2FsdGVkX1/5FCIuL9COTdw4ciD9mQqLjyPhyqlmtUmoka8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HRo4w86TrZePkH3r7KvHUcBAYG78KNv5tu3E0PpjB86Hnp8ZZb1f/UUzewfNDHymniN1mJH64tWjlqwBiOII3OeQZldF8oCRTg45yEYy7VEL4i91uhMFa0P/epj5P92eavOLfP6NNfmKRPNTEk2OfNgeWjKxUTs9Jgg1rHqXrugOJHiMRi6SA== 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 Acked-by: David Hildenbrand Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Alistair Popple --- mm/migrate_device.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 66db28b89f9b..b49f4956617a 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; } - /* ZONE_DEVICE pages are not on LRU */ - if (!is_zone_device_page(page)) { - if (!PageLRU(page) && allow_drain) { + folio = page_folio(page); + /* ZONE_DEVICE folios are not on LRU */ + 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) || + if (folio_mapped(folio) || !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 Mon Aug 26 06:58:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13777229 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 98153C5472F for ; Mon, 26 Aug 2024 06:58:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FBD46B044E; Mon, 26 Aug 2024 02:58:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AD0A6B044F; Mon, 26 Aug 2024 02:58:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 573546B0450; Mon, 26 Aug 2024 02:58:40 -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 35D936B044E for ; Mon, 26 Aug 2024 02:58:40 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DDF68C0C6E for ; Mon, 26 Aug 2024 06:58:39 +0000 (UTC) X-FDA: 82493493558.02.ABDD54E Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf28.hostedemail.com (Postfix) with ESMTP id C1CD0C000D for ; Mon, 26 Aug 2024 06:58:37 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1724655475; a=rsa-sha256; cv=none; b=YMXQcb7io5X1BdvT9KqQI+5DMyBr6dqeRq1Sw4hk+BjCMdnEforap5rap1RgxPteI3Heh5 r8gdyrkaS5tNUZov2tmZ7L51UCxryJCylTJKUsHytrcFR69DCkVE1B7U/romPEb+7H3JlJ eUBreFUnS36fHCvh2lY1tDkOH4mmTk0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1724655475; 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=UeRNGyW+q+LLT1TGeS5gLwataL560hmhkLfMBu+4W60=; b=sgpJvYjtlJTAOqnl0hrufpZsYFBJ8qDhY4wFzHlK9cOUbGLc7YHpWG4MxFRzoTMbxvkS5u CEfkfruy6kKeiecYGejVp/WUsQ6fA+5/aMdXki3b/6V09d9if1TwQfhg1mhqrzD2hBb2vo blj/QWN8EcgrATZsJvWXSGbnWe10bKw= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WshN0091rz2CnZy; Mon, 26 Aug 2024 14:58:24 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 8E46F1402CC; Mon, 26 Aug 2024 14:58:32 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 26 Aug 2024 14:58:32 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Matthew Wilcox , Baolin Wang , Zi Yan , Alistair Popple , Jonathan Corbet , , Kefeng Wang Subject: [PATCH 4/6] mm: migrate_device: use more folio in migrate_device_finalize() Date: Mon, 26 Aug 2024 14:58:12 +0800 Message-ID: <20240826065814.1336616-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> References: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Stat-Signature: jx3pc4n4bbqaw8pafxrx77adt61abj8x X-Rspamd-Queue-Id: C1CD0C000D X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724655517-535741 X-HE-Meta: U2FsdGVkX18fGUC7TI5Zr8PiSH/FuCgFnmfcd12eYgZWBEusKPwVLbaltlhL1kKXEBUEAa3aWqjesLATh9x+QLEWw4GUA8lMoHAMZYA0PHu8pRp+ZeRkyOj9u9RwOM66OzGVlYp/aYd/yLwOFN/g3+UkPqBpJU1KBMPW+L7KA9eBghTr/aG3ms7ivr9WClLezTsemrOQchM+7OOA+5TLcEGO/6zEuy+7PWjG8aIXeAqx3/XizYsHwOYd0yao81UN9mEjDBNBJJyqMLf+N7DHdjkrqUqjH9Qnau+pT5N7M+SwU9/TJIDkBOHEflxFSQAdsKxyGZ3eO23T5rD4hPs/n3C8IwHqfrmBlKtfjt9YVKhEB/3JcfesI6YTttNwW7SI6PO6jipN9ZZdAAEqvH70xMM66SmLo7p89YK0vpWp6q3rmDpbmuSYcQxUWbPpjfU+OYef/6ORirq9hJBxBFp0hiIYm1nw7etZR71Xpi9FVlRWQtjBMiaWRW5724URbQMOzOYSxBGswGG/MWJMQUF2FJ4NxtQcPOmGqPyEeQSn4xMfi/yGuiI8HeF9sDjLrETokjNnFkpRK1jXidRb7aLp4CFgEdh4msiwrLZDLzi1tzUUujpj+tb9yLFoo7G7NqsZJL9G+rE+WOn7la3AYdCYnJf2di8ONZquHGP0CaU8XnhLHnvZ8s5jJaYC1hbyiY0VRWzk0d01hkBqe6u1tjlK/FunMQi7n3VzIcegystKPB6E+1PFNtq28LJnM6xZHnqWH+6FWz/RYeIdA7sJmZmZITlwwLAH2K++HbTEopThxlf7An18yQA9LMB0ybl2TOnieoq8FP1xxhA+zLPtZP4AmAGEGIXJL/HrSGC2nQlE8k5dDrxu0xO7WxH3Ts+13j/+s6xupCq0vT/xtv5D2z7jBM9JngvpRtAdgIbePv8d1wRH7VuNCIXMhaQH6vNg78BWxMP0xKSG8jHAt51dQKI +y6CMh70 15uXHHD46Snpkx+z9fbHMxY3jLpSHMfB5YO0r+4FQwwk9AbBL1qW5syDK2JeWfhOzN49G1Un2qw4lcSsYW5xbIA7Z3PPzfD7oz4lt5AGSO8eDXcNoqC0oMpQ3WVOxc75tM13GslaejikkrDrLsHVVUM4uqSOeut4QB+RqkLrPYgOg1ewWniLI7b/vR7QMfmiwCIdDL4VenMVH61G/cKzYdNgHcbS/9JnIoistsEqQbLnVhqEHDptvgDDRWne5P1O+bkxY8Gv2byzH9dn5Sma3GbRgwOCf2Us0RkPEoVoajmL+4sNmR5TzGz3mQA== 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: Saves a couple of calls to compound_head() and remove last two callers of putback_lru_page(). Signed-off-by: Kefeng Wang Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Alistair Popple --- mm/migrate_device.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index b49f4956617a..6ea3d055f520 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -815,42 +815,45 @@ void migrate_device_finalize(unsigned long *src_pfns, unsigned long i; for (i = 0; i < npages; i++) { - struct folio *dst, *src; + struct folio *dst = NULL, *src = NULL; struct page *newpage = migrate_pfn_to_page(dst_pfns[i]); struct page *page = migrate_pfn_to_page(src_pfns[i]); + if (newpage) + dst = page_folio(newpage); + if (!page) { - if (newpage) { - unlock_page(newpage); - put_page(newpage); + if (dst) { + folio_unlock(dst); + folio_put(dst); } continue; } - if (!(src_pfns[i] & MIGRATE_PFN_MIGRATE) || !newpage) { - if (newpage) { - unlock_page(newpage); - put_page(newpage); + src = page_folio(page); + + if (!(src_pfns[i] & MIGRATE_PFN_MIGRATE) || !dst) { + if (dst) { + folio_unlock(dst); + folio_put(dst); } - newpage = page; + dst = src; } - src = page_folio(page); - dst = page_folio(newpage); remove_migration_ptes(src, dst, false); folio_unlock(src); - if (is_zone_device_page(page)) - put_page(page); + if (folio_is_zone_device(src)) + folio_put(src); else - putback_lru_page(page); + folio_putback_lru(src); - if (newpage != page) { - unlock_page(newpage); - if (is_zone_device_page(newpage)) - put_page(newpage); + if (dst != src) { + folio_unlock(dst); + if (folio_is_zone_device(dst)) + folio_put(dst); else - putback_lru_page(newpage); + folio_putback_lru(dst); } } } From patchwork Mon Aug 26 06:58:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13777227 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 E5035C5321E for ; Mon, 26 Aug 2024 06:58:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EFAD6B044D; Mon, 26 Aug 2024 02:58:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39E916B044F; Mon, 26 Aug 2024 02:58:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28D8D6B044E; Mon, 26 Aug 2024 02:58:39 -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 0963D6B03E2 for ; Mon, 26 Aug 2024 02:58:39 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C486AA8759 for ; Mon, 26 Aug 2024 06:58:38 +0000 (UTC) X-FDA: 82493493516.10.DA9EF29 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf08.hostedemail.com (Postfix) with ESMTP id 3D8E8160008 for ; Mon, 26 Aug 2024 06:58:35 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724655449; 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=1R7RNhVSMA7NE39bvuxwgfpl5tnR1KhWssexa8TD98s=; b=gyexquBrk5tvhySXYHc6bCZz78BtQfwp/BrbLLaNACHQBKvUB0g/JlhHX9akFrWTNw0rAA Nwa2Ag6TmS5SQA/m/UfARk90UPaVDIMtnc/Ei7lhDqMVm/q0RPydoGhgf6y8cRuilH6wOh XhuIyZ1pExzEa1Hy+YG2I5TNfD/xacY= 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.255 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=1724655449; a=rsa-sha256; cv=none; b=bYkJyyQrBLGX9etmRUQ6phBowoa1IDqqN/3WA9XHBVOBqBl492HTJ3ZmZVEeSwrzKNB157 kROCgOycFXDJadJJ3givIz9TJQZff8CKdwt6OkykpK6vBOi4YttGaIPhPjM8eGPDYSmpNA C5YJ+FFBsUIl0+A01Ko/e31wWNnOkYE= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WshMH5Lyfz14G0f; Mon, 26 Aug 2024 14:57:47 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 15BC5180101; Mon, 26 Aug 2024 14:58:33 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 26 Aug 2024 14:58:32 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Matthew Wilcox , Baolin Wang , Zi Yan , Alistair Popple , Jonathan Corbet , , Kefeng Wang Subject: [PATCH 5/6] mm: remove isolate_lru_page() Date: Mon, 26 Aug 2024 14:58:13 +0800 Message-ID: <20240826065814.1336616-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> References: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Stat-Signature: oedtuu98ep33ms4wsyt551zcx3nngccr X-Rspam-User: X-Rspamd-Queue-Id: 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WGNicCh2IKr63DUBHUg1Di2Bn8DPNDmrxHRZFZohFPRODUipEwOs5Q/tBEM0808hlys6kqpP5YmqHhbOysQPrSrNopG5Z6XS8eociI15JBB7X7IRu0MOtZwK4pKwhD+JYL78gQeAU28Li10UB6boYijp37DO0C1x42M6xyUedYDOYx1EhKnDMzW4m2fniEO1N 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 255ef12a432b..04113c2a2f9e 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 0f13126b43b0..0a5a04ad6c21 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -114,7 +114,7 @@ * ->private_lock (try_to_unmap_one) * ->i_pages lock (try_to_unmap_one) * ->lruvec->lru_lock (follow_page_mask->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 f05906006b3c..47b8cc245aa4 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -93,13 +93,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 0f4750f77f59..3ee5810f5231 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -416,7 +416,6 @@ extern unsigned long highest_memmap_pfn; /* * 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 4a83c40d9053..b87eacfac5a7 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -627,7 +627,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. @@ -1874,7 +1874,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); @@ -1889,7 +1889,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 6ea3d055f520..f1faff058491 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 e0dbfc98318e..634fde80cd44 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -906,7 +906,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. * From patchwork Mon Aug 26 06:58:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13777228 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 697B1C5321D for ; Mon, 26 Aug 2024 06:58:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F7C76B03E2; Mon, 26 Aug 2024 02:58:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D0036B044E; Mon, 26 Aug 2024 02:58:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7212B6B044F; Mon, 26 Aug 2024 02:58:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 356966B03E2 for ; Mon, 26 Aug 2024 02:58:39 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E2CB1120D1C for ; Mon, 26 Aug 2024 06:58:38 +0000 (UTC) X-FDA: 82493493516.04.B72D9DD Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf21.hostedemail.com (Postfix) with ESMTP id 85A861C0004 for ; Mon, 26 Aug 2024 06:58:36 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.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=1724655431; 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=MxcclLw78/t36j9fHPZfOsT1iuHj1oNPPJ+v439xXfE=; b=F5TPb7TpFhS4ryRB8nrJTMRH9ZkZUQqLmRVAvyTH1IWTyKmoYX5rIvJ61AbVmNZZQ2WpN2 JmVzAg+XuJYZZzcYNopK/qOhBJ4LpTAIlVG067LwAOZdOyDEsPI4m5SUzV1kTIMFyKKfjc VoBf4aWf2bjPIeG5/xCv0gYjnhpVepM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724655431; a=rsa-sha256; cv=none; b=vGvKoWXos2CRNKGxoC3NOxHgCiT8+9GRfeBaZx3buN0VdwQsgtS3wjPGK/2L8bJoBziOK1 48fUB4ohZzDUyY377ACcKmDqnsAfWVdM1RgkObI7RDvIxJe8A9DdXdCVuE7NN26xxVZuva x+w3xTurvgMPkfv0lPTsbGBttuB0obs= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.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 Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4WshJN1McZz1HHKg; Mon, 26 Aug 2024 14:55:16 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 8F414140120; Mon, 26 Aug 2024 14:58:33 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 26 Aug 2024 14:58:33 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Matthew Wilcox , Baolin Wang , Zi Yan , Alistair Popple , Jonathan Corbet , , Kefeng Wang Subject: [PATCH 6/6] mm: remove putback_lru_page() Date: Mon, 26 Aug 2024 14:58:14 +0800 Message-ID: <20240826065814.1336616-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> References: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Stat-Signature: fe1tca9rxz8bhkf15b3fkb143z8p3iri X-Rspamd-Queue-Id: 85A861C0004 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724655516-120813 X-HE-Meta: U2FsdGVkX18KxmiajTzDAw2bkwXhYOD3r+qtpTGC5zs4cLhn9xitKlGERsSOerUMRJACxRHL1JCkQICaQLAvIel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gx8M1Qf4rONgadclIG 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 Acked-by: David Hildenbrand Reviewed-by: Vishal Moola (Oracle) --- mm/folio-compat.c | 5 ----- mm/internal.h | 1 - 2 files changed, 6 deletions(-) diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 47b8cc245aa4..80746182e9e8 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -92,8 +92,3 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping, mapping_gfp_mask(mapping)); } EXPORT_SYMBOL(grab_cache_page_write_begin); - -void putback_lru_page(struct page *page) -{ - folio_putback_lru(page_folio(page)); -} diff --git a/mm/internal.h b/mm/internal.h index 3ee5810f5231..f1fee5f235c5 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -417,7 +417,6 @@ extern unsigned long highest_memmap_pfn; * in mm/vmscan.c: */ bool folio_isolate_lru(struct folio *folio); -void putback_lru_page(struct page *page); void folio_putback_lru(struct folio *folio); extern void reclaim_throttle(pg_data_t *pgdat, enum vmscan_throttle_state reason);