summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-02-22 16:08:02 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-02-22 16:08:02 +0000
commit5dd0b2887a84d602f92f9be02ecd79834e0bc6c6 (patch)
treeab3a99c7d21244530be565340776b5d880efc0e4
parent01ec2d57bfa74a2ca535c80eb999cbc165f3d76c (diff)
ELF uses more than 5 vmcmds by default, so grow the default vmcmd set size
to 8. At the same time it seemed like a good idea to avoid to always malloc a new vmcmd array, so put the default sized array into struct exec_vmcmd_set. We might want to make a linked list of vmcmd arrays or exec_vmcmd_sets instead of reallocating them some time in the future, but right now this seems like a waste of time.
-rw-r--r--sys/kern/exec_subr.c29
-rw-r--r--sys/kern/kern_exec.c5
-rw-r--r--sys/sys/exec.h27
3 files changed, 33 insertions, 28 deletions
diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c
index 36b2f4b13ea..cb731604d12 100644
--- a/sys/kern/exec_subr.c
+++ b/sys/kern/exec_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_subr.c,v 1.9 2000/11/06 16:19:52 art Exp $ */
+/* $OpenBSD: exec_subr.c,v 1.10 2001/02/22 16:08:01 art Exp $ */
/* $NetBSD: exec_subr.c,v 1.9 1994/12/04 03:10:42 mycroft Exp $ */
/*
@@ -94,18 +94,17 @@ vmcmdset_extend(evsp)
panic("vmcmdset_extend: not necessary");
#endif
- /* figure out number of entries in new set */
ocnt = evsp->evs_cnt;
- evsp->evs_cnt += ocnt ? ocnt : EXEC_DEFAULT_VMCMD_SETSIZE;
+ KASSERT(ocnt > 0);
+ /* figure out number of entries in new set */
+ evsp->evs_cnt += ocnt;
- /* allocate it */
+ /* reallocate the command set */
nvcp = malloc(evsp->evs_cnt * sizeof(struct exec_vmcmd), M_EXEC,
M_WAITOK);
- /* free the old struct, if there was one, and record the new one */
- if (ocnt) {
- bcopy(evsp->evs_cmds, nvcp, (ocnt * sizeof(struct exec_vmcmd)));
+ bcopy(evsp->evs_cmds, nvcp, (ocnt * sizeof(struct exec_vmcmd)));
+ if (evsp->evs_cmds != evsp->evs_start)
free(evsp->evs_cmds, M_EXEC);
- }
evsp->evs_cmds = nvcp;
}
@@ -116,16 +115,20 @@ kill_vmcmds(evsp)
struct exec_vmcmd *vcp;
int i;
- if (evsp->evs_cnt == 0)
- return;
-
for (i = 0; i < evsp->evs_used; i++) {
vcp = &evsp->evs_cmds[i];
if (vcp->ev_vp != NULLVP)
vrele(vcp->ev_vp);
}
- evsp->evs_used = evsp->evs_cnt = 0;
- free(evsp->evs_cmds, M_EXEC);
+
+ /*
+ * Free old vmcmds and restet the array.
+ */
+ evsp->evs_used = 0;
+ if (evsp->evs_cmds != evsp->evs_start)
+ free(evsp->evs_cmds, M_EXEC);
+ evsp->evs_cmds = evsp->evs_start;
+ evsp->evs_cnt = EXEC_DEFAULT_VMCMD_SETSIZE;
}
/*
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 71c068a9348..3344e664d33 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exec.c,v 1.46 2000/11/16 20:02:16 provos Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.47 2001/02/22 16:08:01 art Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
@@ -269,7 +269,8 @@ sys_execve(p, v, retval)
pack.ep_hdrvalid = 0;
pack.ep_ndp = &nid;
pack.ep_emul_arg = NULL;
- pack.ep_vmcmds.evs_cnt = 0;
+ pack.ep_vmcmds.evs_cnt = EXEC_DEFAULT_VMCMD_SETSIZE;
+ pack.ep_vmcmds.evs_cmds = pack.ep_vmcmds.evs_start;
pack.ep_vmcmds.evs_used = 0;
pack.ep_vap = &attr;
pack.ep_emul = &emul_native;
diff --git a/sys/sys/exec.h b/sys/sys/exec.h
index e2dfda8fcab..a95060bfe41 100644
--- a/sys/sys/exec.h
+++ b/sys/sys/exec.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.h,v 1.8 1999/11/05 01:18:01 mickey Exp $ */
+/* $OpenBSD: exec.h,v 1.9 2001/02/22 16:08:01 art Exp $ */
/* $NetBSD: exec.h,v 1.59 1996/02/09 18:25:09 christos Exp $ */
/*-
@@ -116,15 +116,26 @@ struct execsw {
exec_makecmds_fcn es_check; /* function to check exec format */
};
+struct exec_vmcmd {
+ int (*ev_proc) __P((struct proc *p, struct exec_vmcmd *cmd));
+ /* procedure to run for region of vmspace */
+ u_long ev_len; /* length of the segment to map */
+ u_long ev_addr; /* address in the vmspace to place it at */
+ struct vnode *ev_vp; /* vnode pointer for the file w/the data */
+ u_long ev_offset; /* offset in the file for the data */
+ u_int ev_prot; /* protections for segment */
+};
+
+#define EXEC_DEFAULT_VMCMD_SETSIZE 8 /* # of cmds in set to start */
+
/* exec vmspace-creation command set; see below */
struct exec_vmcmd_set {
u_int evs_cnt;
u_int evs_used;
struct exec_vmcmd *evs_cmds;
+ struct exec_vmcmd evs_start[EXEC_DEFAULT_VMCMD_SETSIZE];
};
-#define EXEC_DEFAULT_VMCMD_SETSIZE 5 /* # of cmds in set to start */
-
struct exec_package {
char *ep_name; /* file's name */
void *ep_hdr; /* file's exec header */
@@ -157,16 +168,6 @@ struct exec_package {
#define EXEC_SKIPARG 0x0008 /* don't copy user-supplied argv[0] */
#define EXEC_DESTR 0x0010 /* destructive ops performed */
-struct exec_vmcmd {
- int (*ev_proc) __P((struct proc *p, struct exec_vmcmd *cmd));
- /* procedure to run for region of vmspace */
- u_long ev_len; /* length of the segment to map */
- u_long ev_addr; /* address in the vmspace to place it at */
- struct vnode *ev_vp; /* vnode pointer for the file w/the data */
- u_long ev_offset; /* offset in the file for the data */
- u_int ev_prot; /* protections for segment */
-};
-
#ifdef _KERNEL
/*
* funtions used either by execve() or the various cpu-dependent execve()