Date: Tue, 2 Dec 2003 17:39:06 -0800 (PST) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 43336 for review Message-ID: <200312030139.hB31d6Pa092212@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=43336 Change 43336 by peter@peter_overcee on 2003/12/02 17:38:17 snarf jhb's mp_maxid.patch Affected files ... .. //depot/projects/hammer/sys/alpha/alpha/mp_machdep.c#9 edit .. //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#46 edit .. //depot/projects/hammer/sys/conf/files#40 edit .. //depot/projects/hammer/sys/i386/i386/mp_machdep.c#23 edit .. //depot/projects/hammer/sys/kern/sched_ule.c#20 edit .. //depot/projects/hammer/sys/kern/subr_smp.c#11 edit .. //depot/projects/hammer/sys/sparc64/sparc64/mp_machdep.c#10 edit .. //depot/projects/hammer/sys/sys/smp.h#4 edit .. //depot/projects/hammer/sys/vm/uma_core.c#19 edit Differences ... ==== //depot/projects/hammer/sys/alpha/alpha/mp_machdep.c#9 (text+ko) ==== @@ -339,7 +339,6 @@ continue; mp_maxid = i; } - mp_maxid++; } int ==== //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#46 (text+ko) ==== @@ -179,8 +179,8 @@ cpu_info[apic_id].cpu_bsp = 1; } mp_ncpus++; - if (apic_id >= mp_maxid) - mp_maxid = apic_id + 1; + if (apic_id > mp_maxid) + mp_maxid = apic_id; if (bootverbose) printf("SMP: Added CPU %d (%s)\n", apic_id, boot_cpu ? "BSP" : "AP"); ==== //depot/projects/hammer/sys/conf/files#40 (text+ko) ==== @@ -1152,7 +1152,7 @@ kern/subr_rman.c standard kern/subr_sbuf.c standard kern/subr_scanf.c standard -kern/subr_smp.c optional smp +kern/subr_smp.c standard kern/subr_taskqueue.c standard kern/subr_trap.c standard kern/subr_turnstile.c standard ==== //depot/projects/hammer/sys/i386/i386/mp_machdep.c#23 (text+ko) ==== @@ -258,7 +258,7 @@ cpu_mp_setmaxid(void) { - mp_maxid = MAXCPU; + mp_maxid = MAXCPU - 1; } int ==== //depot/projects/hammer/sys/kern/sched_ule.c#20 (text+ko) ==== @@ -418,7 +418,7 @@ if (smp_started == 0) goto out; - for (i = 0; i < mp_maxid; i++) { + for (i = 0; i <= mp_maxid; i++) { if (CPU_ABSENT(i) || (i & stopped_cpus) != 0) continue; kseq = KSEQ_CPU(i); ==== //depot/projects/hammer/sys/kern/subr_smp.c#11 (text+ko) ==== @@ -48,10 +48,13 @@ #include <machine/smp.h> +#ifdef SMP volatile u_int stopped_cpus; volatile u_int started_cpus; void (*cpustop_restartfunc)(void); +#endif + int mp_ncpus; volatile int smp_started; @@ -73,6 +76,7 @@ SYSCTL_INT(_kern_smp, OID_AUTO, cpus, CTLFLAG_RD, &smp_cpus, 0, "Number of CPUs online"); +#ifdef SMP /* Enable forwarding of a signal to a process running on a different CPU */ static int forward_signal_enabled = 1; SYSCTL_INT(_kern_smp, OID_AUTO, forward_signal_enabled, CTLFLAG_RW, @@ -331,3 +335,35 @@ /* release lock */ mtx_unlock_spin(&smp_rv_mtx); } +#else /* !SMP */ + +/* + * Provide dummy SMP support for UP kernels. Modules that need to use SMP + * APIs will still work using this dummy support. + */ +static void +mp_setvariables_for_up(void *dummy) +{ + mp_ncpus = 1; + mp_maxid = PCPU_GET(cpuid); + all_cpus = PCPU_GET(cpumask); + KASSERT(PCPU_GET(cpuid) == 0, ("UP must have a CPU ID of zero")); +} +SYSINIT(cpu_mp_setvariables, SI_SUB_TUNABLES, SI_ORDER_FIRST, + mp_setvariables_for_up, NULL) + +void +smp_rendezvous(void (* setup_func)(void *), + void (* action_func)(void *), + void (* teardown_func)(void *), + void *arg) +{ + + if (setup_func != NULL) + setup_func(arg); + if (action_func != NULL) + action_func(arg); + if (teardown_func != NULL) + teardown_func(arg); +} +#endif /* SMP */ ==== //depot/projects/hammer/sys/sparc64/sparc64/mp_machdep.c#10 (text+ko) ==== @@ -159,14 +159,14 @@ strcmp(buf, "cpu") == 0) cpus++; } - mp_maxid = cpus; + mp_maxid = cpus - 1; } int cpu_mp_probe(void) { - return (mp_maxid > 1); + return (mp_maxid > 0); } static void ==== //depot/projects/hammer/sys/sys/smp.h#4 (text+ko) ==== @@ -45,14 +45,16 @@ extern struct cpu_top *smp_topology; extern void (*cpustop_restartfunc)(void); -extern int mp_ncpus; extern int smp_active; -extern volatile int smp_started; extern int smp_cpus; -extern u_int all_cpus; extern volatile u_int started_cpus; extern volatile u_int stopped_cpus; +#endif /* SMP */ + +extern u_int all_cpus; extern u_int mp_maxid; +extern int mp_ncpus; +extern volatile int smp_started; /* * Macro allowing us to determine whether a CPU is absent at any given @@ -61,6 +63,7 @@ */ #define CPU_ABSENT(x_cpu) ((all_cpus & (1 << (x_cpu))) == 0) +#ifdef SMP /* * Machine dependent functions used to initialize MP support. * @@ -78,7 +81,7 @@ * The cpu_setmaxid() function is called very early during the boot process * so that the MD code may set mp_maxid to provide an upper bound on CPU IDs * that other subsystems may use. If a platform is not able to determine - * the exact maximum ID that early, then it may set mp_maxid to MAXCPU. + * the exact maximum ID that early, then it may set mp_maxid to MAXCPU - 1. */ struct thread; @@ -92,13 +95,11 @@ int restart_cpus(u_int); int stop_cpus(u_int); void smp_rendezvous_action(void); +#endif /* SMP */ void smp_rendezvous(void (*)(void *), void (*)(void *), void (*)(void *), void *arg); -#else /* SMP */ -#define CPU_ABSENT(x_cpu) (0) -#endif /* SMP */ #endif /* !LOCORE */ #endif /* _KERNEL */ #endif /* _SYS_SMP_H_ */ ==== //depot/projects/hammer/sys/vm/uma_core.c#19 (text+ko) ==== @@ -127,14 +127,6 @@ static int booted = 0; /* - * Rather than #ifdef SMP all over, just give us a bogus definition for - * this on UP. - */ -#ifndef SMP -static int mp_maxid = 1; -#endif - -/* * This is the handle used to schedule events that need to happen * outside of the allocation fast path. */ @@ -350,7 +342,7 @@ * far out of sync. */ if (!(zone->uz_flags & UMA_ZFLAG_INTERNAL)) { - for (cpu = 0; cpu < mp_maxid; cpu++) { + for (cpu = 0; cpu <= mp_maxid; cpu++) { if (CPU_ABSENT(cpu)) continue; CPU_LOCK(cpu); @@ -577,7 +569,7 @@ /* * We have to lock each cpu cache before locking the zone */ - for (cpu = 0; cpu < mp_maxid; cpu++) { + for (cpu = 0; cpu <= mp_maxid; cpu++) { if (CPU_ABSENT(cpu)) continue; CPU_LOCK(cpu); @@ -609,7 +601,7 @@ LIST_REMOVE(bucket, ub_link); bucket_free(bucket); } - for (cpu = 0; cpu < mp_maxid; cpu++) { + for (cpu = 0; cpu <= mp_maxid; cpu++) { if (CPU_ABSENT(cpu)) continue; CPU_UNLOCK(cpu); @@ -1228,7 +1220,7 @@ /* "manually" Create the initial zone */ args.name = "UMA Zones"; args.size = sizeof(struct uma_zone) + - (sizeof(struct uma_cache) * mp_maxid); + (sizeof(struct uma_cache) * (mp_maxid + 1)); args.ctor = zone_ctor; args.dtor = zone_dtor; args.uminit = zero_init; @@ -1239,7 +1231,7 @@ zone_ctor(zones, sizeof(struct uma_zone), &args); /* Initialize the pcpu cache lock set once and for all */ - for (i = 0; i < mp_maxid; i++) + for (i = 0; i <= mp_maxid; i++) CPU_LOCK_INIT(i); #ifdef UMA_DEBUG printf("Filling boot free list.\n"); @@ -2105,7 +2097,7 @@ printf("Full slabs:\n"); LIST_FOREACH(slab, &zone->uz_full_slab, us_link) slab_print(slab); - for (i = 0; i < mp_maxid; i++) { + for (i = 0; i <= mp_maxid; i++) { if (CPU_ABSENT(i)) continue; cache = &zone->uz_cpu[i]; @@ -2153,7 +2145,7 @@ if (cnt == 0) /* list may have changed size */ break; if (!(z->uz_flags & UMA_ZFLAG_INTERNAL)) { - for (cpu = 0; cpu < mp_maxid; cpu++) { + for (cpu = 0; cpu <= mp_maxid; cpu++) { if (CPU_ABSENT(cpu)) continue; CPU_LOCK(cpu); @@ -2162,7 +2154,7 @@ ZONE_LOCK(z); cachefree = 0; if (!(z->uz_flags & UMA_ZFLAG_INTERNAL)) { - for (cpu = 0; cpu < mp_maxid; cpu++) { + for (cpu = 0; cpu <= mp_maxid; cpu++) { if (CPU_ABSENT(cpu)) continue; cache = &z->uz_cpu[cpu];
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312030139.hB31d6Pa092212>