Date:2010-05-09 00:47:37 (13 years 4 months ago)
Author:Arjan van de Ven
Commit:1c6fe0364fa7bf28248488753ee0afb6b759cd04
Message:cpuidle: Fix incorrect optimization

commit 672917dcc78 ("cpuidle: menu governor: reduce latency on exit")
added an optimization, where the analysis on the past idle period moved
from the end of idle, to the beginning of the new idle.

Unfortunately, this optimization had a bug where it zeroed one key
variable for new use, that is needed for the analysis. The fix is
simple, zero the variable after doing the work from the previous idle.

During the audit of the code that found this issue, another issue was
also found; the ->measured_us data structure member is never set, a
local variable is always used instead.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Corrado Zoccolo <czoccolo@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Files: drivers/cpuidle/governors/menu.c (3 diffs)

Change Details

drivers/cpuidle/governors/menu.c
100100    int needs_update;
101101
102102    unsigned int expected_us;
103    unsigned int measured_us;
104103    u64 predicted_us;
105104    unsigned int exit_us;
106105    unsigned int bucket;
...... 
187186    int i;
188187    int multiplier;
189188
190    data->last_state_idx = 0;
191    data->exit_us = 0;
192
193189    if (data->needs_update) {
194190        menu_update(dev);
195191        data->needs_update = 0;
196192    }
197193
194    data->last_state_idx = 0;
195    data->exit_us = 0;
196
198197    /* Special case when user has set very strict latency requirement */
199198    if (unlikely(latency_req == 0))
200199        return 0;
...... 
294293    new_factor = data->correction_factor[data->bucket]
295294            * (DECAY - 1) / DECAY;
296295
297    if (data->expected_us > 0 && data->measured_us < MAX_INTERESTING)
296    if (data->expected_us > 0 && measured_us < MAX_INTERESTING)
298297        new_factor += RESOLUTION * measured_us / data->expected_us;
299298    else
300299        /*

Archive Download the corresponding diff file



interactive