Commit 6aaac55f authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

[PATCH] dup_mmap() double memory accounting

dup_mmap() unnecessarily tries to account for memory of the vma's it has
created if it fails in the middle.

However, that's pointless (and wrong), since the exit_mmap() path called
through mmput() will do so anyway in the failure path.

Just remove the bogus un-accounting code.
parent 754d4c9b
...@@ -271,7 +271,6 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm) ...@@ -271,7 +271,6 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
struct vm_area_struct * mpnt, *tmp, **pprev; struct vm_area_struct * mpnt, *tmp, **pprev;
struct rb_node **rb_link, *rb_parent; struct rb_node **rb_link, *rb_parent;
int retval; int retval;
unsigned long charge = 0;
struct mempolicy *pol; struct mempolicy *pol;
down_write(&oldmm->mmap_sem); down_write(&oldmm->mmap_sem);
...@@ -308,7 +307,6 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm) ...@@ -308,7 +307,6 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT; unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
if (security_vm_enough_memory(len)) if (security_vm_enough_memory(len))
goto fail_nomem; goto fail_nomem;
charge += len;
} }
tmp = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); tmp = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
if (!tmp) if (!tmp)
...@@ -360,7 +358,7 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm) ...@@ -360,7 +358,7 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
tmp->vm_ops->open(tmp); tmp->vm_ops->open(tmp);
if (retval) if (retval)
goto fail; goto out;
} }
retval = 0; retval = 0;
...@@ -372,8 +370,6 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm) ...@@ -372,8 +370,6 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
kmem_cache_free(vm_area_cachep, tmp); kmem_cache_free(vm_area_cachep, tmp);
fail_nomem: fail_nomem:
retval = -ENOMEM; retval = -ENOMEM;
fail:
vm_unacct_memory(charge);
goto out; goto out;
} }
static inline int mm_alloc_pgd(struct mm_struct * mm) static inline int mm_alloc_pgd(struct mm_struct * mm)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment