Lines Matching +full:higher +full:- +full:than +full:- +full:threshold
1 // SPDX-License-Identifier: GPL-2.0-only
3 * menu.c - the menu idle governor
5 * Copyright (C) 2006-2007 Adam Belay <abelay@novell.com>
40 * -----------------------
47 * Since there are other source of wakeups (interrupts for example) than
58 * getting an interrupt very early is much higher than if we expect 50 micro
61 * (as a special twist, we consider every sleep longer than 50 milliseconds
62 * as perfect; there are no power gains for sleeping longer than this)
68 * Repeatable-interval-detector
69 * ----------------------------
76 * threshold value, we use the average of these intervals as prediction.
79 * ---------------------------
88 * This rule-of-thumb is implemented using a performance-multiplier:
89 * If the exit latency times the performance multiplier is longer than
91 * for selection due to a too high performance impact. So the higher
145 * to be, the higher this multiplier, and thus the higher
161 * of points is below a threshold. If it is... then use the
180 unsigned int value = data->intervals[i]; in get_typical_interval()
203 unsigned int value = data->intervals[i]; in get_typical_interval()
205 int64_t diff = (int64_t)value - avg; in get_typical_interval()
218 * 6*stddev, avg^2 > 36*variance). The average is smaller than in get_typical_interval()
221 * the standard deviation is greater than 715 s (which is in get_typical_interval()
235 * those by setting the threshold to exclude these outliers, then in get_typical_interval()
245 thresh = max - 1; in get_typical_interval()
250 * menu_select - selects the next idle state to enter
259 s64 latency_req = cpuidle_governor_latency_req(dev->cpu); in menu_select()
266 if (data->needs_update) { in menu_select()
268 data->needs_update = 0; in menu_select()
271 nr_iowaiters = nr_iowait_cpu(dev->cpu); in menu_select()
285 data->next_timer_ns = delta; in menu_select()
286 data->bucket = which_bucket(data->next_timer_ns, nr_iowaiters); in menu_select()
290 data->next_timer_ns * in menu_select()
291 data->correction_factor[data->bucket], in menu_select()
302 data->next_timer_ns = KTIME_MAX; in menu_select()
304 data->bucket = which_bucket(KTIME_MAX, nr_iowaiters); in menu_select()
307 if (unlikely(drv->state_count <= 1 || latency_req == 0) || in menu_select()
308 ((data->next_timer_ns < drv->states[1].target_residency_ns || in menu_select()
309 latency_req < drv->states[1].exit_latency_ns) && in menu_select()
310 !dev->states_usage[0].disable)) { in menu_select()
316 *stop_tick = !(drv->states[0].flags & CPUIDLE_FLAG_POLLING); in menu_select()
323 * idle duration misprediction is much higher, because the CPU in menu_select()
330 predicted_ns = data->next_timer_ns; in menu_select()
333 * Use the performance multiplier and the user-configurable in menu_select()
346 idx = -1; in menu_select()
347 for (i = 0; i < drv->state_count; i++) { in menu_select()
348 struct cpuidle_state *s = &drv->states[i]; in menu_select()
350 if (dev->states_usage[i].disable) in menu_select()
353 if (idx == -1) in menu_select()
356 if (s->target_residency_ns > predicted_ns) { in menu_select()
361 if ((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) && in menu_select()
362 s->exit_latency_ns <= latency_req && in menu_select()
363 s->target_residency_ns <= data->next_timer_ns) { in menu_select()
364 predicted_ns = s->target_residency_ns; in menu_select()
378 predicted_ns = drv->states[idx].target_residency_ns; in menu_select()
388 if (drv->states[idx].target_residency_ns < TICK_NSEC && in menu_select()
389 s->target_residency_ns <= delta_tick) in menu_select()
394 if (s->exit_latency_ns > latency_req) in menu_select()
400 if (idx == -1) in menu_select()
405 * expected idle duration is shorter than the tick period length. in menu_select()
407 if (((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) || in menu_select()
411 if (idx > 0 && drv->states[idx].target_residency_ns > delta_tick) { in menu_select()
418 for (i = idx - 1; i >= 0; i--) { in menu_select()
419 if (dev->states_usage[i].disable) in menu_select()
423 if (drv->states[i].target_residency_ns <= delta_tick) in menu_select()
433 * menu_reflect - records that data structures need update
444 dev->last_state_idx = index; in menu_reflect()
445 data->needs_update = 1; in menu_reflect()
446 data->tick_wakeup = tick_nohz_idle_got_tick(); in menu_reflect()
450 * menu_update - attempts to guess what happened after entry
457 int last_idx = dev->last_state_idx; in menu_update()
458 struct cpuidle_state *target = &drv->states[last_idx]; in menu_update()
473 * the measured amount of time is less than the exit latency, in menu_update()
477 if (data->tick_wakeup && data->next_timer_ns > TICK_NSEC) { in menu_update()
488 } else if ((drv->states[last_idx].flags & CPUIDLE_FLAG_POLLING) && in menu_update()
489 dev->poll_time_limit) { in menu_update()
497 measured_ns = data->next_timer_ns; in menu_update()
500 measured_ns = dev->last_residency_ns; in menu_update()
503 if (measured_ns > 2 * target->exit_latency_ns) in menu_update()
504 measured_ns -= target->exit_latency_ns; in menu_update()
510 if (measured_ns > data->next_timer_ns) in menu_update()
511 measured_ns = data->next_timer_ns; in menu_update()
514 new_factor = data->correction_factor[data->bucket]; in menu_update()
515 new_factor -= new_factor / DECAY; in menu_update()
517 if (data->next_timer_ns > 0 && measured_ns < MAX_INTERESTING) in menu_update()
519 data->next_timer_ns); in menu_update()
536 data->correction_factor[data->bucket] = new_factor; in menu_update()
538 /* update the repeating-pattern data */ in menu_update()
539 data->intervals[data->interval_ptr++] = ktime_to_us(measured_ns); in menu_update()
540 if (data->interval_ptr >= INTERVALS) in menu_update()
541 data->interval_ptr = 0; in menu_update()
545 * menu_enable_device - scans a CPU's states and does setup
552 struct menu_device *data = &per_cpu(menu_devices, dev->cpu); in menu_enable_device()
562 data->correction_factor[i] = RESOLUTION * DECAY; in menu_enable_device()
576 * init_menu - initializes the governor