* 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: 2.4.x performance tests Re: [PATCH] BUG() in exec_mmap()
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
0 siblings, 0 replies; 3+ messages in thread
From: Andrea Arcangeli @ 2003-10-13 12:09 UTC (permalink / raw)
To: Ernie Petrides
Cc: Marcelo Tosatti, Dave Kleikamp, Marcelo Tosatti, linux-kernel
On Mon, Oct 13, 2003 at 02:52:44AM -0400, Ernie Petrides wrote:
> --- 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;
> }
Is there any special reason you take it around mm_release and exit_aio
too? I don't feel this is needed. exit_aio btw still assumes nobody can
race, so it doesn't take any spinlock (brlocks actually) to guard
against other aio threads, I believe that's ok since as worse the other
tasks can mangle the vm with ptrace, they'll never get to mess with aio,
only the current task can and the mm_user == 1 check guarantees we've no
sibiling threads. the mmap_sem shouldn't help exit_aio anyways, if
something it'll make it deadlock if there's any access to the VM that
generates a page fault in the cancel() callback.
So I suggest this sequence should be safe:
mm_release();
exit_aio(old_mm);
down_write(&old_mm->mmap_sem);
exit_mmap(old_mm);
up_write(&old_mm->mmap_sem);
Please double check ;)
Andrea - If you prefer relying on open source software, check these links:
rsync.kernel.org::pub/scm/linux/kernel/bkcvs/linux-2.[45]/
http://www.cobite.com/cvsps/
^ 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
* 2.4.x performance tests Re: [PATCH] BUG() in exec_mmap()
2003-10-09 20:19 Marcelo Tosatti
@ 2003-10-09 20:25 ` Marcelo Tosatti
0 siblings, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2003-10-09 20:25 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Dave Kleikamp, Marcelo Tosatti, linux-kernel
On Thu, 9 Oct 2003, Marcelo Tosatti wrote:
>
>
> 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!
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.
^ 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