From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org, songmuchun@bytedance.com,
punit.agrawal@bytedance.com, muchun.song@linux.dev,
mike.kravetz@oracle.com, fam.zheng@bytedance.com,
usama.arif@bytedance.com, akpm@linux-foundation.org
Subject: + hugetlb_vmemmap-use-folio-argument-for-hugetlb_vmemmap_-functions.patch added to mm-unstable branch
Date: Mon, 09 Oct 2023 16:30:57 -0700 [thread overview]
Message-ID: <20231009233111.A1380C433C8@smtp.kernel.org> (raw)
The patch titled
Subject: hugetlb_vmemmap: use folio argument for hugetlb_vmemmap_* functions
has been added to the -mm mm-unstable branch. Its filename is
hugetlb_vmemmap-use-folio-argument-for-hugetlb_vmemmap_-functions.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/hugetlb_vmemmap-use-folio-argument-for-hugetlb_vmemmap_-functions.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: Usama Arif <usama.arif@bytedance.com>
Subject: hugetlb_vmemmap: use folio argument for hugetlb_vmemmap_* functions
Date: Mon, 9 Oct 2023 16:18:30 +0100
Most function calls in hugetlb.c are made with folio arguments. This
brings hugetlb_vmemmap calls inline with them by using folio instead of
head struct page. Head struct page is still needed within these
functions.
The set/clear/test functions for hugepages are also changed to
folio versions.
Link: https://lkml.kernel.org/r/20231009151830.2248885-2-usama.arif@bytedance.com
Signed-off-by: Usama Arif <usama.arif@bytedance.com>
Cc: Fam Zheng <fam.zheng@bytedance.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Punit Agrawal <punit.agrawal@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/hugetlb.c | 10 ++++-----
mm/hugetlb_vmemmap.c | 42 +++++++++++++++++++++--------------------
mm/hugetlb_vmemmap.h | 8 +++----
3 files changed, 31 insertions(+), 29 deletions(-)
--- a/mm/hugetlb.c~hugetlb_vmemmap-use-folio-argument-for-hugetlb_vmemmap_-functions
+++ a/mm/hugetlb.c
@@ -1606,7 +1606,7 @@ static void __update_and_free_hugetlb_fo
* is no longer identified as a hugetlb page. hugetlb_vmemmap_restore
* can only be passed hugetlb pages and will BUG otherwise.
*/
- if (clear_dtor && hugetlb_vmemmap_restore(h, &folio->page)) {
+ if (clear_dtor && hugetlb_vmemmap_restore(h, folio)) {
spin_lock_irq(&hugetlb_lock);
/*
* If we cannot allocate vmemmap pages, just refuse to free the
@@ -1749,7 +1749,7 @@ static void bulk_vmemmap_restore_error(s
* quit processing the list to retry the bulk operation.
*/
list_for_each_entry_safe(folio, t_folio, folio_list, lru)
- if (hugetlb_vmemmap_restore(h, &folio->page)) {
+ if (hugetlb_vmemmap_restore(h, folio)) {
list_del(&folio->lru);
spin_lock_irq(&hugetlb_lock);
add_hugetlb_folio(h, folio, true);
@@ -1907,7 +1907,7 @@ static void init_new_hugetlb_folio(struc
static void __prep_new_hugetlb_folio(struct hstate *h, struct folio *folio)
{
init_new_hugetlb_folio(h, folio);
- hugetlb_vmemmap_optimize(h, &folio->page);
+ hugetlb_vmemmap_optimize(h, folio);
}
static void prep_new_hugetlb_folio(struct hstate *h, struct folio *folio, int nid)
@@ -2312,7 +2312,7 @@ retry:
* Attempt to allocate vmemmmap here so that we can take
* appropriate action on failure.
*/
- rc = hugetlb_vmemmap_restore(h, &folio->page);
+ rc = hugetlb_vmemmap_restore(h, folio);
if (!rc) {
update_and_free_hugetlb_folio(h, folio, false);
} else {
@@ -3720,7 +3720,7 @@ static int demote_free_hugetlb_folio(str
* passed hugetlb folios and will BUG otherwise.
*/
if (folio_test_hugetlb(folio)) {
- rc = hugetlb_vmemmap_restore(h, &folio->page);
+ rc = hugetlb_vmemmap_restore(h, folio);
if (rc) {
/* Allocation of vmemmmap failed, we can not demote folio */
spin_lock_irq(&hugetlb_lock);
--- a/mm/hugetlb_vmemmap.c~hugetlb_vmemmap-use-folio-argument-for-hugetlb_vmemmap_-functions
+++ a/mm/hugetlb_vmemmap.c
@@ -495,14 +495,15 @@ EXPORT_SYMBOL(hugetlb_optimize_vmemmap_k
static bool vmemmap_optimize_enabled = IS_ENABLED(CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON);
core_param(hugetlb_free_vmemmap, vmemmap_optimize_enabled, bool, 0);
-static int __hugetlb_vmemmap_restore(const struct hstate *h, struct page *head, unsigned long flags)
+static int __hugetlb_vmemmap_restore(const struct hstate *h, struct folio *folio, unsigned long flags)
{
int ret;
+ struct page *head = &folio->page;
unsigned long vmemmap_start = (unsigned long)head, vmemmap_end;
unsigned long vmemmap_reuse;
VM_WARN_ON_ONCE(!PageHuge(head));
- if (!HPageVmemmapOptimized(head))
+ if (!folio_test_hugetlb_vmemmap_optimized(folio))
return 0;
vmemmap_end = vmemmap_start + hugetlb_vmemmap_size(h);
@@ -518,7 +519,7 @@ static int __hugetlb_vmemmap_restore(con
*/
ret = vmemmap_remap_alloc(vmemmap_start, vmemmap_end, vmemmap_reuse, flags);
if (!ret) {
- ClearHPageVmemmapOptimized(head);
+ folio_clear_hugetlb_vmemmap_optimized(folio);
static_branch_dec(&hugetlb_optimize_vmemmap_key);
}
@@ -530,14 +531,14 @@ static int __hugetlb_vmemmap_restore(con
* hugetlb_vmemmap_optimize()) vmemmap pages which
* will be reallocated and remapped.
* @h: struct hstate.
- * @head: the head page whose vmemmap pages will be restored.
+ * @folio: the folio whose vmemmap pages will be restored.
*
- * Return: %0 if @head's vmemmap pages have been reallocated and remapped,
+ * Return: %0 if @folio's vmemmap pages have been reallocated and remapped,
* negative error code otherwise.
*/
-int hugetlb_vmemmap_restore(const struct hstate *h, struct page *head)
+int hugetlb_vmemmap_restore(const struct hstate *h, struct folio *folio)
{
- return __hugetlb_vmemmap_restore(h, head, 0);
+ return __hugetlb_vmemmap_restore(h, folio, 0);
}
/**
@@ -563,7 +564,7 @@ long hugetlb_vmemmap_restore_folios(cons
list_for_each_entry_safe(folio, t_folio, folio_list, lru) {
if (folio_test_hugetlb_vmemmap_optimized(folio)) {
- ret = __hugetlb_vmemmap_restore(h, &folio->page,
+ ret = __hugetlb_vmemmap_restore(h, folio,
VMEMMAP_REMAP_NO_TLB_FLUSH);
if (ret)
break;
@@ -641,11 +642,12 @@ static bool vmemmap_should_optimize(cons
}
static int __hugetlb_vmemmap_optimize(const struct hstate *h,
- struct page *head,
+ struct folio *folio,
struct list_head *vmemmap_pages,
unsigned long flags)
{
int ret = 0;
+ struct page *head = &folio->page;
unsigned long vmemmap_start = (unsigned long)head, vmemmap_end;
unsigned long vmemmap_reuse;
@@ -665,7 +667,7 @@ static int __hugetlb_vmemmap_optimize(co
* If there is an error during optimization, we will immediately FLUSH
* the TLB and clear the flag below.
*/
- SetHPageVmemmapOptimized(head);
+ folio_set_hugetlb_vmemmap_optimized(folio);
vmemmap_end = vmemmap_start + hugetlb_vmemmap_size(h);
vmemmap_reuse = vmemmap_start;
@@ -681,27 +683,27 @@ static int __hugetlb_vmemmap_optimize(co
vmemmap_pages, flags);
if (ret) {
static_branch_dec(&hugetlb_optimize_vmemmap_key);
- ClearHPageVmemmapOptimized(head);
+ folio_clear_hugetlb_vmemmap_optimized(folio);
}
return ret;
}
/**
- * hugetlb_vmemmap_optimize - optimize @head page's vmemmap pages.
+ * hugetlb_vmemmap_optimize - optimize @folio's vmemmap pages.
* @h: struct hstate.
- * @head: the head page whose vmemmap pages will be optimized.
+ * @folio: the folio whose vmemmap pages will be optimized.
*
- * This function only tries to optimize @head's vmemmap pages and does not
+ * This function only tries to optimize @folio's vmemmap pages and does not
* guarantee that the optimization will succeed after it returns. The caller
- * can use HPageVmemmapOptimized(@head) to detect if @head's vmemmap pages
- * have been optimized.
+ * can use folio_test_hugetlb_vmemmap_optimized(@folio) to detect if @folio's
+ * vmemmap pages have been optimized.
*/
-void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head)
+void hugetlb_vmemmap_optimize(const struct hstate *h, struct folio *folio)
{
LIST_HEAD(vmemmap_pages);
- __hugetlb_vmemmap_optimize(h, head, &vmemmap_pages, 0);
+ __hugetlb_vmemmap_optimize(h, folio, &vmemmap_pages, 0);
free_vmemmap_page_list(&vmemmap_pages);
}
@@ -745,7 +747,7 @@ void hugetlb_vmemmap_optimize_folios(str
flush_tlb_all();
list_for_each_entry(folio, folio_list, lru) {
- int ret = __hugetlb_vmemmap_optimize(h, &folio->page,
+ int ret = __hugetlb_vmemmap_optimize(h, folio,
&vmemmap_pages,
VMEMMAP_REMAP_NO_TLB_FLUSH);
@@ -761,7 +763,7 @@ void hugetlb_vmemmap_optimize_folios(str
flush_tlb_all();
free_vmemmap_page_list(&vmemmap_pages);
INIT_LIST_HEAD(&vmemmap_pages);
- __hugetlb_vmemmap_optimize(h, &folio->page,
+ __hugetlb_vmemmap_optimize(h, folio,
&vmemmap_pages,
VMEMMAP_REMAP_NO_TLB_FLUSH);
}
--- a/mm/hugetlb_vmemmap.h~hugetlb_vmemmap-use-folio-argument-for-hugetlb_vmemmap_-functions
+++ a/mm/hugetlb_vmemmap.h
@@ -18,11 +18,11 @@
#define HUGETLB_VMEMMAP_RESERVE_PAGES (HUGETLB_VMEMMAP_RESERVE_SIZE / sizeof(struct page))
#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
-int hugetlb_vmemmap_restore(const struct hstate *h, struct page *head);
+int hugetlb_vmemmap_restore(const struct hstate *h, struct folio *folio);
long hugetlb_vmemmap_restore_folios(const struct hstate *h,
struct list_head *folio_list,
struct list_head *non_hvo_folios);
-void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head);
+void hugetlb_vmemmap_optimize(const struct hstate *h, struct folio *folio);
void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_list);
static inline unsigned int hugetlb_vmemmap_size(const struct hstate *h)
@@ -43,7 +43,7 @@ static inline unsigned int hugetlb_vmemm
return size > 0 ? size : 0;
}
#else
-static inline int hugetlb_vmemmap_restore(const struct hstate *h, struct page *head)
+static inline int hugetlb_vmemmap_restore(const struct hstate *h, struct folio *folio)
{
return 0;
}
@@ -56,7 +56,7 @@ static long hugetlb_vmemmap_restore_foli
return 0;
}
-static inline void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head)
+static inline void hugetlb_vmemmap_optimize(const struct hstate *h, struct folio *folio)
{
}
_
Patches currently in -mm which might be from usama.arif@bytedance.com are
hugetlb_vmemmap-use-folio-argument-for-hugetlb_vmemmap_-functions.patch
next reply other threads:[~2023-10-09 23:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 23:30 Andrew Morton [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-10-11 17:53 + hugetlb_vmemmap-use-folio-argument-for-hugetlb_vmemmap_-functions.patch added to mm-unstable branch Andrew Morton
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=20231009233111.A1380C433C8@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=fam.zheng@bytedance.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=mm-commits@vger.kernel.org \
--cc=muchun.song@linux.dev \
--cc=punit.agrawal@bytedance.com \
--cc=songmuchun@bytedance.com \
--cc=usama.arif@bytedance.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.