Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_smp.c
Show First 20 Lines • Show All 445 Lines • ▼ Show 20 Lines | #ifdef INVARIANTS | ||||
owepreempt = td->td_owepreempt; | owepreempt = td->td_owepreempt; | ||||
#endif | #endif | ||||
/* | /* | ||||
* If requested, run a setup function before the main action | * If requested, run a setup function before the main action | ||||
* function. Ensure all CPUs have completed the setup | * function. Ensure all CPUs have completed the setup | ||||
* function before moving on to the action function. | * function before moving on to the action function. | ||||
*/ | */ | ||||
if (local_setup_func != smp_no_rendevous_barrier) { | if (local_setup_func != smp_no_rendezvous_barrier) { | ||||
if (smp_rv_setup_func != NULL) | if (smp_rv_setup_func != NULL) | ||||
smp_rv_setup_func(smp_rv_func_arg); | smp_rv_setup_func(smp_rv_func_arg); | ||||
atomic_add_int(&smp_rv_waiters[1], 1); | atomic_add_int(&smp_rv_waiters[1], 1); | ||||
while (smp_rv_waiters[1] < smp_rv_ncpus) | while (smp_rv_waiters[1] < smp_rv_ncpus) | ||||
cpu_spinwait(); | cpu_spinwait(); | ||||
} | } | ||||
if (local_action_func != NULL) | if (local_action_func != NULL) | ||||
local_action_func(local_func_arg); | local_action_func(local_func_arg); | ||||
if (local_teardown_func != smp_no_rendevous_barrier) { | if (local_teardown_func != smp_no_rendezvous_barrier) { | ||||
/* | /* | ||||
* Signal that the main action has been completed. If a | * Signal that the main action has been completed. If a | ||||
* full exit rendezvous is requested, then all CPUs will | * full exit rendezvous is requested, then all CPUs will | ||||
* wait here until all CPUs have finished the main action. | * wait here until all CPUs have finished the main action. | ||||
*/ | */ | ||||
atomic_add_int(&smp_rv_waiters[2], 1); | atomic_add_int(&smp_rv_waiters[2], 1); | ||||
while (smp_rv_waiters[2] < smp_rv_ncpus) | while (smp_rv_waiters[2] < smp_rv_ncpus) | ||||
cpu_spinwait(); | cpu_spinwait(); | ||||
▲ Show 20 Lines • Show All 336 Lines • ▼ Show 20 Lines | mp_setvariables_for_up(void *dummy) | ||||
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 */ | ||||
void | void | ||||
smp_no_rendevous_barrier(void *dummy) | smp_no_rendezvous_barrier(void *dummy) | ||||
{ | { | ||||
#ifdef SMP | #ifdef SMP | ||||
KASSERT((!smp_started),("smp_no_rendevous called and smp is started")); | KASSERT((!smp_started),("smp_no_rendezvous called and smp is started")); | ||||
#endif | #endif | ||||
} | } | ||||
/* | /* | ||||
* Wait specified idle threads to switch once. This ensures that even | * Wait specified idle threads to switch once. This ensures that even | ||||
* preempted threads have cycled through the switch function once, | * preempted threads have cycled through the switch function once, | ||||
* exiting their codepaths. This allows us to change global pointers | * exiting their codepaths. This allows us to change global pointers | ||||
* with no other synchronization. | * with no other synchronization. | ||||
▲ Show 20 Lines • Show All 319 Lines • Show Last 20 Lines |