On Mon, Apr 18, 2011 at 03:47:27PM -0600, Artur Grabowski wrote: > A repeat of an earlier diff. > > Change stack and exec arguments allocation from old allocators to km_alloc(9). > > //art > > > Index: kern/kern_exec.c > =================================================================== > RCS file: /cvs/src/sys/kern/kern_exec.c,v > retrieving revision 1.117 > diff -u -r1.117 kern_exec.c > --- kern/kern_exec.c 4 Apr 2011 13:00:13 -0000 1.117 > +++ kern/kern_exec.c 18 Apr 2011 19:37:08 -0000 > @@ -227,6 +227,11 @@ > return (error); > } > > +struct kmem_va_mode kv_exec = { > + .kv_map = &exec_map, > + .kv_wait = 1 > +}; > + > /* > * exec system call > */ > @@ -312,7 +317,7 @@ > /* XXX -- THE FOLLOWING SECTION NEEDS MAJOR CLEANUP */ > > /* allocate an argument buffer */ > - argp = (char *) uvm_km_valloc_wait(exec_map, NCARGS); > + argp = km_alloc(NCARGS, &kv_exec, &kp_pageable, &kd_waitok); > #ifdef DIAGNOSTIC > if (argp == NULL) > panic("execve: argp == NULL"); > @@ -592,7 +597,7 @@ > splx(s); > } > > - uvm_km_free_wakeup(exec_map, (vaddr_t) argp, NCARGS); > + km_free(argp, NCARGS, &kv_exec, &kp_pageable); > > pool_put(&namei_pool, nid.ni_cnd.cn_pnbuf); > vn_close(pack.ep_vp, FREAD, cred, p); > @@ -689,7 +694,7 @@ > /* close and put the exec'd file */ > vn_close(pack.ep_vp, FREAD, cred, p); > pool_put(&namei_pool, nid.ni_cnd.cn_pnbuf); > - uvm_km_free_wakeup(exec_map, (vaddr_t) argp, NCARGS); > + km_free(argp, NCARGS, &kv_exec, &kp_pageable); > > freehdr: > free(pack.ep_hdr, M_EXEC); > @@ -717,7 +722,7 @@ > free(pack.ep_emul_arg, M_TEMP); > pool_put(&namei_pool, nid.ni_cnd.cn_pnbuf); > vn_close(pack.ep_vp, FREAD, cred, p); > - uvm_km_free_wakeup(exec_map, (vaddr_t) argp, NCARGS); > + km_free(argp, NCARGS, &kv_exec, &kp_pageable); > > free_pack_abort: > free(pack.ep_hdr, M_EXEC); > Index: kern/kern_fork.c > =================================================================== > RCS file: /cvs/src/sys/kern/kern_fork.c,v > retrieving revision 1.125 > diff -u -r1.125 kern_fork.c > --- kern/kern_fork.c 3 Apr 2011 14:56:28 -0000 1.125 > +++ kern/kern_fork.c 18 Apr 2011 19:37:08 -0000 > @@ -195,6 +195,11 @@ > /* print the 'table full' message once per 10 seconds */ > struct timeval fork_tfmrate = { 10, 0 }; > > +struct kmem_va_mode kv_fork = { > + .kv_map = &kernel_map, > + .kv_align = USPACE_ALIGN > +}; > + > int > fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, > void (*func)(void *), void *arg, register_t *retval, > @@ -204,7 +209,7 @@ > uid_t uid; > struct vmspace *vm; > int count; > - vaddr_t uaddr; > + struct user *uaddr; > int s; > extern void endtsleep(void *); > extern void realitexpire(void *); > @@ -251,10 +256,7 @@ > return (EAGAIN); > } > > - uaddr = uvm_km_kmemalloc_pla(kernel_map, uvm.kernel_object, USPACE, > - USPACE_ALIGN, UVM_KMF_ZERO, > - dma_constraint.ucr_low, dma_constraint.ucr_high, > - 0, 0, USPACE/PAGE_SIZE); > + uaddr = km_alloc(USPACE, &kv_fork, &kp_dma_zero, &kd_waitok); > if (uaddr == 0) {
As ariane said, this should be checking null (km_alloc returns void * and uaddr is pointer) > chgproccnt(uid, -1); > nprocs--; > Index: kern/sys_pipe.c > =================================================================== > RCS file: /cvs/src/sys/kern/sys_pipe.c,v > retrieving revision 1.58 > diff -u -r1.58 sys_pipe.c > --- kern/sys_pipe.c 14 Jan 2010 23:12:11 -0000 1.58 > +++ kern/sys_pipe.c 18 Apr 2011 19:37:08 -0000 > @@ -168,9 +168,9 @@ > int > pipespace(struct pipe *cpipe, u_int size) > { > - caddr_t buffer; > + void *buffer; > > - buffer = (caddr_t)uvm_km_valloc(kernel_map, size); > + buffer = km_alloc(size, &kv_any, &kp_pageable, &kd_waitok); > if (buffer == NULL) { > return (ENOMEM); > } > @@ -714,8 +714,8 @@ > if (cpipe->pipe_buffer.size > PIPE_SIZE) > --nbigpipe; > amountpipekva -= cpipe->pipe_buffer.size; > - uvm_km_free(kernel_map, (vaddr_t)cpipe->pipe_buffer.buffer, > - cpipe->pipe_buffer.size); > + km_free(cpipe->pipe_buffer.buffer, cpipe->pipe_buffer.size, > + &kv_any, &kp_pageable); > cpipe->pipe_buffer.buffer = NULL; > } > } > Index: uvm/uvm_glue.c > =================================================================== > RCS file: /cvs/src/sys/uvm/uvm_glue.c,v > retrieving revision 1.58 > diff -u -r1.58 uvm_glue.c > --- uvm/uvm_glue.c 15 Apr 2011 21:47:24 -0000 1.58 > +++ uvm/uvm_glue.c 18 Apr 2011 19:37:09 -0000 > @@ -361,9 +361,11 @@ > void > uvm_exit(struct proc *p) > { > + extern struct kmem_va_mode kv_fork; > + > uvmspace_free(p->p_vmspace); > p->p_vmspace = NULL; > - uvm_km_free(kernel_map, (vaddr_t)p->p_addr, USPACE); > + km_free(p->p_addr, USPACE, &kv_fork, &kp_dma); > p->p_addr = NULL; > } > Otherwise, if you fix that then ok. -- Of all the animals, the boy is the most unmanageable. -- Plato