From patchwork Wed Aug 16 15:11:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13355396 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 2FE76C001E0 for ; Wed, 16 Aug 2023 15:14:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5550280026; Wed, 16 Aug 2023 11:14:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C02FC280021; Wed, 16 Aug 2023 11:14:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACAA3280026; Wed, 16 Aug 2023 11:14:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9DB1A280021 for ; Wed, 16 Aug 2023 11:14:13 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B264C1A0EEC for ; Wed, 16 Aug 2023 15:14:12 +0000 (UTC) X-FDA: 81130313544.19.9156552 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id C7CDE40253 for ; Wed, 16 Aug 2023 15:12:28 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MYS2+QQ+; dmarc=none; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692198749; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OqHtlaBwPOyYVd0BxuxqJHAwBK92pIIYqbMfco12ie4=; b=ks+yIwd2HbbaiOwf87jWijWZYlWGMs9k97O78WTD2aJ8uGCcjoUOpLgEyby/QTRFtEYTo5 MI/IQt3+kd9Du2gobEkBwpCOGxnfNtQc/gagaxcLesxLWoYd9T4sQsVbGauToZWtMfZGpm Cz8ZZHEdL4n+JfE/Z7J2ISdJ11JnevQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MYS2+QQ+; dmarc=none; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692198749; a=rsa-sha256; cv=none; b=TveOxMX+HWQw6uZ7QAguA3uzuaNjvj6ki/3nYmDxfr8BXiqHLDLE3FP6mVffA/G/3uiYPF vQK3sqLKx0aVUU/9q69vVIaT/GJj6EdcEtMOLL/K4HLeyTivtcCjxCjMerSqvHrrxzSxRE fJ0dGP0zASynBQimoSp9GaXqmYSKm7c= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=OqHtlaBwPOyYVd0BxuxqJHAwBK92pIIYqbMfco12ie4=; b=MYS2+QQ+X+fK4cGw3tU2wA2sSl MjekAsM3RnYqbnq8S1LtlyrLH4UL8MVTTuK23DRXIG6iQmyAkDDzKxZ5wK85oubGzcJts7DRZeUc4 Xu0Z//4Im2awNk/ExV2MJjM/NlSvo5zxOeiRqbkSMo8A2qEpkhftSpoemyd9GQMFw3QK1Tu8hbj/U Xjy+51WMZI19LNCx/ahY8MOGBcFhMu0wQnzWWM3zW5KOnzcW4JFSSfeRXyPmTFUla6DjF6jWh59E+ 5N8G/u3ZZ4GNZni7vCgFRdeF57he5ZZhXdW+cr8JZUUXSO92jT83PMe1aLz4msy0Ub3awvjg9kR4W +3oWGX0w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qWIBu-00FL8X-9l; Wed, 16 Aug 2023 15:12:10 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Jens Axboe , io-uring@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 05/13] mm; Convert prep_transhuge_page() to folio_prep_large_rmappable() Date: Wed, 16 Aug 2023 16:11:53 +0100 Message-Id: <20230816151201.3655946-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230816151201.3655946-1-willy@infradead.org> References: <20230816151201.3655946-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C7CDE40253 X-Stat-Signature: bgsmsofcuut1npfawqbgurfm5oaizbw6 X-HE-Tag: 1692198748-818852 X-HE-Meta: U2FsdGVkX1/boT7z51A0y08+pkRgkAVdiYIeCB1faJRvTA8Qc20VO7plSegt4EqndyFFtiBZPNDunNqmTgWlJXjlgjVBJZV0fN1zYbSCt9Gnot7dEjhX/rXd+qB7mibR4QfJvl3KmaQs7nHMXExfhgZ7tUj1cMbolUytaZ3ZUq4MwfFQL07bXx5nq9nTBVgummPT2pJ3nXaQpvLelgRGMEJ778Sad4pPYg8q537IcGMfKdjP2mse66Db+mH2MBjwOuxZiIKXMzp6b/TdiQr+21eaJ6XL03ddkmBCymdDNNzZwrUi0B3ym8n6cLrkVisBUqeVAu7eBsW6b69qyNNYJ/uCsM3STaUK8X4Os/MVzU5eIfoS9Ka74fi3CbcmpgmdYDEZ48fNjlLRFB0GJLFQ66U5uYHYy2APXql2ZLoiRqhvy53hOALEljBZl6CfepNjgZKXh3b2ebB38uOlUKfDIdZNPqm8N+Se7gkZMZIwCqVITSPNx39m+4lQhX2Fd7adGHO14McW8DoJwTj+jaK556BrY/zUXzqKzhcpSn/K2FsmKZxkSoYXrR5QBFoLIEzWopNY+rm+9IArTgi1ty4vgbYvYXmP+ccMWYRURmfBNrJuvD56YS6IUGotM/JOhBLJiAHH8gL65LO1BiKlQTgbnkXCJE31vK8v7AvN4j53Rui6Z9yruT/Wh5Dv6RcmKeNWHXjVGJ50l1hHf7V8vk/w7U2zVMZtVdnh0QxAC1W1oooLLUj8nFXZJAy20j3r9zVvGhkroA5boqJ5/zay6hzfta74a91FlT56YfSKu1K5oa1zJ8CmsOeGwmRFPUYrJhEwzRndhnLrqf/uMjA0CsY1K5RVFWA7NIiVKOYCCHy1Up0l+r4x9eSBipv6B/uqJljTQ0DdH8Ar4HVOul5MWbXYqrk4OE4lMJfYzGybPYdhsuX+caRtgo6scNHiCQQ4/NHAzeMR4PBdqVkMKXcy2/1 DgbHSy7a r3qXn/xNXC2JCj+SRckWbMgaG02VwTOBLsUmTuT+cFbpIS2aQ2x15oFuT+ShayEmqoIM3fkyFZyjKtzFfAQ0rcyBhALZUWQTZvS/J68ZPlR9gU/xW0CsQmoa0MdUn1ji49AoGBJKBJ39SgphS9JBcf2f3r0J1+1AqmFYvmfiTG/EeriVEu4SAgQhnvIeVpiT0Y6sXysTdA7/Zx2SsrzJmUBkZ0r8oA2n4glc8 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: Match folio_undo_large_rmappable(), and move the casting from page to folio into the callers (which they were largely doing anyway). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/huge_mm.h | 4 ++-- mm/huge_memory.c | 4 +--- mm/khugepaged.c | 2 +- mm/mempolicy.c | 15 ++++++++------- mm/page_alloc.c | 7 ++++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index f351c3f9d58b..6d812b8856c8 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -143,7 +143,7 @@ bool hugepage_vma_check(struct vm_area_struct *vma, unsigned long vm_flags, unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); -void prep_transhuge_page(struct page *page); +void folio_prep_large_rmappable(struct folio *folio); bool can_split_folio(struct folio *folio, int *pextra_pins); int split_huge_page_to_list(struct page *page, struct list_head *list); static inline int split_huge_page(struct page *page) @@ -283,7 +283,7 @@ static inline bool hugepage_vma_check(struct vm_area_struct *vma, return false; } -static inline void prep_transhuge_page(struct page *page) {} +static inline void folio_prep_large_rmappable(struct folio *folio) {} #define transparent_hugepage_flags 0UL diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 9598bbe6c792..04664e6918c1 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -577,10 +577,8 @@ struct deferred_split *get_deferred_split_queue(struct folio *folio) } #endif -void prep_transhuge_page(struct page *page) +void folio_prep_large_rmappable(struct folio *folio) { - struct folio *folio = (struct folio *)page; - VM_BUG_ON_FOLIO(folio_order(folio) < 2, folio); INIT_LIST_HEAD(&folio->_deferred_list); folio_set_compound_dtor(folio, TRANSHUGE_PAGE_DTOR); diff --git a/mm/khugepaged.c b/mm/khugepaged.c index bb76a5d454de..a8e0eca2cd1e 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -896,7 +896,7 @@ static bool hpage_collapse_alloc_page(struct page **hpage, gfp_t gfp, int node, return false; } - prep_transhuge_page(*hpage); + folio_prep_large_rmappable((struct folio *)*hpage); count_vm_event(THP_COLLAPSE_ALLOC); return true; } diff --git a/mm/mempolicy.c b/mm/mempolicy.c index c53f8beeb507..4afbb67ccf27 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2189,9 +2189,9 @@ struct folio *vma_alloc_folio(gfp_t gfp, int order, struct vm_area_struct *vma, mpol_cond_put(pol); gfp |= __GFP_COMP; page = alloc_page_interleave(gfp, order, nid); - if (page && order > 1) - prep_transhuge_page(page); folio = (struct folio *)page; + if (folio && order > 1) + folio_prep_large_rmappable(folio); goto out; } @@ -2202,9 +2202,9 @@ struct folio *vma_alloc_folio(gfp_t gfp, int order, struct vm_area_struct *vma, gfp |= __GFP_COMP; page = alloc_pages_preferred_many(gfp, order, node, pol); mpol_cond_put(pol); - if (page && order > 1) - prep_transhuge_page(page); folio = (struct folio *)page; + if (folio && order > 1) + folio_prep_large_rmappable(folio); goto out; } @@ -2300,10 +2300,11 @@ EXPORT_SYMBOL(alloc_pages); struct folio *folio_alloc(gfp_t gfp, unsigned order) { struct page *page = alloc_pages(gfp | __GFP_COMP, order); + struct folio *folio = (struct folio *)page; - if (page && order > 1) - prep_transhuge_page(page); - return (struct folio *)page; + if (folio && order > 1) + folio_prep_large_rmappable(folio); + return folio; } EXPORT_SYMBOL(folio_alloc); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0dbc2ecdefa5..5ee4dc9318b7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4548,10 +4548,11 @@ struct folio *__folio_alloc(gfp_t gfp, unsigned int order, int preferred_nid, { struct page *page = __alloc_pages(gfp | __GFP_COMP, order, preferred_nid, nodemask); + struct folio *folio = (struct folio *)page; - if (page && order > 1) - prep_transhuge_page(page); - return (struct folio *)page; + if (folio && order > 1) + folio_prep_large_rmappable(folio); + return folio; } EXPORT_SYMBOL(__folio_alloc);