2002-11-18 16:08:40

by Luca Barbieri

[permalink] [raw]
Subject: [PATCH] dup_mmap tiny optimization

This patch moves retval = -ENOMEM out of the vma loop and after the
fail_nomem label.
The fail label is added and is used when retval is already set.

--- linux-2.5.48_ldb/kernel/fork.c~ 2002-11-18 05:29:22.000000000 +0100
+++ linux-2.5.48_ldb/kernel/fork.c 2002-11-18 17:08:55.000000000 +0100
@@ -238,7 +238,6 @@ static inline int dup_mmap(struct mm_str
for (mpnt = current->mm->mmap ; mpnt ; mpnt = mpnt->vm_next) {
struct file *file;

- retval = -ENOMEM;
if(mpnt->vm_flags & VM_DONTCOPY)
continue;
if (mpnt->vm_flags & VM_ACCOUNT) {
@@ -283,7 +282,7 @@ static inline int dup_mmap(struct mm_str
tmp->vm_ops->open(tmp);

if (retval)
- goto fail_nomem;
+ goto fail;
}
retval = 0;
build_mmap_rb(mm);
@@ -293,6 +292,8 @@ out:
up_write(&oldmm->mmap_sem);
return retval;
fail_nomem:
+ retval = -ENOMEM;
+ fail:
vm_unacct_memory(charge);
goto out;
}


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part