static void runnables_work_func(struct work_struct *work) { bool up = false; bool sample = false; unsigned int cpu = nr_cpu_ids; mutex_lock(&runnables_work_lock); update_runnables_state(); switch (runnables_state) { case DISABLED: break; case IDLE: sample = true; break; case UP: //cpu = cpumask_next_zero(0, cpu_online_mask); cpu = best_core_to_turn_up(); up = true; sample = true; break; case DOWN: cpu = get_lightest_loaded_cpu_n(); sample = true; break; default: pr_err("%s: invalid cpuquiet runnable governor state %d\n", __func__, runnables_state); break; } if (sample) queue_delayed_work(runnables_wq, &runnables_work, msecs_to_jiffies(sample_rate)); if (cpu < nr_cpu_ids) { if (up) cpuquiet_wake_cpu(cpu); else cpuquiet_quiesence_cpu(cpu); } mutex_unlock(&runnables_work_lock); }
static void min_max_constraints_workfunc(struct work_struct *work) { int count = -1; bool up = false; unsigned int cpu; int nr_cpus = num_online_cpus(); int max_cpus = tegra_cpq_max_cpus(); int min_cpus = tegra_cpq_min_cpus(); if (cpq_state == TEGRA_CPQ_DISABLED) return; if (is_lp_cluster()) return; if (nr_cpus < min_cpus) { up = true; count = min_cpus - nr_cpus; } else if (nr_cpus > max_cpus && max_cpus >= min_cpus) { count = nr_cpus - max_cpus; } for (;count > 0; count--) { if (up) { cpu = best_core_to_turn_up(); if (cpu < nr_cpu_ids){ show_status("UP", 0, cpu); cpu_up(cpu); } else break; } else { cpu = cpumask_next(0, cpu_online_mask); if (cpu < nr_cpu_ids){ show_status("DOWN", 0, cpu); cpu_down(cpu); } else break; } } }