public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: 2.4.x performance tests Re: [PATCH] BUG() in exec_mmap()
@ 2003-10-13  6:52 Ernie Petrides
  2003-10-13 12:09 ` Andrea Arcangeli
  0 siblings, 1 reply; 3+ messages in thread
From: Ernie Petrides @ 2003-10-13  6:52 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Dave Kleikamp, Marcelo Tosatti, linux-kernel

On Thursday, 9-Oct-2003 at 17:25 -0300, Marcelo Tosatti wrote:

> BTW, further performance testing of the removal of this optimization is
> VERY welcome.
>
> I've done some tests and no big performance harm has showed up, but thats
> just me.


In a variation of a (loosely) 2.4.21-based kernel, I get a 0% degradation
in the speed of a program exec'ing itself 1,000,000 times with the addition
of the missing locking in exec_mmap():

--- linux-2.4.21/fs/exec.c.orig
+++ linux-2.4.21/fs/exec.c
@@ -452,9 +452,11 @@ static int exec_mmap(void)
 
 	old_mm = current->mm;
 	if (old_mm && atomic_read(&old_mm->mm_users) == 1) {
+		down_write(&old_mm->mmap_sem);
 		mm_release();
 		exit_aio(old_mm);
 		exit_mmap(old_mm);
+		up_write(&old_mm->mmap_sem);
 		return 0;
 	}
 

Applying your change to the same kernel, I get a 2.5% degradation in the
same test case:

--- linux-2.4.21/fs/exec.c.orig
+++ linux-2.4.21/fs/exec.c
@@ -451,12 +451,6 @@ static int exec_mmap(void)
 	struct mm_struct * mm, * old_mm;
 
 	old_mm = current->mm;
-	if (old_mm && atomic_read(&old_mm->mm_users) == 1) {
-		mm_release();
-		exit_aio(old_mm);
-		exit_mmap(old_mm);
-		return 0;
-	}
 
 	mm = mm_alloc();
 	if (mm) {


Average times over 3 runs (of 1,000,000 execs each) were:

	base kernel:	529 elapsed seconds
	w/1st change:	529 elapsed seconds
	w/2nd change:	542 elapsed seconds

I wouldn't bother optimizing for an exec() syscall, but the 1st change
also eliminates the possibility of two ENOMEM error paths in the typical
case of not sharing an mm_struct.


Also, a reproducer that could expose the race condition (in typically 5-20
seconds) on a dual-Xeon Dell box ran for 10's of minutes without problems
with either fix.

Cheers.  -ernie

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [PATCH] BUG() in exec_mmap()
@ 2003-10-09 20:19 Marcelo Tosatti
  2003-10-09 20:25 ` 2.4.x performance tests " Marcelo Tosatti
  0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Tosatti @ 2003-10-09 20:19 UTC (permalink / raw)
  To: Dave Kleikamp; +Cc: Marcelo Tosatti, linux-kernel



On Thu, 9 Oct 2003, Dave Kleikamp wrote:

> Marcelo,
> A recent change to exec_mmap() removed the initialization of old_mm,
> leaving an uninitialized use of it.  This patch would completely remove
> old_mm from the function.  Is this what was intended?

Yes. 

Blame me... patch applied, thank you!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-10-13 12:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-13  6:52 2.4.x performance tests Re: [PATCH] BUG() in exec_mmap() Ernie Petrides
2003-10-13 12:09 ` Andrea Arcangeli
  -- strict thread matches above, loose matches on Subject: below --
2003-10-09 20:19 Marcelo Tosatti
2003-10-09 20:25 ` 2.4.x performance tests " Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox