Chuck Ebbert 14525ab
From: Roland McGrath <roland@redhat.com>
Chuck Ebbert 14525ab
Date: Wed, 8 Sep 2010 02:36:28 +0000 (-0700)
Chuck Ebbert 14525ab
Subject: execve: improve interactivity with large arguments
Chuck Ebbert 14525ab
X-Git-Tag: v2.6.36-rc4~13
Chuck Ebbert 14525ab
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=7993bc1f4663c0db67bb8f0d98e6678145b387cd
Chuck Ebbert 14525ab
Chuck Ebbert 14525ab
execve: improve interactivity with large arguments
Chuck Ebbert 14525ab
Chuck Ebbert 14525ab
This adds a preemption point during the copying of the argument and
Chuck Ebbert 14525ab
environment strings for execve, in copy_strings().  There is already
Chuck Ebbert 14525ab
a preemption point in the count() loop, so this doesn't add any new
Chuck Ebbert 14525ab
points in the abstract sense.
Chuck Ebbert 14525ab
Chuck Ebbert 14525ab
When the total argument+environment strings are very large, the time
Chuck Ebbert 14525ab
spent copying them can be much more than a normal user time slice.
Chuck Ebbert 14525ab
So this change improves the interactivity of the rest of the system
Chuck Ebbert 14525ab
when one process is doing an execve with very large arguments.
Chuck Ebbert 14525ab
Chuck Ebbert 14525ab
Signed-off-by: Roland McGrath <roland@redhat.com>
Chuck Ebbert 14525ab
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Chuck Ebbert 14525ab
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Chuck Ebbert 14525ab
---
Chuck Ebbert 14525ab
Chuck Ebbert 14525ab
diff --git a/fs/exec.c b/fs/exec.c
Chuck Ebbert 14525ab
index 1b63237..6f2d777 100644
Chuck Ebbert 14525ab
--- a/fs/exec.c
Chuck Ebbert 14525ab
+++ b/fs/exec.c
Chuck Ebbert 14525ab
@@ -419,6 +419,8 @@ static int copy_strings(int argc, const char __user *const __user *argv,
Chuck Ebbert 14525ab
 		while (len > 0) {
Chuck Ebbert 14525ab
 			int offset, bytes_to_copy;
Chuck Ebbert 14525ab
 
Chuck Ebbert 14525ab
+			cond_resched();
Chuck Ebbert 14525ab
+
Chuck Ebbert 14525ab
 			offset = pos % PAGE_SIZE;
Chuck Ebbert 14525ab
 			if (offset == 0)
Chuck Ebbert 14525ab
 				offset = PAGE_SIZE;