x86: stop nmi softlockup warnings in show_mem()
[platform/adaptation/renesas_rcar/renesas_kernel.git] / ipc / shm.c
index 242c3f6..5fc5cf5 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -224,17 +224,16 @@ static void shm_close(struct vm_area_struct *vma)
        mutex_unlock(&shm_ids(ns).mutex);
 }
 
-static struct page *shm_nopage(struct vm_area_struct *vma,
-                              unsigned long address, int *type)
+static int shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        struct file *file = vma->vm_file;
        struct shm_file_data *sfd = shm_file_data(file);
 
-       return sfd->vm_ops->nopage(vma, address, type);
+       return sfd->vm_ops->fault(vma, vmf);
 }
 
 #ifdef CONFIG_NUMA
-int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
+static int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
 {
        struct file *file = vma->vm_file;
        struct shm_file_data *sfd = shm_file_data(file);
@@ -244,7 +243,8 @@ int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
        return err;
 }
 
-struct mempolicy *shm_get_policy(struct vm_area_struct *vma, unsigned long addr)
+static struct mempolicy *shm_get_policy(struct vm_area_struct *vma,
+                                       unsigned long addr)
 {
        struct file *file = vma->vm_file;
        struct shm_file_data *sfd = shm_file_data(file);
@@ -269,6 +269,9 @@ static int shm_mmap(struct file * file, struct vm_area_struct * vma)
        if (ret != 0)
                return ret;
        sfd->vm_ops = vma->vm_ops;
+#ifdef CONFIG_MMU
+       BUG_ON(!sfd->vm_ops->fault);
+#endif
        vma->vm_ops = &shm_vm_ops;
        shm_open(vma);
 
@@ -327,7 +330,7 @@ static const struct file_operations shm_file_operations = {
 static struct vm_operations_struct shm_vm_ops = {
        .open   = shm_open,     /* callback for a new vm-area open */
        .close  = shm_close,    /* callback for when the vm-area is released */
-       .nopage = shm_nopage,
+       .fault  = shm_fault,
 #if defined(CONFIG_NUMA)
        .set_policy = shm_set_policy,
        .get_policy = shm_get_policy,
@@ -714,7 +717,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
                        struct user_struct * user = current->user;
                        if (!is_file_hugepages(shp->shm_file)) {
                                err = shmem_lock(shp->shm_file, 1, user);
-                               if (!err{
+                               if (!err && !(shp->shm_perm.mode & SHM_LOCKED)){
                                        shp->shm_perm.mode |= SHM_LOCKED;
                                        shp->mlock_user = user;
                                }
@@ -904,7 +907,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
                goto out_unlock;
 
        path.dentry = dget(shp->shm_file->f_path.dentry);
-       path.mnt    = mntget(shp->shm_file->f_path.mnt);
+       path.mnt    = shp->shm_file->f_path.mnt;
        shp->shm_nattch++;
        size = i_size_read(path.dentry->d_inode);
        shm_unlock(shp);
@@ -912,18 +915,16 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
        err = -ENOMEM;
        sfd = kzalloc(sizeof(*sfd), GFP_KERNEL);
        if (!sfd)
-               goto out_put_path;
+               goto out_put_dentry;
 
        err = -ENOMEM;
-       file = get_empty_filp();
+
+       file = alloc_file(path.mnt, path.dentry, f_mode, &shm_file_operations);
        if (!file)
                goto out_free;
 
-       file->f_op = &shm_file_operations;
        file->private_data = sfd;
-       file->f_path = path;
        file->f_mapping = shp->shm_file->f_mapping;
-       file->f_mode = f_mode;
        sfd->id = shp->id;
        sfd->ns = get_ipc_ns(ns);
        sfd->file = shp->shm_file;
@@ -974,9 +975,8 @@ out_unlock:
 
 out_free:
        kfree(sfd);
-out_put_path:
+out_put_dentry:
        dput(path.dentry);
-       mntput(path.mnt);
        goto out_nattch;
 }