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