From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Muchun Song <muchun.song@linux.dev>,
linux-mm@kvack.org, Sidhartha Kumar <sidhartha.kumar@oracle.com>
Subject: [PATCH 3/3] hugetlb: Convert remove_pool_huge_page() to return a folio
Date: Tue, 22 Aug 2023 17:28:07 +0100 [thread overview]
Message-ID: <20230822162808.4131399-3-willy@infradead.org> (raw)
In-Reply-To: <20230822162808.4131399-1-willy@infradead.org>
Convert the callers to expect a folio and remove the unnecesary conversion
back to a struct page.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
mm/hugetlb.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index d6309edb59e5..283cd5290515 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -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_huge_page(struct hstate *h,
+ nodemask_t *nodes_allowed, bool acct_surplus)
{
int nr_nodes, node;
struct folio *folio;
@@ -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);
@@ -2622,11 +2620,13 @@ static void return_unused_surplus_pages(struct hstate *h,
* 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_huge_page(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_huge_page(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);
--
2.40.1
next prev parent reply other threads:[~2023-08-22 16:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 16:28 [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn() Matthew Wilcox (Oracle)
2023-08-22 16:28 ` [PATCH 2/3] hugetlb: Remove a few calls to page_folio() Matthew Wilcox (Oracle)
2023-08-23 22:41 ` Mike Kravetz
2023-08-24 2:59 ` Muchun Song
2023-08-24 13:59 ` kernel test robot
2023-10-13 9:06 ` Dan Carpenter
2023-08-22 16:28 ` Matthew Wilcox (Oracle) [this message]
2023-08-23 22:48 ` [PATCH 3/3] hugetlb: Convert remove_pool_huge_page() to return a folio Mike Kravetz
2023-08-24 1:10 ` Matthew Wilcox
2023-08-24 2:38 ` Muchun Song
2023-08-23 22:37 ` [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn() Mike Kravetz
2023-08-24 2:58 ` Muchun Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230822162808.4131399-3-willy@infradead.org \
--to=willy@infradead.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=sidhartha.kumar@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox