Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 2008, 2009 Cavium Networks, Inc.
0007  */
0008 
0009 #ifndef __ASM_HUGETLB_H
0010 #define __ASM_HUGETLB_H
0011 
0012 #include <asm/page.h>
0013 
0014 #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE
0015 static inline int prepare_hugepage_range(struct file *file,
0016                      unsigned long addr,
0017                      unsigned long len)
0018 {
0019     unsigned long task_size = STACK_TOP;
0020     struct hstate *h = hstate_file(file);
0021 
0022     if (len & ~huge_page_mask(h))
0023         return -EINVAL;
0024     if (addr & ~huge_page_mask(h))
0025         return -EINVAL;
0026     if (len > task_size)
0027         return -ENOMEM;
0028     if (task_size - len < addr)
0029         return -EINVAL;
0030     return 0;
0031 }
0032 
0033 #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
0034 static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
0035                         unsigned long addr, pte_t *ptep)
0036 {
0037     pte_t clear;
0038     pte_t pte = *ptep;
0039 
0040     pte_val(clear) = (unsigned long)invalid_pte_table;
0041     set_pte_at(mm, addr, ptep, clear);
0042     return pte;
0043 }
0044 
0045 #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
0046 static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
0047                       unsigned long addr, pte_t *ptep)
0048 {
0049     pte_t pte;
0050 
0051     /*
0052      * clear the huge pte entry firstly, so that the other smp threads will
0053      * not get old pte entry after finishing flush_tlb_page and before
0054      * setting new huge pte entry
0055      */
0056     pte = huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
0057     flush_tlb_page(vma, addr);
0058     return pte;
0059 }
0060 
0061 #define __HAVE_ARCH_HUGE_PTE_NONE
0062 static inline int huge_pte_none(pte_t pte)
0063 {
0064     unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL;
0065     return !val || (val == (unsigned long)invalid_pte_table);
0066 }
0067 
0068 #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
0069 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
0070                          unsigned long addr,
0071                          pte_t *ptep, pte_t pte,
0072                          int dirty)
0073 {
0074     int changed = !pte_same(*ptep, pte);
0075 
0076     if (changed) {
0077         set_pte_at(vma->vm_mm, addr, ptep, pte);
0078         /*
0079          * There could be some standard sized pages in there,
0080          * get them all.
0081          */
0082         flush_tlb_range(vma, addr, addr + HPAGE_SIZE);
0083     }
0084     return changed;
0085 }
0086 
0087 #include <asm-generic/hugetlb.h>
0088 
0089 #endif /* __ASM_HUGETLB_H */