[RFC,01/19] mm: hugetlb: Expose get_hstate_idx()
Commit Message
Expose get_hstate_idx() so it can be used from KVM's guest_mem code
Signed-off-by: Ackerley Tng <ackerleytng@google.com>
---
fs/hugetlbfs/inode.c | 9 ---------
include/linux/hugetlb.h | 14 ++++++++++++++
2 files changed, 14 insertions(+), 9 deletions(-)
@@ -1560,15 +1560,6 @@ static int can_do_hugetlb_shm(void)
return capable(CAP_IPC_LOCK) || in_group_p(shm_group);
}
-static int get_hstate_idx(int page_size_log)
-{
- struct hstate *h = hstate_sizelog(page_size_log);
-
- if (!h)
- return -1;
- return hstate_index(h);
-}
-
/*
* Note that size should be aligned to proper hugepage size in caller side,
* otherwise hugetlb_reserve_pages reserves one less hugepages than intended.
@@ -876,6 +876,15 @@ static inline int hstate_index(struct hstate *h)
return h - hstates;
}
+static inline int get_hstate_idx(int page_size_log)
+{
+ struct hstate *h = hstate_sizelog(page_size_log);
+
+ if (!h)
+ return -1;
+ return hstate_index(h);
+}
+
extern int dissolve_free_huge_page(struct page *page);
extern int dissolve_free_huge_pages(unsigned long start_pfn,
unsigned long end_pfn);
@@ -1142,6 +1151,11 @@ static inline int hstate_index(struct hstate *h)
return 0;
}
+static inline int get_hstate_idx(int page_size_log)
+{
+ return 0;
+}
+
static inline int dissolve_free_huge_page(struct page *page)
{
return 0;