These functions are introduced in hugetlb.c so the private
hugetlb_lock can be accessed.
These functions will be used in splitting and merging pages in a later
patch.
Signed-off-by: Ackerley Tng <ackerleytng@google.com>
Co-developed-by: Vishal Annapurve <vannapurve@google.com>
Signed-off-by: Vishal Annapurve <vannapurve@google.com>
Change-Id: I42f8feda40cbd28e5fd02e54fa58145d847a220e
---
include/linux/hugetlb.h | 2 ++
mm/hugetlb.c | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index e6b90e72d46d..e432ccfe3e63 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -156,6 +156,8 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to,
vm_flags_t vm_flags);
long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
long freed);
+void hugetlb_folio_list_add(struct folio *folio, struct list_head *list);
+void hugetlb_folio_list_del(struct folio *folio);
bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list);
int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison);
int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 816f257680be..6e326c09c505 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -7473,6 +7473,28 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
return 0;
}
+void hugetlb_folio_list_add(struct folio *folio, struct list_head *list)
+{
+ /*
+ * hstate's hugepage_activelist is guarded by hugetlb_lock, hence hold
+ * hugetlb_lock while modifying folio-> lru.
+ */
+ spin_lock_irq(&hugetlb_lock);
+ list_add(&folio->lru, list);
+ spin_unlock_irq(&hugetlb_lock);
+}
+
+void hugetlb_folio_list_del(struct folio *folio)
+{
+ /*
+ * hstate's hugepage_activelist is guarded by hugetlb_lock, hence hold
+ * hugetlb_lock while modifying folio-> lru.
+ */
+ spin_lock_irq(&hugetlb_lock);
+ list_del(&folio->lru);
+ spin_unlock_irq(&hugetlb_lock);
+}
+
#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING
static unsigned long page_table_shareable(struct vm_area_struct *svma,
struct vm_area_struct *vma,
--
2.49.0.1045.g170613ef41-goog