Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/subr_smp.c
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
int smp_disabled = 0; /* has smp been disabled? */ | int smp_disabled = 0; /* has smp been disabled? */ | ||||
SYSCTL_INT(_kern_smp, OID_AUTO, disabled, CTLFLAG_RDTUN|CTLFLAG_CAPRD, | SYSCTL_INT(_kern_smp, OID_AUTO, disabled, CTLFLAG_RDTUN|CTLFLAG_CAPRD, | ||||
&smp_disabled, 0, "SMP has been disabled from the loader"); | &smp_disabled, 0, "SMP has been disabled from the loader"); | ||||
int smp_cpus = 1; /* how many cpu's running */ | int smp_cpus = 1; /* how many cpu's running */ | ||||
SYSCTL_INT(_kern_smp, OID_AUTO, cpus, CTLFLAG_RD|CTLFLAG_CAPRD, &smp_cpus, 0, | SYSCTL_INT(_kern_smp, OID_AUTO, cpus, CTLFLAG_RD|CTLFLAG_CAPRD, &smp_cpus, 0, | ||||
"Number of CPUs online"); | "Number of CPUs online"); | ||||
int smp_threads_per_core = 1; /* how many SMT threads are running per core */ | |||||
SYSCTL_INT(_kern_smp, OID_AUTO, threads_per_core, CTLFLAG_RD|CTLFLAG_CAPRD, | |||||
&smp_threads_per_core, 0, "Number of SMT threads online per core"); | |||||
int mp_ncores = -1; /* how many physical cores running */ | |||||
SYSCTL_INT(_kern_smp, OID_AUTO, cores, CTLFLAG_RD|CTLFLAG_CAPRD, &mp_ncores, 0, | |||||
"Number of CPUs online"); | |||||
int smp_topology = 0; /* Which topology we're using. */ | int smp_topology = 0; /* Which topology we're using. */ | ||||
SYSCTL_INT(_kern_smp, OID_AUTO, topology, CTLFLAG_RDTUN, &smp_topology, 0, | SYSCTL_INT(_kern_smp, OID_AUTO, topology, CTLFLAG_RDTUN, &smp_topology, 0, | ||||
"Topology override setting; 0 is default provided by hardware."); | "Topology override setting; 0 is default provided by hardware."); | ||||
#ifdef SMP | #ifdef SMP | ||||
/* Enable forwarding of a signal to a process running on a different CPU */ | /* Enable forwarding of a signal to a process running on a different CPU */ | ||||
static int forward_signal_enabled = 1; | static int forward_signal_enabled = 1; | ||||
SYSCTL_INT(_kern_smp, OID_AUTO, forward_signal_enabled, CTLFLAG_RW, | SYSCTL_INT(_kern_smp, OID_AUTO, forward_signal_enabled, CTLFLAG_RW, | ||||
Show All 40 Lines | |||||
static void | static void | ||||
mp_start(void *dummy) | mp_start(void *dummy) | ||||
{ | { | ||||
mtx_init(&smp_ipi_mtx, "smp rendezvous", NULL, MTX_SPIN); | mtx_init(&smp_ipi_mtx, "smp rendezvous", NULL, MTX_SPIN); | ||||
/* Probe for MP hardware. */ | /* Probe for MP hardware. */ | ||||
if (smp_disabled != 0 || cpu_mp_probe() == 0) { | if (smp_disabled != 0 || cpu_mp_probe() == 0) { | ||||
mp_ncores = 1; | |||||
mp_ncpus = 1; | mp_ncpus = 1; | ||||
CPU_SETOF(PCPU_GET(cpuid), &all_cpus); | CPU_SETOF(PCPU_GET(cpuid), &all_cpus); | ||||
return; | return; | ||||
} | } | ||||
cpu_mp_start(); | cpu_mp_start(); | ||||
printf("FreeBSD/SMP: Multiprocessor System Detected: %d CPUs\n", | printf("FreeBSD/SMP: Multiprocessor System Detected: %d CPUs\n", | ||||
mp_ncpus); | mp_ncpus); | ||||
/* Provide a default for most architectures that don't have SMT/HTT. */ | |||||
if (mp_ncores < 0) | |||||
mp_ncores = mp_ncpus; | |||||
cpu_mp_announce(); | cpu_mp_announce(); | ||||
} | } | ||||
SYSINIT(cpu_mp, SI_SUB_CPU, SI_ORDER_THIRD, mp_start, NULL); | SYSINIT(cpu_mp, SI_SUB_CPU, SI_ORDER_THIRD, mp_start, NULL); | ||||
void | void | ||||
forward_signal(struct thread *td) | forward_signal(struct thread *td) | ||||
{ | { | ||||
int id; | int id; | ||||
▲ Show 20 Lines • Show All 645 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Provide dummy SMP support for UP kernels. Modules that need to use SMP | * Provide dummy SMP support for UP kernels. Modules that need to use SMP | ||||
* APIs will still work using this dummy support. | * APIs will still work using this dummy support. | ||||
*/ | */ | ||||
static void | static void | ||||
mp_setvariables_for_up(void *dummy) | mp_setvariables_for_up(void *dummy) | ||||
{ | { | ||||
mp_ncpus = 1; | mp_ncpus = 1; | ||||
mp_ncores = 1; | |||||
mp_maxid = PCPU_GET(cpuid); | mp_maxid = PCPU_GET(cpuid); | ||||
CPU_SETOF(mp_maxid, &all_cpus); | CPU_SETOF(mp_maxid, &all_cpus); | ||||
KASSERT(PCPU_GET(cpuid) == 0, ("UP must have a CPU ID of zero")); | KASSERT(PCPU_GET(cpuid) == 0, ("UP must have a CPU ID of zero")); | ||||
} | } | ||||
SYSINIT(cpu_mp_setvariables, SI_SUB_TUNABLES, SI_ORDER_FIRST, | SYSINIT(cpu_mp_setvariables, SI_SUB_TUNABLES, SI_ORDER_FIRST, | ||||
mp_setvariables_for_up, NULL); | mp_setvariables_for_up, NULL); | ||||
#endif /* SMP */ | #endif /* SMP */ | ||||
▲ Show 20 Lines • Show All 326 Lines • Show Last 20 Lines |