]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Revert "mm: support more pagesizes for MAP_HUGETLB/SHM_HUGETLB"
authorStephen Rothwell <sfr@canb.auug.org.au>
Mon, 12 Nov 2012 04:22:51 +0000 (15:22 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 12 Nov 2012 04:22:51 +0000 (15:22 +1100)
This reverts commit e37c64a9751abe43d8dc768126521dc6d77ec35c.

arch/x86/include/asm/mman.h
fs/hugetlbfs/inode.c
include/linux/hugetlb.h
include/linux/shm.h
include/uapi/asm-generic/mman.h
ipc/shm.c
mm/mmap.c

index 513b05f15bb4f8cdeeb42369b18223ad506ded40..593e51d4643f6adb403a756f11408835ce075355 100644 (file)
@@ -3,9 +3,6 @@
 
 #define MAP_32BIT      0x40            /* only give out 32bit addresses */
 
-#define MAP_HUGE_2MB    (21 << MAP_HUGE_SHIFT)
-#define MAP_HUGE_1GB    (30 << MAP_HUGE_SHIFT)
-
 #include <asm-generic/mman.h>
 
 #endif /* _ASM_X86_MMAN_H */
index ea615023cea629bf84f5f55fe0804d732d9c0355..fed1cd5a53936b858510337c101ab2fcc560316c 100644 (file)
@@ -897,7 +897,7 @@ static struct file_system_type hugetlbfs_fs_type = {
        .kill_sb        = kill_litter_super,
 };
 
-static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
+static struct vfsmount *hugetlbfs_vfsmount;
 
 static int can_do_hugetlb_shm(void)
 {
@@ -906,22 +906,9 @@ static int can_do_hugetlb_shm(void)
        return capable(CAP_IPC_LOCK) || in_group_p(shm_group);
 }
 
-static int get_hstate_idx(int page_size_log)
-{
-       struct hstate *h;
-
-       if (!page_size_log)
-               return default_hstate_idx;
-       h = size_to_hstate(1 << page_size_log);
-       if (!h)
-               return -1;
-       return h - hstates;
-}
-
 struct file *hugetlb_file_setup(const char *name, unsigned long addr,
                                size_t size, vm_flags_t acctflag,
-                               struct user_struct **user,
-                               int creat_flags, int page_size_log)
+                               struct user_struct **user, int creat_flags)
 {
        int error = -ENOMEM;
        struct file *file;
@@ -931,14 +918,9 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
        struct qstr quick_string;
        struct hstate *hstate;
        unsigned long num_pages;
-       int hstate_idx;
-
-       hstate_idx = get_hstate_idx(page_size_log);
-       if (hstate_idx < 0)
-               return ERR_PTR(-ENODEV);
 
        *user = NULL;
-       if (!hugetlbfs_vfsmount[hstate_idx])
+       if (!hugetlbfs_vfsmount)
                return ERR_PTR(-ENOENT);
 
        if (creat_flags == HUGETLB_SHMFS_INODE && !can_do_hugetlb_shm()) {
@@ -955,7 +937,7 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
                }
        }
 
-       root = hugetlbfs_vfsmount[hstate_idx]->mnt_root;
+       root = hugetlbfs_vfsmount->mnt_root;
        quick_string.name = name;
        quick_string.len = strlen(quick_string.name);
        quick_string.hash = 0;
@@ -963,7 +945,7 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
        if (!path.dentry)
                goto out_shm_unlock;
 
-       path.mnt = mntget(hugetlbfs_vfsmount[hstate_idx]);
+       path.mnt = mntget(hugetlbfs_vfsmount);
        error = -ENOSPC;
        inode = hugetlbfs_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0);
        if (!inode)
@@ -1003,9 +985,8 @@ out_shm_unlock:
 
 static int __init init_hugetlbfs_fs(void)
 {
-       struct hstate *h;
        int error;
-       int i;
+       struct vfsmount *vfsmount;
 
        error = bdi_init(&hugetlbfs_backing_dev_info);
        if (error)
@@ -1022,27 +1003,14 @@ static int __init init_hugetlbfs_fs(void)
        if (error)
                goto out;
 
-       i = 0;
-       for_each_hstate (h) {
-               char buf[50];
-               unsigned ps_kb = 1U << (h->order + PAGE_SHIFT - 10);
-
-               snprintf(buf, sizeof buf, "pagesize=%uK", ps_kb);
-               hugetlbfs_vfsmount[i] = kern_mount_data(&hugetlbfs_fs_type,
-                                                       buf);
-
-               if (IS_ERR(hugetlbfs_vfsmount[i])) {
-                               pr_err(
-                       "hugetlb: Cannot mount internal hugetlbfs for page size %uK",
-                              ps_kb);
-                       error = PTR_ERR(hugetlbfs_vfsmount[i]);
-                       hugetlbfs_vfsmount[i] = NULL;
-               }
-               i++;
-       }
-       /* Non default hstates are optional */
-       if (!IS_ERR_OR_NULL(hugetlbfs_vfsmount[default_hstate_idx]))
+       vfsmount = kern_mount(&hugetlbfs_fs_type);
+
+       if (!IS_ERR(vfsmount)) {
+               hugetlbfs_vfsmount = vfsmount;
                return 0;
+       }
+
+       error = PTR_ERR(vfsmount);
 
  out:
        kmem_cache_destroy(hugetlbfs_inode_cachep);
@@ -1053,19 +1021,13 @@ static int __init init_hugetlbfs_fs(void)
 
 static void __exit exit_hugetlbfs_fs(void)
 {
-       struct hstate *h;
-       int i;
-
-
        /*
         * Make sure all delayed rcu free inodes are flushed before we
         * destroy cache.
         */
        rcu_barrier();
        kmem_cache_destroy(hugetlbfs_inode_cachep);
-       i = 0;
-       for_each_hstate (h)
-               kern_unmount(hugetlbfs_vfsmount[i++]);
+       kern_unmount(hugetlbfs_vfsmount);
        unregister_filesystem(&hugetlbfs_fs_type);
        bdi_destroy(&hugetlbfs_backing_dev_info);
 }
index 3e7fa1acf09cdebb4f060b17bb293a30a1437206..225164842ab62797216cd13c82c510d6847e13c4 100644 (file)
@@ -183,8 +183,7 @@ extern const struct file_operations hugetlbfs_file_operations;
 extern const struct vm_operations_struct hugetlb_vm_ops;
 struct file *hugetlb_file_setup(const char *name, unsigned long addr,
                                size_t size, vm_flags_t acct,
-                               struct user_struct **user, int creat_flags,
-                               int page_size_log);
+                               struct user_struct **user, int creat_flags);
 
 static inline int is_file_hugepages(struct file *file)
 {
@@ -196,14 +195,12 @@ static inline int is_file_hugepages(struct file *file)
        return 0;
 }
 
-
 #else /* !CONFIG_HUGETLBFS */
 
 #define is_file_hugepages(file)                        0
 static inline struct file *
 hugetlb_file_setup(const char *name, unsigned long addr, size_t size,
-               vm_flags_t acctflag, struct user_struct **user, int creat_flags,
-               int page_size_log)
+               vm_flags_t acctflag, struct user_struct **user, int creat_flags)
 {
        return ERR_PTR(-ENOSYS);
 }
index 7bbab55b0d0970be1ec34cb1e7aa52c2b4eb1123..bcf8a6a3ec00d51b08e113248a0ca62d56f8b542 100644 (file)
@@ -23,31 +23,12 @@ struct shmid_kernel /* private to the kernel */
        struct task_struct      *shm_creator;
 };
 
-#endif
-
 /* shm_mode upper byte flags */
 #define        SHM_DEST        01000   /* segment will be destroyed on last detach */
 #define SHM_LOCKED      02000   /* segment will not be swapped */
 #define SHM_HUGETLB     04000   /* segment will use huge TLB pages */
 #define SHM_NORESERVE   010000  /* don't check for reservations */
 
-/* Bits [26:31] are reserved */
-
-/*
- * When SHM_HUGETLB is set bits [26:31] encode the log2 of the huge page size.
- * This gives us 6 bits, which is enough until someone invents 128 bit address
- * spaces.
- *
- * Assume these are all power of twos.
- * When 0 use the default page size.
- */
-#define SHM_HUGE_SHIFT  26
-#define SHM_HUGE_MASK   0x3f
-#define SHM_HUGE_2MB    (21 << SHM_HUGE_SHIFT)
-#define SHM_HUGE_1GB    (30 << SHM_HUGE_SHIFT)
-
-#ifdef __KERNEL__
-
 #ifdef CONFIG_SYSVIPC
 long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr,
              unsigned long shmlba);
index d2f35d8d68c6122cfe7e5cbb67b878ab4d0c563e..32c8bd6a196dffe0cc2cfd367792754faf88836e 100644 (file)
 #define MAP_STACK      0x20000         /* give out an address that is best suited for process/thread stacks */
 #define MAP_HUGETLB    0x40000         /* create a huge page mapping */
 
-/* Bits [26:31] are reserved */
-
-/*
- * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size.
- * This gives us 6 bits, which is enough until someone invents 128 bit address
- * spaces.
- *
- * Assume these are all power of twos.
- * When 0 use the default page size.
- */
-#define MAP_HUGE_SHIFT  26
-#define MAP_HUGE_MASK   0x3f
-
 #define MCL_CURRENT    1               /* lock all current mappings */
 #define MCL_FUTURE     2               /* lock all future mappings */
 
index 4fa6d8fee730c05e3fe4e4fbb93fa40690ede3bc..dff40c9f73c9df09544c057f7325004726d27715 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -495,8 +495,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
                if (shmflg & SHM_NORESERVE)
                        acctflag = VM_NORESERVE;
                file = hugetlb_file_setup(name, 0, size, acctflag,
-                                 &shp->mlock_user, HUGETLB_SHMFS_INODE,
-                               (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
+                                       &shp->mlock_user, HUGETLB_SHMFS_INODE);
        } else {
                /*
                 * Do not allow no accounting for OVERCOMMIT_NEVER, even
index 0b8f9d83e2e20fe9160eddac84bc459d158d6955..8e6a1a3eea13577c55aad549c776fac840d6008f 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1266,9 +1266,8 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
                 * memory so no accounting is necessary
                 */
                file = hugetlb_file_setup(HUGETLB_ANON_FILE, addr, len,
-                               VM_NORESERVE,
-                               &user, HUGETLB_ANONHUGE_INODE,
-                               (flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
+                                               VM_NORESERVE, &user,
+                                               HUGETLB_ANONHUGE_INODE);
                if (IS_ERR(file))
                        return PTR_ERR(file);
        }