[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 06/19] mm: hugetlb: Provide hugetlb_filemap_add_folio()
From: |
Ackerley Tng |
Subject: |
[RFC PATCH 06/19] mm: hugetlb: Provide hugetlb_filemap_add_folio() |
Date: |
Tue, 6 Jun 2023 19:03:51 +0000 |
hstate_inode() is hugetlbfs-specific, limiting
hugetlb_add_to_page_cache() to hugetlbfs.
hugetlb_filemap_add_folio() allows hstate to be specified and further
separates hugetlb from hugetlbfs.
Signed-off-by: Ackerley Tng <ackerleytng@google.com>
---
include/linux/hugetlb.h | 2 ++
mm/hugetlb.c | 13 ++++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 14df89d1642c..7d49048c5a2a 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -756,6 +756,8 @@ struct folio *alloc_hugetlb_folio_nodemask(struct hstate
*h, int preferred_nid,
nodemask_t *nmask, gfp_t gfp_mask);
struct folio *alloc_hugetlb_folio_vma(struct hstate *h, struct vm_area_struct
*vma,
unsigned long address);
+int hugetlb_filemap_add_folio(struct address_space *mapping, struct hstate *h,
+ struct folio *folio, pgoff_t idx);
int hugetlb_add_to_page_cache(struct folio *folio, struct address_space
*mapping,
pgoff_t idx);
void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 99ab4bbdb2ce..d16c6417b90f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5665,11 +5665,10 @@ static bool hugetlbfs_pagecache_present(struct hstate
*h,
return present;
}
-int hugetlb_add_to_page_cache(struct folio *folio, struct address_space
*mapping,
- pgoff_t idx)
+int hugetlb_filemap_add_folio(struct address_space *mapping, struct hstate *h,
+ struct folio *folio, pgoff_t idx)
{
struct inode *inode = mapping->host;
- struct hstate *h = hstate_inode(inode);
int err;
__folio_set_locked(folio);
@@ -5693,6 +5692,14 @@ int hugetlb_add_to_page_cache(struct folio *folio,
struct address_space *mapping
return 0;
}
+int hugetlb_add_to_page_cache(struct folio *folio, struct address_space
*mapping,
+ pgoff_t idx)
+{
+ struct hstate *h = hstate_inode(mapping->host);
+
+ return hugetlb_filemap_add_folio(mapping, h, folio, idx);
+}
+
static inline vm_fault_t hugetlb_handle_userfault(struct vm_area_struct *vma,
struct address_space *mapping,
pgoff_t idx,
--
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, 2023/06/06
- [RFC PATCH 06/19] mm: hugetlb: Provide hugetlb_filemap_add_folio(),
Ackerley Tng <=
- [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
- [RFC PATCH 16/19] KVM: guest_mem: hugetlb: allocate and truncate from hugetlb, Ackerley Tng, 2023/06/06