Skip to contentSkip to conversation

dup_mmap tiny optimization

PATCH New Luca Barbieri 1 participant 1 message Nov 18, 2002

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

kernel/fork.c renamed from kernel/fork.c~ +3 -2
@@ -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;
 }