18 #define CPUIDLE_STATES_MAX 10
22 static unsigned long long **previous_count;
23 static unsigned long long **current_count;
25 static unsigned long long timediff;
27 static int cpuidle_get_count_percent(
unsigned int id,
double *
percent,
30 unsigned long long statediff = current_count[
cpu][
id]
31 - previous_count[
cpu][
id];
32 dprint(
"%s: - diff: %llu - percent: %f (%u)\n",
33 cpuidle_cstates[
id].
name, timediff, *percent, cpu);
38 *percent = ((100.0 * statediff) / timediff);
40 dprint(
"%s: - timediff: %llu - statediff: %llu - percent: %f (%u)\n",
41 cpuidle_cstates[
id].
name, timediff, statediff, *percent, cpu);
46 static int cpuidle_start(
void)
55 dprint(
"CPU %d - State: %d - Val: %llu\n",
56 cpu, state, previous_count[cpu][state]);
62 static int cpuidle_stop(
void)
74 dprint(
"CPU %d - State: %d - Val: %llu\n",
75 cpu, state, previous_count[cpu][state]);
96 }
else if (!
strncmp(tmp,
"SNB-", 4)) {
111 }
else if (!
strncmp(tmp,
"ATM-", 4)) {
156 cpuidle_cstates[num].
id = num;
158 cpuidle_get_count_percent;
162 previous_count =
malloc(
sizeof(
long long *) * cpu_count);
163 current_count =
malloc(
sizeof(
long long *) * cpu_count);
165 previous_count[num] =
malloc(
sizeof(
long long) *
167 current_count[num] =
malloc(
sizeof(
long long) *
180 free(previous_count[num]);
181 free(current_count[num]);
183 free(previous_count);
188 .name =
"Idle_Stats",
189 .hw_states = cpuidle_cstates,
190 .start = cpuidle_start,
191 .stop = cpuidle_stop,
192 .do_register = cpuidle_register,