From patchwork Thu Aug 24 14:13:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13364246 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 09677C3DA6F for ; Thu, 24 Aug 2023 14:13:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50C4E2800B0; Thu, 24 Aug 2023 10:13:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46ED72800AB; Thu, 24 Aug 2023 10:13:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29B202800B0; Thu, 24 Aug 2023 10:13:40 -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 0CDDD2800AB for ; Thu, 24 Aug 2023 10:13:40 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 99096160336 for ; Thu, 24 Aug 2023 14:13:39 +0000 (UTC) X-FDA: 81159191358.22.EB8401D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 5CDFB180031 for ; Thu, 24 Aug 2023 14:13:36 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sPa61H5v; dmarc=none; spf=none (imf24.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=1692886417; 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=SsFJQNcfE3nVkojz2bjT5SHs5TvxKlqqWYc1ctQJ8EI=; b=BGnDD4nQHe12zbmoLdH9zxZ0m6fxfi40Sm6eSSw40m9bx1JeQ3VyFKC/8TUeXWksnBOhYU I1LatexAeA1tm4D/3GRSCX6RHa5Nm09XdENFVtFRM/2TwPTcuu4s8poL9ZVnnfX2D3JXEN IO4oMYYIoKSeFvcpmNMMHFTtz+5FVNc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sPa61H5v; dmarc=none; spf=none (imf24.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=1692886417; a=rsa-sha256; cv=none; b=1bwxUV1ypiabDZBJ1eCXdCt4tH5jSodW4n6R+2AapTSV2SytQQHVW+BSFBgv3M2a7+7tMU ciz1Xdkq8VxhH1HctmkJv4Prwf6PzKpgvQgY7LwSCdiEndZp4lrc1AbBF3nT7SzLMkabHI tMDj6tBJijDKt85+i7kdy8LrLgEQPsM= 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=SsFJQNcfE3nVkojz2bjT5SHs5TvxKlqqWYc1ctQJ8EI=; b=sPa61H5vcZnXuxVSblnCWi+hzo 3+qOHEyuBeFd71YeHiZ4ZTubVCAsRffiUERif/27cBPENerVODQdPdVcmITk6XYQxeR73x5H8s+DO XGP+9mS83PQZPSnLPvrzDJXr0EdED++FBJ5VsBHdS/WQotLPX3LK4z2zFY3R3yKDd3ySlW2U5k08N HVzzSLm8BimsYy0xxFCP7u6Vd8KR8vuHeY8Nr6oQ6QIRhROeFpb3cm4Qfgq/tnowLReeuo+M7/8qo jaHIyZ9pBbqnY4p97p/7LhHU9ztB0S7/14cKrbzu2renA5VP8fR4gwxceIVs0+vEDaNqsl4Nw0QY6 es2Nzl1Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qZB5U-00BLae-Rv; Thu, 24 Aug 2023 14:13:28 +0000 From: "Matthew Wilcox (Oracle)" To: Mike Kravetz Cc: "Matthew Wilcox (Oracle)" , Muchun Song , linux-mm@kvack.org, Sidhartha Kumar Subject: [PATCH v2 3/3] hugetlb: Convert remove_pool_huge_page() to remove_pool_hugetlb_folio() Date: Thu, 24 Aug 2023 15:13:25 +0100 Message-Id: <20230824141325.2704553-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230824141325.2704553-1-willy@infradead.org> References: <20230824141325.2704553-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5CDFB180031 X-Stat-Signature: hgz4njxbwctcet9sphbt6akcarpomqpu X-HE-Tag: 1692886416-215017 X-HE-Meta: U2FsdGVkX1+8hipOgvcgexthPWSnU42/6TCjTmNRdHYFI8EWp5zumpYrwW9X+S+Y4sGmU7dRHoz8wMRQxrQfdk+6k/hOlUNTl27tSLFK4d024Jw6BwPB4eDvz2xDATuO1mAbjnQc3hVcIC6/6D2QGFLzHXeqab1QOHQpt8c7xwvHLQl5l6RH7EChe6RkykGZGUv/9u86W9ClbvHRmNdvZ6XsDc82pugbFfisTSZ5sGlU6cm5jyn0V7bLIepn/yobPomB2pdjnoVwBvODBiVNkcQiMf26E1Ux+KC300TzisnXq74u5D8W4fbCnweT1fCnXbuQFYerN/Cec4McGyD/ZOvGisjqzjfpXmQlwwbQuXk3gfwNz0qFKZSOI8xcTY0ZsLZ3fFsITDRbxPerA++Oy5j9xclwNmmdmKpcLDMLkrvYtj9g8Ft7WDnP7ErsKPRlf3VA5kvOzGvixhCXrgQgjzNsh/jMd9PUd9Yl/qG0X4sT4aP+MT2KNnlgw6A8RE9BHIXiwqYOinenKWRX4Nvx21EQiknfge70dxhsmmKnbonSA9Mj8bM706GIW0sBW9l3GUuuwtdf7M7bCK1u4hmMT13fPWBAct608aXDxa4nhaHgKtyujgDcVRHaykxRRjvkU0niLg5ZZEgy+JGy1+eV3FFBGBGImjnUxRX3DTe//vKaeZXRraoDZQ2Ef2hBFF7Ka7m7iLHoQSZEDiuBmjltMb7qbbc7I8auZhRl9tSyq/Q/537Wtg/6Xyvd2F7J3xGQyyEAtFD4/t+RbaCMyxIkin01+PeoQb9bXesH8BL+ysxNyGMCnj5LiqfEqHJKdU1jpUL2GSFkAEP/zzPvyq+WnsNZ1RtYjh3WSkrRV95MSMwPQgQBwdCKENmMPpTJbdzxld/U385+iCWbZc/KwJgmlgLaR5TcWH4na/jACLoPgZOOXILW2/0Jy46Xcn/aEhnKhy9wbFw8qqUAFq65ATZ 4PRKj01Z BoSKSvnyuXEXY99yY7Qc2pZ3C/kAE6o2r4dIEPoksvAt6IB3YXWcbfRcADBR2zirhGqS2SrVuf49JQkKlC6/H4pE08SeK9Q2/HDTOJ1nJfFD2NSClMPGOwQDodtWO4ZijcZwOjaAWdUUjWDgsZY62Zu0vfM2MF/0gsTgb1Llz0fwIRjJo1vf9PRiPFivhaCSeIJpdDurbbQ1xwMkhyLUwjts9dVZ54VHc/oDvK1NS4L/40kVItd6EUlR8Mg== 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: Convert the callers to expect a folio and remove the unnecesary conversion back to a struct page. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Mike Kravetz Cc: Sidhartha Kumar Reviewed-by: Muchun Song --- mm/hugetlb.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 8f548a274e3c..35dcc7f9b52a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1441,7 +1441,7 @@ static int hstate_next_node_to_alloc(struct hstate *h, } /* - * helper for remove_pool_huge_page() - return the previously saved + * helper for remove_pool_hugetlb_folio() - return the previously saved * node ["this node"] from which to free a huge page. Advance the * next node id whether or not we find a free huge page to free so * that the next attempt to free addresses the next node. @@ -2221,9 +2221,8 @@ static int alloc_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed, * an additional call to free the page to low level allocators. * Called with hugetlb_lock locked. */ -static struct page *remove_pool_huge_page(struct hstate *h, - nodemask_t *nodes_allowed, - bool acct_surplus) +static struct folio *remove_pool_hugetlb_folio(struct hstate *h, + nodemask_t *nodes_allowed, bool acct_surplus) { int nr_nodes, node; struct folio *folio = NULL; @@ -2243,7 +2242,7 @@ static struct page *remove_pool_huge_page(struct hstate *h, } } - return &folio->page; + return folio; } /* @@ -2597,7 +2596,6 @@ static void return_unused_surplus_pages(struct hstate *h, unsigned long unused_resv_pages) { unsigned long nr_pages; - struct page *page; LIST_HEAD(page_list); lockdep_assert_held(&hugetlb_lock); @@ -2618,15 +2616,17 @@ static void return_unused_surplus_pages(struct hstate *h, * evenly across all nodes with memory. Iterate across these nodes * until we can no longer free unreserved surplus pages. This occurs * when the nodes with surplus pages have no free pages. - * remove_pool_huge_page() will balance the freed pages across the + * remove_pool_hugetlb_folio() will balance the freed pages across the * on-line nodes with memory and will handle the hstate accounting. */ while (nr_pages--) { - page = remove_pool_huge_page(h, &node_states[N_MEMORY], 1); - if (!page) + struct folio *folio; + + folio = remove_pool_hugetlb_folio(h, &node_states[N_MEMORY], 1); + if (!folio) goto out; - list_add(&page->lru, &page_list); + list_add(&folio->lru, &page_list); } out: @@ -3421,7 +3421,6 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, nodemask_t *nodes_allowed) { unsigned long min_count, ret; - struct page *page; LIST_HEAD(page_list); NODEMASK_ALLOC(nodemask_t, node_alloc_noretry, GFP_KERNEL); @@ -3541,11 +3540,13 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, * Collect pages to be removed on list without dropping lock */ while (min_count < persistent_huge_pages(h)) { - page = remove_pool_huge_page(h, nodes_allowed, 0); - if (!page) + struct folio *folio; + + folio = remove_pool_hugetlb_folio(h, nodes_allowed, 0); + if (!folio) break; - list_add(&page->lru, &page_list); + list_add(&folio->lru, &page_list); } /* free the pages after dropping lock */ spin_unlock_irq(&hugetlb_lock);