summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishal Bhoj <vishal.bhoj@linaro.org>2013-06-19 13:33:16 +0100
committerVishal Bhoj <vishal.bhoj@linaro.org>2013-06-19 18:23:19 +0100
commitdf2f910f0630b03d6e1daf45f272540b251e82a2 (patch)
tree65613aee7bfc990adcf0fa79d5c655d7d8783c34
parent9b9a91553beb811183ea0e3a54eb86f04ef7b171 (diff)
downloadbase-linaro_android_4.2.2.tar.gz
ProcessStats: Handle changes in the scaling frequnencylinaro_android_4.2.2
Switching from MP to IKS mode results increase in number of operating points and results in bug #1183781 . The patch makes sure that whenever the available scaling frequency changes it resets the existing values and sets them as per the new values. Change-Id: Ic74cdc2015f3c4ddd61cb116d1f4b4ed1204a3bf Signed-off-by: Vishal Bhoj <vishal.bhoj@linaro.org>
-rw-r--r--core/java/com/android/internal/os/ProcessStats.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/core/java/com/android/internal/os/ProcessStats.java b/core/java/com/android/internal/os/ProcessStats.java
index f295636e3239..b1ea5c897f30 100644
--- a/core/java/com/android/internal/os/ProcessStats.java
+++ b/core/java/com/android/internal/os/ProcessStats.java
@@ -30,6 +30,7 @@ import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Date;
import java.util.StringTokenizer;
public class ProcessStats {
@@ -171,6 +172,11 @@ public class ProcessStats {
*/
private long[] mCpuSpeeds;
+ /**
+ * The lastmodified date of sysfs entry to detect change in available scaling frequency
+ */
+ private Date mLastModified = null;
+
public static class Stats {
public final int pid;
final String statFile;
@@ -557,9 +563,25 @@ public class ProcessStats {
long[] tempTimes = out;
long[] tempSpeeds = mCpuSpeeds;
final int MAX_SPEEDS = 60;
- if (out == null || out.length == 0) {
+ Date currentModified = null;
+
+ try {
+ File file = new File("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies");
+ if (file.exists()) {
+ currentModified = new Date(file.lastModified());
+ }
+ } catch (Exception e) {
+ Slog.i(TAG, "Exception = " + e);
+ }
+ if (mLastModified == null) {
+ mLastModified = currentModified;
+ }
+ if (out == null || out.length == 0 || mLastModified != currentModified) {
tempTimes = new long[MAX_SPEEDS]; // Hopefully no more than that
tempSpeeds = new long[MAX_SPEEDS];
+ mLastModified = currentModified;
+ // We need to clean up previous scaling frequency since they need to be updated
+ out = null;
}
int speed = 0;
String file = readFile("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state", '\0');
@@ -580,8 +602,14 @@ public class ProcessStats {
Slog.v(TAG, "First time : Speed/Time = " + tempSpeeds[speed - 1]
+ "\t" + tempTimes[speed - 1]);
}
- } catch (NumberFormatException nfe) {
- Slog.i(TAG, "Unable to parse time_in_state");
+ } catch (Exception e) {
+ if (e instanceof NumberFormatException) {
+ Slog.i(TAG, "Unable to parse time_in_state");
+ }
+ else if (e instanceof ArrayIndexOutOfBoundsException) {
+ Slog.i(TAG, "Scaling frequency changed while accessing" +
+ " the time_in_state, It will be handled when the function is called again");
+ }
}
}
}