Page MenuHomeFreeBSD

D8921.id23289.diff
No OneTemporary

D8921.id23289.diff

Index: sys/kern/kern_exec.c
===================================================================
--- sys/kern/kern_exec.c
+++ sys/kern/kern_exec.c
@@ -101,6 +101,8 @@
MALLOC_DEFINE(M_PARGS, "proc-args", "Process arguments");
+DPCPU_DEFINE(void *, execargs);
+
int coredump_pack_fileinfo = 1;
SYSCTL_INT(_kern, OID_AUTO, coredump_pack_fileinfo, CTLFLAG_RWTUN,
&coredump_pack_fileinfo, 0,
@@ -1319,12 +1321,21 @@
* Allocate temporary demand-paged, zero-filled memory for the file name,
* argument, and environment strings. Returns zero if the allocation succeeds
* and ENOMEM otherwise.
+ *
+ * VA ranges are cached in a per-CPU pointer when possible to reduce contention
+ * on the kernel map.
*/
int
exec_alloc_args(struct image_args *args)
{
+ void *buf;
- args->buf = (char *)kmap_alloc_wait(exec_map, PATH_MAX + ARG_MAX);
+ buf = (void *)atomic_readandclear_ptr((uintptr_t *)DPCPU_PTR(execargs));
+ if (buf != NULL)
+ args->buf = buf;
+ else
+ args->buf = (char *)kmap_alloc_wait(exec_map,
+ PATH_MAX + ARG_MAX);
return (args->buf != NULL ? 0 : ENOMEM);
}
@@ -1333,8 +1344,10 @@
{
if (args->buf != NULL) {
- kmap_free_wakeup(exec_map, (vm_offset_t)args->buf,
- PATH_MAX + ARG_MAX);
+ if (!atomic_cmpset_ptr((uintptr_t *)DPCPU_PTR(execargs),
+ (uintptr_t)NULL, (uintptr_t)args->buf))
+ kmap_free_wakeup(exec_map, (vm_offset_t)args->buf,
+ PATH_MAX + ARG_MAX);
args->buf = NULL;
}
if (args->fname_buf != NULL) {
Index: sys/vm/vm_init.c
===================================================================
--- sys/vm/vm_init.c
+++ sys/vm/vm_init.c
@@ -91,10 +91,6 @@
long physmem;
-static int exec_map_entries = 16;
-SYSCTL_INT(_vm, OID_AUTO, exec_map_entries, CTLFLAG_RDTUN, &exec_map_entries, 0,
- "Maximum number of simultaneous execs");
-
/*
* System initialization
*/
@@ -174,6 +170,7 @@
long physmem_est;
vm_offset_t minaddr;
vm_offset_t maxaddr;
+ int exec_map_entries;
/*
* Allocate space for system data structures.
@@ -271,8 +268,11 @@
panic("Clean map calculation incorrect");
/*
- * Allocate the pageable submaps.
+ * Allocate the pageable submaps. We may cache a buffer of size
+ * PATH_MAX+ARG_MAX per CPU, so we therefore need to reserve space for
+ * at least ncpu+1 buffers to avoid deadlock.
*/
+ exec_map_entries = mp_ncpus * 2;
exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
exec_map_entries * round_page(PATH_MAX + ARG_MAX), FALSE);
pipe_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, maxpipekva,

File Metadata

Mime Type
text/plain
Expires
Sat, Jul 4, 12:04 PM (1 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34668160
Default Alt Text
D8921.id23289.diff (2 KB)

Event Timeline