qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 11/19] mm: hugetlb: Parametrize hugetlb functions by resv_map


From: Ackerley Tng
Subject: [RFC PATCH 11/19] mm: hugetlb: Parametrize hugetlb functions by resv_map
Date: Tue, 6 Jun 2023 19:03:56 +0000

Parametrize remove_mapping_hugepages() and hugetlb_unreserve_pages()
by resv_map to remove the use of inode_resv_map() and decouple hugetlb
with hugetlbfs.

Signed-off-by: Ackerley Tng <ackerleytng@google.com>
---
 fs/hugetlbfs/inode.c    | 16 ++++++++++------
 include/linux/hugetlb.h |  6 ++++--
 mm/hugetlb.c            |  4 ++--
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 53f6a421499d..a7791b1390a6 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -560,8 +560,8 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t 
start, pgoff_t end,
  */
 static bool remove_mapping_single_folio(
        struct address_space *mapping, struct folio *folio, pgoff_t index,
-       struct hstate *h, struct hugepage_subpool *spool, struct inode *inode,
-       bool truncate_op)
+       struct hstate *h, struct hugepage_subpool *spool, struct resv_map 
*resv_map,
+       struct inode *inode, bool truncate_op)
 {
        bool ret = false;
 
@@ -586,7 +586,8 @@ static bool remove_mapping_single_folio(
        hugetlb_delete_from_page_cache(folio);
        ret = true;
        if (!truncate_op) {
-               if (unlikely(hugetlb_unreserve_pages(h, spool, inode, index, 
index + 1, 1)))
+               if (unlikely(hugetlb_unreserve_pages(h, spool, resv_map,
+                                                    inode, index, index + 1, 
1)))
                        hugetlb_fix_reserve_counts(h, spool);
        }
 
@@ -623,6 +624,7 @@ static bool remove_mapping_single_folio(
  */
 void remove_mapping_hugepages(struct address_space *mapping,
                              struct hstate *h, struct hugepage_subpool *spool,
+                             struct resv_map *resv_map,
                              struct inode *inode, loff_t lstart, loff_t lend)
 {
        const pgoff_t start = lstart >> huge_page_shift(h);
@@ -647,7 +649,7 @@ void remove_mapping_hugepages(struct address_space *mapping,
                         * Remove folio that was part of folio_batch.
                         */
                        if (remove_mapping_single_folio(mapping, folio, index,
-                                                       h, spool, inode, 
truncate_op))
+                                                       h, spool, resv_map, 
inode, truncate_op))
                                freed++;
 
                        mutex_unlock(&hugetlb_fault_mutex_table[hash]);
@@ -657,7 +659,8 @@ void remove_mapping_hugepages(struct address_space *mapping,
        }
 
        if (truncate_op)
-               (void)hugetlb_unreserve_pages(h, spool, inode, start, LONG_MAX, 
freed);
+               (void)hugetlb_unreserve_pages(h, spool, resv_map, inode,
+                                             start, LONG_MAX, freed);
 }
 
 void remove_inode_hugepages(struct inode *inode, loff_t lstart, loff_t lend)
@@ -665,8 +668,9 @@ void remove_inode_hugepages(struct inode *inode, loff_t 
lstart, loff_t lend)
        struct address_space *mapping = &inode->i_data;
        struct hstate *h = hstate_inode(inode);
        struct hugepage_subpool *spool = subpool_inode(inode);
+       struct resv_map *resv_map = inode_resv_map(inode);
 
-       return remove_mapping_hugepages(mapping, h, spool, inode, lstart, lend);
+       return remove_mapping_hugepages(mapping, h, spool, resv_map, inode, 
lstart, lend);
 }
 
 static void hugetlbfs_evict_inode(struct inode *inode)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index d564802ace4b..af04588a5afe 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -172,7 +172,8 @@ bool hugetlb_reserve_pages(struct hstate *h, struct 
hugepage_subpool *spool,
                           struct vm_area_struct *vma,
                           vm_flags_t vm_flags);
 long hugetlb_unreserve_pages(struct hstate *h, struct hugepage_subpool *spool,
-                            struct inode *inode, long start, long end, long 
freed);
+                            struct resv_map *resv_map, struct inode *inode,
+                            long start, long end, long freed);
 bool 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,
@@ -263,6 +264,7 @@ void hugetlb_zero_partial_page(struct hstate *h, struct 
address_space *mapping,
 
 void remove_mapping_hugepages(struct address_space *mapping,
                              struct hstate *h, struct hugepage_subpool *spool,
+                             struct resv_map *resv_map,
                              struct inode *inode, loff_t lstart, loff_t lend);
 void remove_inode_hugepages(struct inode *inode, loff_t lstart, loff_t lend);
 
@@ -479,7 +481,7 @@ static inline void hugetlb_zero_partial_page(
 
 static inline void remove_mapping_hugepages(
        struct address_space *mapping, struct hstate *h, struct 
hugepage_subpool *spool,
-       struct inode *inode, loff_t lstart, loff_t lend) {}
+       struct resv_map *resv_map, struct inode *inode, loff_t lstart, loff_t 
lend) {}
 static inline void remove_inode_hugepages(struct inode *inode, loff_t lstart, 
loff_t lend) {}
 
 #endif /* !CONFIG_HUGETLB_PAGE */
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index aebdd8c63439..a1cbda457aa7 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -6954,9 +6954,9 @@ bool hugetlb_reserve_pages(struct hstate *h, struct 
hugepage_subpool *spool,
  * Returns 0 on success.
  */
 long hugetlb_unreserve_pages(struct hstate *h, struct hugepage_subpool *spool,
-                            struct inode *inode, long start, long end, long 
freed)
+                            struct resv_map *resv_map, struct inode *inode,
+                            long start, long end, long freed)
 {
-       struct resv_map *resv_map = inode_resv_map(inode);
        long chg = 0;
        long gbl_reserve;
 
-- 
2.41.0.rc0.172.g3f132b7071-goog




reply via email to

[Prev in Thread] Current Thread [Next in Thread]