From: Sidhartha Kumar <sidhartha.kumar@oracle.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: akpm@linux-foundation.org, songmuchun@bytedance.com,
mike.kravetz@oracle.com, willy@infradead.org,
Sidhartha Kumar <sidhartha.kumar@oracle.com>
Subject: [PATCH v2] mm/hugetlb: get rid of page_hstate()
Date: Wed, 19 Jul 2023 11:41:45 -0700 [thread overview]
Message-ID: <20230719184145.301911-1-sidhartha.kumar@oracle.com> (raw)
Converts the last page_hstate() user to use folio_hstate() so
page_hstate() can be safely removed.
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
v1->v2:
-change (page - &folio->page) to folio_page_idx(folio, page)
per Matthew Wilcox
include/linux/hugetlb.h | 10 ----------
mm/hugetlb.c | 6 +++---
mm/page_isolation.c | 8 ++++----
3 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 9f4bac3df59e4..0a393bc02f25b 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -841,11 +841,6 @@ static inline struct hstate *folio_hstate(struct folio *folio)
return size_to_hstate(folio_size(folio));
}
-static inline struct hstate *page_hstate(struct page *page)
-{
- return folio_hstate(page_folio(page));
-}
-
static inline unsigned hstate_index_to_shift(unsigned index)
{
return hstates[index].order + PAGE_SHIFT;
@@ -1062,11 +1057,6 @@ static inline struct hstate *folio_hstate(struct folio *folio)
return NULL;
}
-static inline struct hstate *page_hstate(struct page *page)
-{
- return NULL;
-}
-
static inline struct hstate *size_to_hstate(unsigned long size)
{
return NULL;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index e0028cbb86c09..154cc5b315727 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1812,10 +1812,10 @@ static void free_hpage_workfn(struct work_struct *work)
node = node->next;
page->mapping = NULL;
/*
- * The VM_BUG_ON_PAGE(!PageHuge(page), page) in page_hstate()
- * is going to trigger because a previous call to
+ * The VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio) in
+ * folio_hstate() is going to trigger because a previous call to
* remove_hugetlb_folio() will call folio_set_compound_dtor
- * (folio, NULL_COMPOUND_DTOR), so do not use page_hstate()
+ * (folio, NULL_COMPOUND_DTOR), so do not use folio_hstate()
* directly.
*/
h = size_to_hstate(page_size(page));
diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 6599cc965e216..bcf99ba747a05 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -79,17 +79,17 @@ static struct page *has_unmovable_pages(unsigned long start_pfn, unsigned long e
* handle each tail page individually in migration.
*/
if (PageHuge(page) || PageTransCompound(page)) {
- struct page *head = compound_head(page);
+ struct folio *folio = page_folio(page);
unsigned int skip_pages;
if (PageHuge(page)) {
- if (!hugepage_migration_supported(page_hstate(head)))
+ if (!hugepage_migration_supported(folio_hstate(folio)))
return page;
- } else if (!PageLRU(head) && !__PageMovable(head)) {
+ } else if (!folio_test_lru(folio) && !__folio_test_movable(folio)) {
return page;
}
- skip_pages = compound_nr(head) - (page - head);
+ skip_pages = folio_nr_pages(folio) - folio_page_idx(folio, page);
pfn += skip_pages - 1;
continue;
}
--
2.41.0
next reply other threads:[~2023-07-19 18:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 18:41 Sidhartha Kumar [this message]
2023-07-19 23:02 ` [PATCH v2] mm/hugetlb: get rid of page_hstate() Mike Kravetz
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=20230719184145.301911-1-sidhartha.kumar@oracle.com \
--to=sidhartha.kumar@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=songmuchun@bytedance.com \
--cc=willy@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).