[PATCH] dup_mmap tiny optimization

From: Luca Barbieri (ldb@ldb.ods.org)
Date: Mon Nov 18 2002 - 11:15:28 EST


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;
 }



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Nov 23 2002 - 22:00:22 EST