Module Name: src Committed By: pooka Date: Fri Jan 15 19:01:04 UTC 2010
Modified Files: src/sys/rump/librump/rumpkern: Makefile.rumpkern emul.c memalloc.c rump.c Removed Files: src/sys/rump/librump/rumpkern: percpu.c Log Message: Use subr_percpu.c instead of homegrown implementation. ...except when using malloc(3)-relegated allocators (happens in production e.g. on Linux), since subr_percpu.c uses vmem and i don't want to reimplement vmem. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/rump/librump/rumpkern/Makefile.rumpkern cvs rdiff -u -r1.118 -r1.119 src/sys/rump/librump/rumpkern/emul.c cvs rdiff -u -r1.4 -r1.5 src/sys/rump/librump/rumpkern/memalloc.c cvs rdiff -u -r1.6 -r0 src/sys/rump/librump/rumpkern/percpu.c cvs rdiff -u -r1.149 -r1.150 src/sys/rump/librump/rumpkern/rump.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/librump/rumpkern/Makefile.rumpkern diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.70 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.71 --- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.70 Wed Dec 16 21:25:55 2009 +++ src/sys/rump/librump/rumpkern/Makefile.rumpkern Fri Jan 15 19:01:04 2010 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpkern,v 1.70 2009/12/16 21:25:55 pooka Exp $ +# $NetBSD: Makefile.rumpkern,v 1.71 2010/01/15 19:01:04 pooka Exp $ # .include "${RUMPTOP}/Makefile.rump" @@ -16,8 +16,8 @@ # Source modules, first the ones specifically implemented for librump. # SRCS= rump.c rumpcopy.c emul.c intr.c locks.c ltsleep.c \ - memalloc.c percpu.c scheduler.c sleepq.c \ - sysproxy_socket.c threads.c vm.c + memalloc.c scheduler.c sleepq.c sysproxy_socket.c \ + threads.c vm.c vers.c: ${RUMPTOP}/../conf/newvers.sh ${RUMPTOP}/../conf/osrelease.sh ${_MKMSG_CREATE} vers.c @@ -69,7 +69,7 @@ # corner cases as well (not to mention if you want to debug the # allocators themselves). #CPPFLAGS+= -DRUMP_USE_UNREAL_ALLOCATORS -SRCS+= subr_kmem.c subr_pool.c subr_vmem.c +SRCS+= subr_kmem.c subr_percpu.c subr_pool.c subr_vmem.c # no shlib_version because this is automatically in sync with lib/librump SHLIB_MAJOR= 0 Index: src/sys/rump/librump/rumpkern/emul.c diff -u src/sys/rump/librump/rumpkern/emul.c:1.118 src/sys/rump/librump/rumpkern/emul.c:1.119 --- src/sys/rump/librump/rumpkern/emul.c:1.118 Wed Jan 13 01:53:38 2010 +++ src/sys/rump/librump/rumpkern/emul.c Fri Jan 15 19:01:04 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: emul.c,v 1.118 2010/01/13 01:53:38 pooka Exp $ */ +/* $NetBSD: emul.c,v 1.119 2010/01/15 19:01:04 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.118 2010/01/13 01:53:38 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.119 2010/01/15 19:01:04 pooka Exp $"); #include <sys/param.h> #include <sys/null.h> @@ -384,11 +384,22 @@ } void (*delay_func)(unsigned int) = rump_delay; +bool +kpreempt(uintptr_t where) +{ + + return false; +} + +/* + * There is no kernel thread preemption in rump currently. But call + * the implementing macros anyway in case they grow some side-effects + * down the road. + */ void kpreempt_disable(void) { - /* XXX: see below */ KPREEMPT_DISABLE(curlwp); } @@ -396,8 +407,7 @@ kpreempt_enable(void) { - /* try to make sure kpreempt_disable() is only used from panic() */ - panic("kpreempt not supported"); + KPREEMPT_ENABLE(curlwp); } void Index: src/sys/rump/librump/rumpkern/memalloc.c diff -u src/sys/rump/librump/rumpkern/memalloc.c:1.4 src/sys/rump/librump/rumpkern/memalloc.c:1.5 --- src/sys/rump/librump/rumpkern/memalloc.c:1.4 Mon Jan 11 19:19:57 2010 +++ src/sys/rump/librump/rumpkern/memalloc.c Fri Jan 15 19:01:04 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: memalloc.c,v 1.4 2010/01/11 19:19:57 stacktic Exp $ */ +/* $NetBSD: memalloc.c,v 1.5 2010/01/15 19:01:04 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,16 +26,19 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.4 2010/01/11 19:19:57 stacktic Exp $"); +__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.5 2010/01/15 19:01:04 pooka Exp $"); #include <sys/param.h> #include <sys/kmem.h> #include <sys/malloc.h> +#include <sys/percpu.h> #include <sys/pool.h> #include <sys/vmem.h> #include <rump/rumpuser.h> +#include "rump_private.h" + /* * Allocator "implementations" which relegate tasks to the host * libc malloc. @@ -325,4 +328,62 @@ return; } + +/* + * A simplified percpu is included in here since subr_percpu.c uses + * the vmem allocator and I don't want to reimplement vmem. So use + * this simplified percpu for non-vmem systems. + */ + +static kmutex_t pcmtx; + +void +percpu_init(void) +{ + + mutex_init(&pcmtx, MUTEX_DEFAULT, IPL_NONE); +} + +void +percpu_init_cpu(struct cpu_info *ci) +{ + + /* nada */ +} + +void * +percpu_getref(percpu_t *pc) +{ + + mutex_enter(&pcmtx); + return pc; +} + +void +percpu_putref(percpu_t *pc) +{ + + mutex_exit(&pcmtx); +} + +percpu_t * +percpu_alloc(size_t size) +{ + + return kmem_alloc(size, KM_SLEEP); +} + +void +percpu_free(percpu_t *pc, size_t size) +{ + + kmem_free(pc, size); +} + +void +percpu_foreach(percpu_t *pc, percpu_callback_t cb, void *arg) +{ + + cb(pc, arg, rump_cpu); +} #endif /* RUMP_USE_UNREAL_ALLOCATORS */ Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.149 src/sys/rump/librump/rumpkern/rump.c:1.150 --- src/sys/rump/librump/rumpkern/rump.c:1.149 Wed Jan 13 00:07:40 2010 +++ src/sys/rump/librump/rumpkern/rump.c Fri Jan 15 19:01:04 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.149 2010/01/13 00:07:40 pooka Exp $ */ +/* $NetBSD: rump.c,v 1.150 2010/01/15 19:01:04 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.149 2010/01/13 00:07:40 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.150 2010/01/15 19:01:04 pooka Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -270,6 +270,8 @@ rumpuser_set_curlwp(NULL); rump_schedule(); + percpu_init(); + /* we are mostly go. do per-cpu subsystem init */ for (i = 0; i < ncpu; i++) { struct cpu_info *ci = cpu_lookup(i); @@ -279,13 +281,13 @@ xc_init_cpu(ci); pool_cache_cpu_init(ci); selsysinit(ci); + percpu_init_cpu(ci); } sysctl_init(); kqueue_init(); iostat_init(); uid_init(); - percpu_init(); fd_sys_init(); module_init(); devsw_init();