[IA64] Add API for allocating Dynamic TR resource.
[safe/jmp/linux-2.6] / arch / ia64 / mm / hugetlbpage.c
index 8d50671..d3ce8f3 100644 (file)
@@ -8,15 +8,14 @@
  * Feb, 2004: dynamic hugetlb page size via boot parameter
  */
 
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
 #include <linux/pagemap.h>
-#include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/sysctl.h>
+#include <linux/log2.h>
 #include <asm/mman.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
@@ -65,6 +64,11 @@ huge_pte_offset (struct mm_struct *mm, unsigned long addr)
        return pte;
 }
 
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
+{
+       return 0;
+}
+
 #define mk_pte_huge(entry) { pte_val(entry) |= _PAGE_P; }
 
 /*
@@ -142,6 +146,14 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
                return -ENOMEM;
        if (len & ~HPAGE_MASK)
                return -EINVAL;
+
+       /* Handle MAP_FIXED */
+       if (flags & MAP_FIXED) {
+               if (prepare_hugepage_range(addr, len))
+                       return -EINVAL;
+               return addr;
+       }
+
        /* This code assumes that RGN_HPAGE != 0. */
        if ((REGION_NUMBER(addr) != RGN_HPAGE) || (addr & (HPAGE_SIZE - 1)))
                addr = HPAGE_REGION_BASE;
@@ -169,7 +181,7 @@ static int __init hugetlb_setup_sz(char *str)
                tr_pages = 0x15557000UL;
 
        size = memparse(str, &str);
-       if (*str || (size & (size-1)) || !(tr_pages & size) ||
+       if (*str || !is_power_of_2(size) || !(tr_pages & size) ||
                size <= PAGE_SIZE ||
                size >= (1UL << PAGE_SHIFT << MAX_ORDER)) {
                printk(KERN_WARNING "Invalid huge page size specified\n");
@@ -182,6 +194,6 @@ static int __init hugetlb_setup_sz(char *str)
         * override here with new page shift.
         */
        ia64_set_rr(HPAGE_REGION_BASE, hpage_shift << 2);
-       return 1;
+       return 0;
 }
-__setup("hugepagesz=", hugetlb_setup_sz);
+early_param("hugepagesz", hugetlb_setup_sz);