[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 05/19] mm: hugetlb: Allow alloc_hugetlb_folio() to be paramet
From: |
Ackerley Tng |
Subject: |
[RFC PATCH 05/19] mm: hugetlb: Allow alloc_hugetlb_folio() to be parametrized by subpool and hstate |
Date: |
Tue, 6 Jun 2023 19:03:50 +0000 |
subpool_inode() and hstate_inode() are hugetlbfs-specific.
By allowing subpool and hstate to be specified, hugetlb is further
modularized from hugetlbfs.
Signed-off-by: Ackerley Tng <ackerleytng@google.com>
---
include/linux/hugetlb.h | 3 +++
mm/hugetlb.c | 16 ++++++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 2457d7a21974..14df89d1642c 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -747,6 +747,9 @@ struct huge_bootmem_page {
};
int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list);
+struct folio *alloc_hugetlb_folio_from_subpool(
+ struct hugepage_subpool *spool, struct hstate *h,
+ struct vm_area_struct *vma, unsigned long addr, int avoid_reserve);
struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
unsigned long addr, int avoid_reserve);
struct folio *alloc_hugetlb_folio_nodemask(struct hstate *h, int preferred_nid,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 9da419b930df..99ab4bbdb2ce 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3008,11 +3008,10 @@ int isolate_or_dissolve_huge_page(struct page *page,
struct list_head *list)
return ret;
}
-struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
- unsigned long addr, int avoid_reserve)
+struct folio *alloc_hugetlb_folio_from_subpool(
+ struct hugepage_subpool *spool, struct hstate *h,
+ struct vm_area_struct *vma, unsigned long addr, int avoid_reserve)
{
- struct hugepage_subpool *spool = subpool_vma(vma);
- struct hstate *h = hstate_vma(vma);
struct folio *folio;
long map_chg, map_commit;
long gbl_chg;
@@ -3139,6 +3138,15 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct
*vma,
return ERR_PTR(-ENOSPC);
}
+struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
+ unsigned long addr, int avoid_reserve)
+{
+ struct hugepage_subpool *spool = subpool_vma(vma);
+ struct hstate *h = hstate_vma(vma);
+
+ return alloc_hugetlb_folio_from_subpool(spool, h, vma, addr,
avoid_reserve);
+}
+
int alloc_bootmem_huge_page(struct hstate *h, int nid)
__attribute__ ((weak, alias("__alloc_bootmem_huge_page")));
int __alloc_bootmem_huge_page(struct hstate *h, int nid)
--
2.41.0.rc0.172.g3f132b7071-goog
- [RFC PATCH 00/19] hugetlb support for KVM guest_mem, Ackerley Tng, 2023/06/06
- [RFC PATCH 01/19] mm: hugetlb: Expose get_hstate_idx(), Ackerley Tng, 2023/06/06
- [RFC PATCH 03/19] mm: hugetlb: Expose remove_inode_hugepages, Ackerley Tng, 2023/06/06
- [RFC PATCH 02/19] mm: hugetlb: Move and expose hugetlbfs_zero_partial_page, Ackerley Tng, 2023/06/06
- [RFC PATCH 04/19] mm: hugetlb: Decouple hstate, subpool from inode, Ackerley Tng, 2023/06/06
- [RFC PATCH 05/19] mm: hugetlb: Allow alloc_hugetlb_folio() to be parametrized by subpool and hstate,
Ackerley Tng <=
- [RFC PATCH 06/19] mm: hugetlb: Provide hugetlb_filemap_add_folio(), Ackerley Tng, 2023/06/06
- [RFC PATCH 08/19] mm: hugetlb: Refactor restore_reserve_on_error, Ackerley Tng, 2023/06/06
- [RFC PATCH 07/19] mm: hugetlb: Refactor vma_*_reservation functions, Ackerley Tng, 2023/06/06
- [RFC PATCH 09/19] mm: hugetlb: Use restore_reserve_on_error directly in filesystems, Ackerley Tng, 2023/06/06
- [RFC PATCH 10/19] mm: hugetlb: Parametrize alloc_hugetlb_folio_from_subpool() by resv_map, Ackerley Tng, 2023/06/06
- [RFC PATCH 11/19] mm: hugetlb: Parametrize hugetlb functions by resv_map, Ackerley Tng, 2023/06/06
- [RFC PATCH 12/19] mm: truncate: Expose preparation steps for truncate_inode_pages_final, Ackerley Tng, 2023/06/06
- [RFC PATCH 13/19] KVM: guest_mem: Refactor kvm_gmem fd creation to be in layers, Ackerley Tng, 2023/06/06
- [RFC PATCH 14/19] KVM: guest_mem: Refactor cleanup to separate inode and file cleanup, Ackerley Tng, 2023/06/06
- [RFC PATCH 15/19] KVM: guest_mem: hugetlb: initialization and cleanup, Ackerley Tng, 2023/06/06