提交 da660018 编写于 作者: Z Zhou Guanghui 提交者: Yang Yingliang

Ascend/memcg: Use CONFIG_ASCEND_FEATURES for customized interfaces

ascend inclusion
category: feature
bugzilla: NA
CVE: NA

-------------------------------------------------------------

The following functions are used only in the ascend scenario:
hugetlb_get_hstate,
hugetlb_alloc_hugepage,
hugetlb_insert_hugepage_pte,
hugetlb_insert_hugepage_pte_by_pa

Remove unused interface hugetlb_insert_hugepage
Signed-off-by: NZhou Guanghui <zhouguanghui1@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 99df82f2
...@@ -375,17 +375,31 @@ struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask, ...@@ -375,17 +375,31 @@ struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask,
int huge_add_to_page_cache(struct page *page, struct address_space *mapping, int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
pgoff_t idx); pgoff_t idx);
#ifdef CONFIG_ARM64 #ifdef CONFIG_ASCEND_FEATURES
const struct hstate *hugetlb_get_hstate(void); const struct hstate *hugetlb_get_hstate(void);
struct page *hugetlb_alloc_hugepage(int nid); struct page *hugetlb_alloc_hugepage(int nid);
int hugetlb_insert_hugepage_pte(struct mm_struct *mm, unsigned long addr, int hugetlb_insert_hugepage_pte(struct mm_struct *mm, unsigned long addr,
pgprot_t prot, struct page *hpage); pgprot_t prot, struct page *hpage);
#endif
int hugetlb_insert_hugepage_pte_by_pa(struct mm_struct *mm, int hugetlb_insert_hugepage_pte_by_pa(struct mm_struct *mm,
unsigned long vir_addr, unsigned long vir_addr,
pgprot_t prot, unsigned long phy_addr); pgprot_t prot, unsigned long phy_addr);
int hugetlb_insert_hugepage(struct vm_area_struct *vma, unsigned long addr, #else
struct page *hpage, pgprot_t prot); static inline const struct hstate *hugetlb_get_hstate(void)
{
return NULL;
}
static inline struct page *hugetlb_alloc_hugepage(int nid)
{
return NULL;
}
static inline int hugetlb_insert_hugepage_pte(struct mm_struct *mm,
unsigned long addr, pgprot_t prot, struct page *hpage)
{
return -EPERM;
}
#endif
/* arch callback */ /* arch callback */
int __init __alloc_bootmem_huge_page(struct hstate *h); int __init __alloc_bootmem_huge_page(struct hstate *h);
...@@ -637,12 +651,6 @@ static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr ...@@ -637,12 +651,6 @@ static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr
{ {
} }
static inline int hugetlb_insert_hugepage_pte_by_pa(struct mm_struct *mm,
unsigned long vir_addr,
pgprot_t prot, unsigned long phy_addr)
{
return 0;
}
#endif /* CONFIG_HUGETLB_PAGE */ #endif /* CONFIG_HUGETLB_PAGE */
static inline spinlock_t *huge_pte_lock(struct hstate *h, static inline spinlock_t *huge_pte_lock(struct hstate *h,
...@@ -655,6 +663,15 @@ static inline spinlock_t *huge_pte_lock(struct hstate *h, ...@@ -655,6 +663,15 @@ static inline spinlock_t *huge_pte_lock(struct hstate *h,
return ptl; return ptl;
} }
#ifndef CONFIG_ASCEND_FEATURES
static inline int hugetlb_insert_hugepage_pte_by_pa(struct mm_struct *mm,
unsigned long vir_addr,
pgprot_t prot, unsigned long phy_addr)
{
return -EPERM;
}
#endif
#ifdef CONFIG_ASCEND_SHARE_POOL #ifdef CONFIG_ASCEND_SHARE_POOL
pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, int writable); pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, int writable);
#endif #endif
......
...@@ -5234,7 +5234,7 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason) ...@@ -5234,7 +5234,7 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason)
} }
} }
#ifdef CONFIG_ARM64 #ifdef CONFIG_ASCEND_FEATURES
const struct hstate *hugetlb_get_hstate(void) const struct hstate *hugetlb_get_hstate(void)
{ {
return &default_hstate; return &default_hstate;
...@@ -5335,41 +5335,6 @@ int hugetlb_insert_hugepage_pte_by_pa(struct mm_struct *mm, ...@@ -5335,41 +5335,6 @@ int hugetlb_insert_hugepage_pte_by_pa(struct mm_struct *mm,
} }
EXPORT_SYMBOL_GPL(hugetlb_insert_hugepage_pte_by_pa); EXPORT_SYMBOL_GPL(hugetlb_insert_hugepage_pte_by_pa);
int hugetlb_insert_hugepage(struct vm_area_struct *vma, unsigned long addr,
struct page *hpage, pgprot_t prot)
{
struct hstate *h = hstate_vma(vma);
int anon_rmap = 0;
spinlock_t *ptl;
pte_t *ptep;
pte_t pte;
struct mm_struct *mm = vma->vm_mm;
ptep = hugetlb_huge_pte_alloc(mm, addr, huge_page_size(h));
if (!ptep)
return -ENXIO;
get_page(hpage);
ptl = huge_pte_lock(h, mm, ptep);
if (anon_rmap) {
ClearPagePrivate(hpage);
hugepage_add_new_anon_rmap(hpage, vma, addr);
} else {
page_dup_rmap(hpage, true);
}
pte = make_huge_pte(vma, hpage, ((vma->vm_flags & VM_WRITE)
&& (vma->vm_flags & VM_SHARED)));
set_huge_pte_at(mm, addr, ptep, pte);
hugetlb_count_add(pages_per_huge_page(h), mm);
spin_unlock(ptl);
return 0;
}
#ifdef CONFIG_ASCEND_CHARGE_MIGRATE_HUGEPAGES #ifdef CONFIG_ASCEND_CHARGE_MIGRATE_HUGEPAGES
static int __init ascend_enable_charge_migrate_hugepages(char *s) static int __init ascend_enable_charge_migrate_hugepages(char *s)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册