/** * cpuidle_idle_call - the main idle loop * * NOTE: no locks or semaphores should be used here */ static void cpuidle_idle_call(void) { struct cpuidle_device *dev = __get_cpu_var(cpuidle_devices); struct cpuidle_state *target_state; int next_state; /* check if the device is ready */ if (!dev || !dev->enabled) { if (pm_idle_old) pm_idle_old(); else local_irq_enable(); return; } /* ask the governor for the next state */ next_state = cpuidle_curr_governor->select(dev); if (need_resched()) return; target_state = &dev->states[next_state]; /* enter the state and update stats */ dev->last_residency = target_state->enter(dev, target_state); dev->last_state = target_state; target_state->time += (unsigned long long)dev->last_residency; target_state->usage++; /* give the governor an opportunity to reflect on the outcome */ if (cpuidle_curr_governor->reflect) cpuidle_curr_governor->reflect(dev); }
/** * cpuidle_idle_call - the main idle loop * * NOTE: no locks or semaphores should be used here */ static void cpuidle_idle_call(void) { struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); struct cpuidle_state *target_state; int next_state; /* check if the device is ready */ if (!dev || !dev->enabled) { if (pm_idle_old) pm_idle_old(); else #if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE) default_idle(); #else local_irq_enable(); #endif return; } #if 0 /* shows regressions, re-enable for 2.6.29 */ /* * run any timers that can be run now, at this point * before calculating the idle duration etc. */ hrtimer_peek_ahead_timers(); #endif /* ask the governor for the next state */ next_state = cpuidle_curr_governor->select(dev); if (need_resched()) { local_irq_enable(); return; } target_state = &dev->states[next_state]; /* enter the state and update stats */ dev->last_state = target_state; trace_power_start(POWER_CSTATE, next_state, dev->cpu); trace_cpu_idle(next_state, dev->cpu); dev->last_residency = target_state->enter(dev, target_state); trace_power_end(dev->cpu); trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu); if (dev->last_state) target_state = dev->last_state; target_state->time += (unsigned long long)dev->last_residency; target_state->usage++; /* give the governor an opportunity to reflect on the outcome */ if (cpuidle_curr_governor->reflect) cpuidle_curr_governor->reflect(dev); }
static void cpufreq_idle(void) { struct timer_list *t; u64 *cpu_time_in_idle; u64 *cpu_idle_exit_time; pm_idle_old(); if (!cpumask_test_cpu(smp_processor_id(), policy->cpus)) return; /* Timer to fire in 1-2 ticks, jiffie aligned. */ t = &per_cpu(cpu_timer, smp_processor_id()); cpu_idle_exit_time = &per_cpu(idle_exit_time, smp_processor_id()); cpu_time_in_idle = &per_cpu(time_in_idle, smp_processor_id()); if (timer_pending(t) == 0) { *cpu_time_in_idle = get_cpu_idle_time_us( smp_processor_id(), cpu_idle_exit_time); mod_timer(t, jiffies + 2); } }
/** * cpuidle_idle_call - the main idle loop * * NOTE: no locks or semaphores should be used here */ static void cpuidle_idle_call(void) { struct cpuidle_device *dev = __get_cpu_var(cpuidle_devices); struct cpuidle_state *target_state; int next_state; /* check if the device is ready */ if (!dev || !dev->enabled) { if (pm_idle_old) pm_idle_old(); else #if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE) default_idle(); #else local_irq_enable(); #endif return; } #if 0 /* shows regressions, re-enable for 2.6.29 */ /* * run any timers that can be run now, at this point * before calculating the idle duration etc. */ hrtimer_peek_ahead_timers(); #endif /* * Call the device's prepare function before calling the * governor's select function. ->prepare gives the device's * cpuidle driver a chance to update any dynamic information * of its cpuidle states for the current idle period, e.g. * state availability, latencies, residencies, etc. */ if (dev->prepare) dev->prepare(dev); /* ask the governor for the next state */ next_state = cpuidle_curr_governor->select(dev); if (need_resched()) { local_irq_enable(); return; } target_state = &dev->states[next_state]; /* enter the state and update stats */ dev->last_state = target_state; dev->last_residency = target_state->enter(dev, target_state); if (dev->last_state) target_state = dev->last_state; target_state->time += (unsigned long long)dev->last_residency; target_state->usage++; /* give the governor an opportunity to reflect on the outcome */ if (cpuidle_curr_governor->reflect) cpuidle_curr_governor->reflect(dev); trace_power_end(0); }