X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/6d2010ae8f7a6078e10b361c6962983bab233e0f..c7d2c2c6ee645e10cbccdd01c6191873ec77239d:/osfmk/kern/machine.c diff --git a/osfmk/kern/machine.c b/osfmk/kern/machine.c index 9b310f031..dfe33564d 100644 --- a/osfmk/kern/machine.c +++ b/osfmk/kern/machine.c @@ -79,7 +79,6 @@ #include #include #include -#include #include #include #include @@ -95,6 +94,10 @@ #endif #include +#if CONFIG_DTRACE +extern void (*dtrace_cpu_state_changed_hook)(int, boolean_t); +#endif + /* * Exported variables: */ @@ -122,10 +125,7 @@ processor_up( init_ast_check(processor); pset = processor->processor_set; pset_lock(pset); - if (++pset->online_processor_count == 1) { - pset_pri_init_hint(pset, processor); - pset_count_init_hint(pset, processor); - } + ++pset->online_processor_count; enqueue_tail(&pset->active_queue, (queue_entry_t)processor); processor->state = PROCESSOR_RUNNING; (void)hw_atomic_add(&processor_avail_count, 1); @@ -133,7 +133,13 @@ processor_up( pset_unlock(pset); ml_cpu_up(); splx(s); + +#if CONFIG_DTRACE + if (dtrace_cpu_state_changed_hook) + (*dtrace_cpu_state_changed_hook)(processor->cpu_id, TRUE); +#endif } +#include kern_return_t host_reboot( @@ -145,10 +151,12 @@ host_reboot( assert(host_priv == &realhost); +#if DEVELOPMENT || DEBUG if (options & HOST_REBOOT_DEBUGGER) { Debugger("Debugger"); return (KERN_SUCCESS); } +#endif if (options & HOST_REBOOT_UPSDELAY) { // UPS power cutoff path @@ -204,7 +212,9 @@ processor_shutdown( */ while (processor->state == PROCESSOR_DISPATCHING) { pset_unlock(pset); + splx(s); delay(1); + s = splsched(); pset_lock(pset); } @@ -237,7 +247,7 @@ processor_shutdown( } /* - * Called at splsched. + * Called with interrupts disabled. */ void processor_doshutdown( @@ -245,6 +255,7 @@ processor_doshutdown( { thread_t old_thread, self = current_thread(); processor_t prev; + processor_set_t pset; /* * Get onto the processor to shutdown @@ -252,18 +263,31 @@ processor_doshutdown( prev = thread_bind(processor); thread_block(THREAD_CONTINUE_NULL); -#if HIBERNATION - if (processor_avail_count < 2) - hibernate_vm_lock(); + assert(processor->state == PROCESSOR_SHUTDOWN); + +#if CONFIG_DTRACE + if (dtrace_cpu_state_changed_hook) + (*dtrace_cpu_state_changed_hook)(processor->cpu_id, FALSE); #endif - assert(processor->state == PROCESSOR_SHUTDOWN); + ml_cpu_down(); #if HIBERNATION - if (processor_avail_count < 2) + if (processor_avail_count < 2) { + hibernate_vm_lock(); hibernate_vm_unlock(); + } #endif + pset = processor->processor_set; + pset_lock(pset); + processor->state = PROCESSOR_OFF_LINE; + --pset->online_processor_count; + (void)hw_atomic_sub(&processor_avail_count, 1); + commpage_update_active_cpus(); + SCHED(processor_queue_shutdown)(processor); + /* pset lock dropped */ + /* * Continue processor shutdown in shutdown context. */ @@ -274,7 +298,7 @@ processor_doshutdown( } /* - * Complete the shutdown and place the processor offline. + *Complete the shutdown and place the processor offline. * * Called at splsched in the shutdown context. */ @@ -283,7 +307,6 @@ processor_offline( processor_t processor) { thread_t new_thread, old_thread = processor->active_thread; - processor_set_t pset; new_thread = processor->idle_thread; processor->active_thread = new_thread; @@ -301,20 +324,6 @@ processor_offline( PMAP_DEACTIVATE_KERNEL(processor->cpu_id); - pset = processor->processor_set; - pset_lock(pset); - processor->state = PROCESSOR_OFF_LINE; - if (--pset->online_processor_count == 0) { - pset_pri_init_hint(pset, PROCESSOR_NULL); - pset_count_init_hint(pset, PROCESSOR_NULL); - } - (void)hw_atomic_sub(&processor_avail_count, 1); - commpage_update_active_cpus(); - SCHED(processor_queue_shutdown)(processor); - /* pset lock dropped */ - - ml_cpu_down(); - cpu_sleep(); panic("zombie processor"); /*NOTREACHED*/