From: Jack Steiner <steiner@sgi.com>

It looks like the call to sched_balance_exec() from do_execve() is in the
wrong spot.  The code calls sched_balance_exec() before determining whether
"filename" actually exists.  

In many cases, users have several entries in $PATH.  If a full path name is
not specified on the 'exec" call, the library code iterates thru the files
in the PATH list until it finds the program.  This can result is numerous
migrations of the parent process before the program is actually found.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/exec.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff -puN fs/exec.c~balance-on-exec-fix fs/exec.c
--- 25/fs/exec.c~balance-on-exec-fix	Tue Jun  1 16:42:51 2004
+++ 25-akpm/fs/exec.c	Tue Jun  1 16:42:51 2004
@@ -1074,14 +1074,14 @@ int do_execve(char * filename,
 	int retval;
 	int i;
 
-	sched_balance_exec();
-
 	file = open_exec(filename);
 
 	retval = PTR_ERR(file);
 	if (IS_ERR(file))
 		return retval;
 
+	sched_balance_exec();
+
 	bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
 	memset(bprm.page, 0, MAX_ARG_PAGES*sizeof(bprm.page[0]));
 
_