From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE0B5C4332F for ; Thu, 15 Dec 2022 21:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229510AbiLOVlz (ORCPT ); Thu, 15 Dec 2022 16:41:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiLOVly (ORCPT ); Thu, 15 Dec 2022 16:41:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6881CFEC for ; Thu, 15 Dec 2022 13:41:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B2373B81CAE for ; Thu, 15 Dec 2022 21:41:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EFBBC433D2; Thu, 15 Dec 2022 21:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1671140509; bh=72zIHWCTutLRPciZeSYMZq/SUgp5CHSX4ita6lGDPHo=; h=Date:To:From:Subject:From; b=jerPtYeffTpHktQj2ocsAeE9BpgJc/8u4gS7cGTVQO7quQEP7M7uPq5srnFJipOfC FVY061vuAzK+8QbEUrc6lO4msENi5h1It0SMrjgqGwSzHBTxjwXscrOY7WqS4RgHS9 fVCuj33K9X4bcXYN0IidSNt28+aSbcy+jVc5uSC0= Date: Thu, 15 Dec 2022 13:41:48 -0800 To: mm-commits@vger.kernel.org, willy@infradead.org, songmuchun@bytedance.com, mike.kravetz@oracle.com, jhubbard@nvidia.com, sidhartha.kumar@oracle.com, akpm@linux-foundation.org From: Andrew Morton Subject: + mm-move-folio_set_compound_order-to-mm-internalh.patch added to mm-unstable branch Message-Id: <20221215214149.4EFBBC433D2@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: mm: move folio_set_compound_order() to mm/internal.h has been added to the -mm mm-unstable branch. Its filename is mm-move-folio_set_compound_order-to-mm-internalh.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-move-folio_set_compound_order-to-mm-internalh.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Sidhartha Kumar Subject: mm: move folio_set_compound_order() to mm/internal.h Date: Wed, 14 Dec 2022 22:17:57 -0800 folio_set_compound_order() is moved to an mm-internal location so external folio users cannot misuse this function. Change the name of the function to folio_set_order() and use WARN_ON_ONCE() rather than BUG_ON. Also, handle the case if a non-large folio is passed and add clarifying comments to the function. Link: https://lore.kernel.org/lkml/20221207223731.32784-1-sidhartha.kumar@oracle.com/T/ Link: https://lkml.kernel.org/r/20221215061757.223440-1-sidhartha.kumar@oracle.com Fixes: 9fd330582b2f ("mm: add folio dtor and order setter functions") Signed-off-by: Sidhartha Kumar Suggested-by: Mike Kravetz Suggested-by: Muchun Song Suggested-by: Matthew Wilcox Suggested-by: John Hubbard Reviewed-by: John Hubbard Reviewed-by: Muchun Song Signed-off-by: Andrew Morton --- include/linux/mm.h | 16 ---------------- mm/hugetlb.c | 6 +++--- mm/internal.h | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 19 deletions(-) --- a/include/linux/mm.h~mm-move-folio_set_compound_order-to-mm-internalh +++ a/include/linux/mm.h @@ -1019,22 +1019,6 @@ static inline void set_compound_order(st #endif } -/* - * folio_set_compound_order is generally passed a non-zero order to - * initialize a large folio. However, hugetlb code abuses this by - * passing in zero when 'dissolving' a large folio. - */ -static inline void folio_set_compound_order(struct folio *folio, - unsigned int order) -{ - VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); - - folio->_folio_order = order; -#ifdef CONFIG_64BIT - folio->_folio_nr_pages = order ? 1U << order : 0; -#endif -} - /* Returns the number of pages in this potentially compound page. */ static inline unsigned long compound_nr(struct page *page) { --- a/mm/hugetlb.c~mm-move-folio_set_compound_order-to-mm-internalh +++ a/mm/hugetlb.c @@ -1344,7 +1344,7 @@ static void __destroy_compound_gigantic_ set_page_refcounted(p); } - folio_set_compound_order(folio, 0); + folio_set_order(folio, 0); __folio_clear_head(folio); } @@ -1808,7 +1808,7 @@ static bool __prep_compound_gigantic_fol __folio_clear_reserved(folio); __folio_set_head(folio); /* we rely on prep_new_hugetlb_folio to set the destructor */ - folio_set_compound_order(folio, order); + folio_set_order(folio, order); for (i = 0; i < nr_pages; i++) { p = folio_page(folio, i); @@ -1872,7 +1872,7 @@ out_error: p = folio_page(folio, j); __ClearPageReserved(p); } - folio_set_compound_order(folio, 0); + folio_set_order(folio, 0); __folio_clear_head(folio); return false; } --- a/mm/internal.h~mm-move-folio_set_compound_order-to-mm-internalh +++ a/mm/internal.h @@ -378,6 +378,25 @@ extern void *memmap_alloc(phys_addr_t si int split_free_page(struct page *free_page, unsigned int order, unsigned long split_pfn_offset); +/* + * This will have no effect, other than possibly generating a warning, if the + * caller passes in a non-large folio. + */ +static inline void folio_set_order(struct folio *folio, unsigned int order) +{ + if (WARN_ON_ONCE(!folio_test_large(folio))) + return; + + folio->_folio_order = order; +#ifdef CONFIG_64BIT + /* + * When hugetlb dissolves a folio, we need to clear the tail + * page, rather than setting nr_pages to 1. + */ + folio->_folio_nr_pages = order ? 1U << order : 0; +#endif +} + #if defined CONFIG_COMPACTION || defined CONFIG_CMA /* _ Patches currently in -mm which might be from sidhartha.kumar@oracle.com are mm-move-folio_set_compound_order-to-mm-internalh.patch