+ /* Obtain power-relevant interrupt and "platform-idle exit" statistics.
+ * We also account for "double hop" thread signaling via
+ * the thread callout infrastructure.
+ * DRK: consider removing the callout wakeup counters in the future
+ * they're present for verification at the moment.
+ */
+ boolean_t aticontext, pidle;
+ ml_get_power_state(&aticontext, &pidle);
+ if (__improbable(aticontext)) {
+ ledger_credit(thread->t_ledger, task_ledgers.interrupt_wakeups, 1);
+ uint64_t ttd = PROCESSOR_DATA(current_processor(), timer_call_ttd);
+ if (ttd) {
+ if (ttd <= timer_deadline_tracking_bin_1)
+ thread->thread_timer_wakeups_bin_1++;
+ else
+ if (ttd <= timer_deadline_tracking_bin_2)
+ thread->thread_timer_wakeups_bin_2++;
+ }
+ if (pidle) {
+ ledger_credit(thread->t_ledger, task_ledgers.platform_idle_wakeups, 1);
+ }
+ } else if (thread_get_tag_internal(cthread) & THREAD_TAG_CALLOUT) {
+ if (cthread->callout_woken_from_icontext) {
+ ledger_credit(thread->t_ledger, task_ledgers.interrupt_wakeups, 1);
+ thread->thread_callout_interrupt_wakeups++;
+ if (cthread->callout_woken_from_platform_idle) {
+ ledger_credit(thread->t_ledger, task_ledgers.platform_idle_wakeups, 1);
+ thread->thread_callout_platform_idle_wakeups++;
+ }
+ }
+ }
+
+ if (thread_get_tag_internal(thread) & THREAD_TAG_CALLOUT) {
+ thread->callout_woken_from_icontext = aticontext;
+ thread->callout_woken_from_platform_idle = pidle;
+ }
+