Unverified Commit f31cd96b authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3674 mm/hugetlb: Introduce alloc_hugetlb_folio_size()

parents f18dd64c f54a918d
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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
+27 −0
Original line number Diff line number Diff line
@@ -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