ascend inclusion category: Feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8SC4J
---------------------------------------------
This could allocate hugepage from hpool of specific size. The driver would map those hugepage for some special processes via hugetlb_insert_hugepage_pte().
Signed-off-by: Wang Wensheng wangwensheng4@huawei.com --- include/linux/hugetlb.h | 14 ++++++++++++++ mm/hugetlb.c | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 57c2630cb80d..1883751673b8 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -302,6 +302,15 @@ static inline int hugetlb_insert_hugepage_pte_by_pa(struct mm_struct *mm, } #endif /* CONFIG_HUGETLB_INSERT_PAGE */
+#ifdef CONFIG_ASCEND_FEATURES +struct folio *alloc_hugetlb_folio_size(int nid, unsigned long size); +#else +static inline struct folio *alloc_hugetlb_folio_size(int nid, unsigned long size) +{ + return NULL; +} +#endif + #else /* !CONFIG_HUGETLB_PAGE */
static inline void hugetlb_dup_vma_private(struct vm_area_struct *vma) @@ -523,6 +532,11 @@ static inline int hugetlb_insert_hugepage_pte_by_pa(struct mm_struct *mm, return -EPERM; }
+static inline struct folio *alloc_hugetlb_folio_size(int nid, unsigned long size) +{ + return NULL; +} + #endif /* !CONFIG_HUGETLB_PAGE */ /* * hugepages at page global directory. If arch support diff --git a/mm/hugetlb.c b/mm/hugetlb.c index adffb0ce1e6e..d996a63ebf50 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7633,3 +7633,30 @@ int hugetlb_insert_hugepage_pte_by_pa(struct mm_struct *mm, unsigned long addr, } EXPORT_SYMBOL_GPL(hugetlb_insert_hugepage_pte_by_pa); #endif /* CONFIG_HUGETLB_INSERT_PAGE */ + +#ifdef CONFIG_ASCEND_FEATURES +struct folio *alloc_hugetlb_folio_size(int nid, unsigned long size) +{ + gfp_t gfp_mask; + struct hstate *h; + nodemask_t nodemask; + unsigned long flags; + struct folio *folio = NULL; + + nodes_clear(nodemask); + node_set(nid, nodemask); + + h = size_to_hstate(size); + if (!h) + return NULL; + + gfp_mask = htlb_alloc_mask(h); + spin_lock_irqsave(&hugetlb_lock, flags); + if (h->free_huge_pages - h->resv_huge_pages > 0) + folio = dequeue_hugetlb_folio_nodemask(h, gfp_mask, nid, &nodemask); + spin_unlock_irqrestore(&hugetlb_lock, flags); + + return folio; +} +EXPORT_SYMBOL(alloc_hugetlb_folio_size); +#endif
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/3674 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/D...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/3674 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/D...