summaryrefslogtreecommitdiffstats
path: root/sys/kern/imgact_shell.c
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2010-07-25 17:43:38 +0000
committeralc <alc@FreeBSD.org>2010-07-25 17:43:38 +0000
commit02c0473d357065296a2fb75f673b0a548ad70b89 (patch)
tree84bc9e509fd3ee94e50dcb0812a33b82c1b67b87 /sys/kern/imgact_shell.c
parent68b26f66494feb7f028f26e91a6756e69b2ba395 (diff)
downloadFreeBSD-src-02c0473d357065296a2fb75f673b0a548ad70b89.zip
FreeBSD-src-02c0473d357065296a2fb75f673b0a548ad70b89.tar.gz
Change the order in which the file name, arguments, environment, and
shell command are stored in exec*()'s demand-paged string buffer. For a "buildworld" on an 8GB amd64 multiprocessor, the new order reduces the number of global TLB shootdowns by 31%. It also eliminates about 330k page faults on the kernel address space. Change exec_shell_imgact() to use "args->begin_argv" consistently as the start of the argument and environment strings. Previously, it would sometimes use "args->buf", which is the start of the overall buffer, but no longer the start of the argument and environment strings. While I'm here, eliminate unnecessary passing of "&length" to copystr(), where we don't actually care about the length of the copied string. Clean up the initialization of the exec map. In particular, use the correct size for an entry, and express that size in the same way that is used when an entry is allocated. The old size was one page too large. (This discrepancy originated in 2004 when I rewrote exec_map_first_page() to use sf_buf_alloc() instead of the exec map for mapping the first page of the executable.) Reviewed by: kib
Diffstat (limited to 'sys/kern/imgact_shell.c')
-rw-r--r--sys/kern/imgact_shell.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/kern/imgact_shell.c b/sys/kern/imgact_shell.c
index e0248a7..5eb3065 100644
--- a/sys/kern/imgact_shell.c
+++ b/sys/kern/imgact_shell.c
@@ -220,13 +220,13 @@ exec_shell_imgact(imgp)
* the interpreter name and options-string.
*/
length = interpe - interpb;
- bcopy(interpb, imgp->args->buf, length);
- *(imgp->args->buf + length) = '\0';
+ bcopy(interpb, imgp->args->begin_argv, length);
+ *(imgp->args->begin_argv + length) = '\0';
offset = length + 1;
if (opte > optb) {
length = opte - optb;
- bcopy(optb, imgp->args->buf + offset, length);
- *(imgp->args->buf + offset + length) = '\0';
+ bcopy(optb, imgp->args->begin_argv + offset, length);
+ *(imgp->args->begin_argv + offset + length) = '\0';
offset += length + 1;
imgp->args->argc++;
}
@@ -236,12 +236,12 @@ exec_shell_imgact(imgp)
* use and copy the interpreter's name to imgp->interpreter_name
* for exec to use.
*/
- error = copystr(fname, imgp->args->buf + offset, imgp->args->stringspace,
- &length);
+ error = copystr(fname, imgp->args->begin_argv + offset,
+ imgp->args->stringspace, NULL);
if (error == 0)
error = copystr(imgp->args->begin_argv, imgp->interpreter_name,
- MAXSHELLCMDLEN, &length);
+ MAXSHELLCMDLEN, NULL);
if (sname != NULL)
sbuf_delete(sname);
OpenPOWER on IntegriCloud