Commit 03dba278043358bbbf4f029be169e1e73d2fbe2b

Authored by Rafael J. Wysocki
1 parent 7037b43e00

cpuidle: menu: Replace data->predicted_us with local variable

The predicted_us field in struct menu_device is only accessed in
menu_select(), so replace it with a local variable in that function.

With that, stop using expected_interval instead of predicted_us to
store the new predicted idle duration value if it is set to the
selected state's target residency which is quite confusing.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Showing 1 changed file with 11 additions and 12 deletions Side-by-side Diff

drivers/cpuidle/governors/menu.c
... ... @@ -124,7 +124,6 @@
124 124 int tick_wakeup;
125 125  
126 126 unsigned int next_timer_us;
127   - unsigned int predicted_us;
128 127 unsigned int bucket;
129 128 unsigned int correction_factor[BUCKETS];
130 129 unsigned int intervals[INTERVALS];
... ... @@ -290,6 +289,7 @@
290 289 int idx;
291 290 unsigned int interactivity_req;
292 291 unsigned int expected_interval;
  292 + unsigned int predicted_us;
293 293 unsigned long nr_iowaiters, cpu_load;
294 294 ktime_t delta_next;
295 295  
... ... @@ -315,7 +315,7 @@
315 315 * operands are 32 bits.
316 316 * Make sure to round up for half microseconds.
317 317 */
318   - data->predicted_us = DIV_ROUND_CLOSEST_ULL((uint64_t)data->next_timer_us *
  318 + predicted_us = DIV_ROUND_CLOSEST_ULL((uint64_t)data->next_timer_us *
319 319 data->correction_factor[data->bucket],
320 320 RESOLUTION * DECAY);
321 321  
... ... @@ -341,7 +341,7 @@
341 341 /*
342 342 * Use the lowest expected idle interval to pick the idle state.
343 343 */
344   - data->predicted_us = min(data->predicted_us, expected_interval);
  344 + predicted_us = min(predicted_us, expected_interval);
345 345  
346 346 if (tick_nohz_tick_stopped()) {
347 347 /*
348 348  
349 349  
... ... @@ -352,19 +352,18 @@
352 352 * the known time till the closest timer event for the idle
353 353 * state selection.
354 354 */
355   - if (data->predicted_us < TICK_USEC)
356   - data->predicted_us = ktime_to_us(delta_next);
  355 + if (predicted_us < TICK_USEC)
  356 + predicted_us = ktime_to_us(delta_next);
357 357 } else {
358 358 /*
359 359 * Use the performance multiplier and the user-configurable
360 360 * latency_req to determine the maximum exit latency.
361 361 */
362   - interactivity_req = data->predicted_us / performance_multiplier(nr_iowaiters, cpu_load);
  362 + interactivity_req = predicted_us / performance_multiplier(nr_iowaiters, cpu_load);
363 363 if (latency_req > interactivity_req)
364 364 latency_req = interactivity_req;
365 365 }
366 366  
367   - expected_interval = data->predicted_us;
368 367 /*
369 368 * Find the idle state with the lowest power while satisfying
370 369 * our constraints.
... ... @@ -378,8 +377,8 @@
378 377 continue;
379 378 if (idx == -1)
380 379 idx = i; /* first enabled state */
381   - if (s->target_residency > data->predicted_us) {
382   - if (data->predicted_us < TICK_USEC)
  380 + if (s->target_residency > predicted_us) {
  381 + if (predicted_us < TICK_USEC)
383 382 break;
384 383  
385 384 if (!tick_nohz_tick_stopped()) {
... ... @@ -389,7 +388,7 @@
389 388 * tick in that case and let the governor run
390 389 * again in the next iteration of the loop.
391 390 */
392   - expected_interval = drv->states[idx].target_residency;
  391 + predicted_us = drv->states[idx].target_residency;
393 392 break;
394 393 }
395 394  
... ... @@ -412,7 +411,7 @@
412 411 * expected idle duration so that the tick is retained
413 412 * as long as that target residency is low enough.
414 413 */
415   - expected_interval = drv->states[idx].target_residency;
  414 + predicted_us = drv->states[idx].target_residency;
416 415 break;
417 416 }
418 417 idx = i;
... ... @@ -426,7 +425,7 @@
426 425 * expected idle duration is shorter than the tick period length.
427 426 */
428 427 if (((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) ||
429   - expected_interval < TICK_USEC) && !tick_nohz_tick_stopped()) {
  428 + predicted_us < TICK_USEC) && !tick_nohz_tick_stopped()) {
430 429 unsigned int delta_next_us = ktime_to_us(delta_next);
431 430  
432 431 *stop_tick = false;