Export a few SMP related symbols in UP kernels as well. This is needed to

aid other kernel code, especially code which can be in a module such as
the acpi_cpu(4) driver, to work properly with both SMP and UP kernels.
The exported symbols include mp_ncpus, all_cpus, mp_maxid, smp_started, and
the smp_rendezvous() function.  This also means that CPU_ABSENT() is now
always implemented the same on all kernels.

Approved by:	re (scottl)
This commit is contained in:
John Baldwin 2003-12-03 14:55:31 +00:00
parent 019446db3a
commit 45c1c90f6a
3 changed files with 44 additions and 7 deletions

View File

@ -1152,7 +1152,7 @@ kern/subr_prof.c standard
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

View File

@ -48,10 +48,13 @@ __FBSDID("$FreeBSD$");
#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 @@ int smp_cpus = 1; /* how many cpu's running */
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 @@ smp_rendezvous(void (* setup_func)(void *),
/* 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 */

View File

@ -45,14 +45,16 @@ struct cpu_top {
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 @@ extern u_int mp_maxid;
*/
#define CPU_ABSENT(x_cpu) ((all_cpus & (1 << (x_cpu))) == 0)
#ifdef SMP
/*
* Machine dependent functions used to initialize MP support.
*
@ -92,13 +95,11 @@ void forward_roundrobin(void);
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_ */