2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2008, 2009 Cavium Networks, Inc.
9 #ifndef __ASM_HUGETLB_H
10 #define __ASM_HUGETLB_H
14 static inline int is_hugepage_only_range(struct mm_struct *mm,
21 #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE
22 static inline int prepare_hugepage_range(struct file *file,
26 unsigned long task_size = STACK_TOP;
27 struct hstate *h = hstate_file(file);
29 if (len & ~huge_page_mask(h))
31 if (addr & ~huge_page_mask(h))
35 if (task_size - len < addr)
40 #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
41 static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
42 unsigned long addr, pte_t *ptep)
47 pte_val(clear) = (unsigned long)invalid_pte_table;
48 set_pte_at(mm, addr, ptep, clear);
52 #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
53 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
54 unsigned long addr, pte_t *ptep)
57 * clear the huge pte entry firstly, so that the other smp threads will
58 * not get old pte entry after finishing flush_tlb_page and before
59 * setting new huge pte entry
61 huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
62 flush_tlb_page(vma, addr);
65 #define __HAVE_ARCH_HUGE_PTE_NONE
66 static inline int huge_pte_none(pte_t pte)
68 unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL;
69 return !val || (val == (unsigned long)invalid_pte_table);
72 #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
73 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
75 pte_t *ptep, pte_t pte,
78 int changed = !pte_same(*ptep, pte);
81 set_pte_at(vma->vm_mm, addr, ptep, pte);
83 * There could be some standard sized pages in there,
86 flush_tlb_range(vma, addr, addr + HPAGE_SIZE);
91 static inline void arch_clear_hugepage_flags(struct page *page)
95 #include <asm-generic/hugetlb.h>
97 #endif /* __ASM_HUGETLB_H */