Module Name: src Committed By: pooka Date: Tue Jan 4 16:23:36 UTC 2011
Modified Files: src/sys/rump/include/machine: cpu.h src/sys/rump/librump/rumpkern: Makefile.rumpkern rump.c rumpcpu_generic.c Log Message: Add SMP support for all architectures. tested on sparc64 by martin To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/rump/include/machine/cpu.h cvs rdiff -u -r1.104 -r1.105 src/sys/rump/librump/rumpkern/Makefile.rumpkern cvs rdiff -u -r1.214 -r1.215 src/sys/rump/librump/rumpkern/rump.c cvs rdiff -u -r1.2 -r1.3 src/sys/rump/librump/rumpkern/rumpcpu_generic.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/include/machine/cpu.h diff -u src/sys/rump/include/machine/cpu.h:1.13 src/sys/rump/include/machine/cpu.h:1.14 --- src/sys/rump/include/machine/cpu.h:1.13 Thu Dec 2 21:20:39 2010 +++ src/sys/rump/include/machine/cpu.h Tue Jan 4 16:23:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.13 2010/12/02 21:20:39 pooka Exp $ */ +/* $NetBSD: cpu.h,v 1.14 2011/01/04 16:23:35 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -40,6 +40,8 @@ cpuid_t ci_cpuid; struct lwp *ci_curlwp; + struct cpu_info *ci_next; + /* * XXX: horrible workaround for vax lock.h. * I eventually want to nuke rump include/machine, so don't waste @@ -77,7 +79,14 @@ #define curlwp rumpuser_get_curlwp() #define curcpu() (curlwp->l_cpu) -#define cpu_number() 0 /* XXX: not good enuf */ +#define cpu_number() (cpu_index(curcpu)) + +extern struct cpu_info *rumpcpu_info_list; +#define CPU_INFO_ITERATOR int +#define CPU_INFO_FOREACH(_cii_, _ci_) _cii_ = 0, _ci_ = rumpcpu_info_list; \ + _ci_ != NULL; _ci_ = _ci_->ci_next +#define CPU_IS_PRIMARY(_ci_) (_ci_->ci_index == 0) + #endif /* !_LOCORE */ Index: src/sys/rump/librump/rumpkern/Makefile.rumpkern diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.104 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.105 --- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.104 Fri Dec 17 00:53:16 2010 +++ src/sys/rump/librump/rumpkern/Makefile.rumpkern Tue Jan 4 16:23:36 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpkern,v 1.104 2010/12/17 00:53:16 joerg Exp $ +# $NetBSD: Makefile.rumpkern,v 1.105 2011/01/04 16:23:36 pooka Exp $ # .include "${RUMPTOP}/Makefile.rump" @@ -25,12 +25,6 @@ SRCS+= locks.c #SRCS+= locks_up.c -# Does the arch support multiple processors? -.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" -RUMP_SMP= # defined -CPPFLAGS.rump.c+= -DRUMP_SMP -.endif - MKREPRO?=no .if ${MKREPRO} == "yes" @@ -180,20 +174,14 @@ # Some architectures require a little special massage with atomic # compare-and-swap. This is because the kernel version is using -# instructions or routines unavailable to us in userspace. We -# use a very simple CAS routine which (correctly) assumes non-SMP -# and no preemption. If some of these archs later develop MP -# support, switch them to use atomic_cas_generic.c +# instructions or routines unavailable to us in userspace. # .if ${MACHINE_CPU} == "arm" || ${MACHINE_CPU} == "hppa" \ || ${MACHINE_CPU} == "mips" || ${MACHINE_CPU} == "sh3" \ || ${MACHINE_CPU} == "vax" || ${MACHINE_ARCH} == "m68000" CPPFLAGS+= -I${RUMPTOP}/../../common/lib/libc/atomic -.ifdef RUMP_SMP SRCS+= atomic_cas_generic.c -.else -SRCS+= rump_atomic_cas_up.c -.endif +#SRCS+= rump_atomic_cas_up.c .endif .include <bsd.lib.mk> Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.214 src/sys/rump/librump/rumpkern/rump.c:1.215 --- src/sys/rump/librump/rumpkern/rump.c:1.214 Sun Jan 2 12:52:25 2011 +++ src/sys/rump/librump/rumpkern/rump.c Tue Jan 4 16:23:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.214 2011/01/02 12:52:25 pooka Exp $ */ +/* $NetBSD: rump.c,v 1.215 2011/01/04 16:23:36 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.214 2011/01/02 12:52:25 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.215 2011/01/04 16:23:36 pooka Exp $"); #include <sys/systm.h> #define ELFSIZE ARCH_ELFSIZE @@ -255,8 +255,6 @@ if (rumpuser_getenv("RUMP_NCPU", buf, sizeof(buf), &error) == 0) error = 0; - /* non-x86 is missing CPU_INFO_FOREACH() support */ -#ifdef RUMP_SMP if (error == 0) { numcpu = strtoll(buf, NULL, 10); if (numcpu < 1) @@ -264,11 +262,6 @@ } else { numcpu = rumpuser_getnhostcpu(); } -#else - if (error == 0) - printf("NCPU limited to 1 on this machine architecture\n"); - numcpu = 1; -#endif rump_cpus_bootstrap(&numcpu); rumpuser_gettime(&sec, &nsec, &error); Index: src/sys/rump/librump/rumpkern/rumpcpu_generic.c diff -u src/sys/rump/librump/rumpkern/rumpcpu_generic.c:1.2 src/sys/rump/librump/rumpkern/rumpcpu_generic.c:1.3 --- src/sys/rump/librump/rumpkern/rumpcpu_generic.c:1.2 Tue Apr 27 23:30:30 2010 +++ src/sys/rump/librump/rumpkern/rumpcpu_generic.c Tue Jan 4 16:23:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpcpu_generic.c,v 1.2 2010/04/27 23:30:30 pooka Exp $ */ +/* $NetBSD: rumpcpu_generic.c,v 1.3 2011/01/04 16:23:36 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -29,15 +29,22 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rumpcpu_generic.c,v 1.2 2010/04/27 23:30:30 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rumpcpu_generic.c,v 1.3 2011/01/04 16:23:36 pooka Exp $"); #include <sys/param.h> #include "rump_private.h" +struct cpu_info *rumpcpu_info_list; + void rump_cpu_attach(struct cpu_info *ci) { + static int nattached; + + /* XXX: wrong order, but ... */ + ci->ci_next = rumpcpu_info_list; + rumpcpu_info_list = ci; - /* nada */ + ci->ci_index = nattached++; }