tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Deadlock on fragmented memory?
> Date: Thu, 19 Oct 2017 14:49:24 +0000
> From: Taylor R Campbell <campbell+netbsd-tech-kern%mumble.net@localhost>
>
> Attached is a patch that attempts to restore the original behaviour of
> carving out enough KVA on boot, by setting the exec_pool low-water
> mark to be the same as the hard limit.
On reflection, this patch has the downside of always reserving 4 MB of
RAM up front, which the original exec_map approach did not. Attached
is another patch that reintroduces exec_map (but in MI code, not a
copy of it in all MD code) and pool-allocates from that, without a
low-water mark. Compile-tested only so far.
Index: sys/kern/kern_exec.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_exec.c,v
retrieving revision 1.446
diff -p -u -r1.446 kern_exec.c
--- sys/kern/kern_exec.c 29 Sep 2017 17:47:29 -0000 1.446
+++ sys/kern/kern_exec.c 19 Oct 2017 15:02:24 -0000
@@ -280,11 +280,14 @@ struct spawn_exec_data {
volatile uint32_t sed_refcnt;
};
+static struct vm_map *exec_map;
+static struct pool exec_pool;
+
static void *
exec_pool_alloc(struct pool *pp, int flags)
{
- return (void *)uvm_km_alloc(kernel_map, NCARGS, 0,
+ return (void *)uvm_km_alloc(exec_map, NCARGS, 0,
UVM_KMF_PAGEABLE | UVM_KMF_WAITVA);
}
@@ -292,11 +295,9 @@ static void
exec_pool_free(struct pool *pp, void *addr)
{
- uvm_km_free(kernel_map, (vaddr_t)addr, NCARGS, UVM_KMF_PAGEABLE);
+ uvm_km_free(exec_map, (vaddr_t)addr, NCARGS, UVM_KMF_PAGEABLE);
}
-static struct pool exec_pool;
-
static struct pool_allocator exec_palloc = {
.pa_alloc = exec_pool_alloc,
.pa_free = exec_pool_free,
@@ -1820,8 +1821,12 @@ exec_init(int init_boot)
if (init_boot) {
/* do one-time initializations */
+ vaddr_t vmin, vmax;
+
rw_init(&exec_lock);
mutex_init(&sigobject_lock, MUTEX_DEFAULT, IPL_NONE);
+ exec_map = uvm_km_suballoc(kernel_map, &vmin, &vmax,
+ maxexec*NCARGS, VM_MAP_PAGEABLE, false, NULL);
pool_init(&exec_pool, NCARGS, 0, 0, PR_NOALIGN|PR_NOTOUCH,
"execargs", &exec_palloc, IPL_NONE);
pool_sethardlimit(&exec_pool, maxexec, "should not happen", 0);
Home |
Main Index |
Thread Index |
Old Index