OSDN Git Service

add overlays to override lowmemorykiller adjustment values
authorColin Cross <ccross@android.com>
Thu, 25 Jul 2013 22:04:40 +0000 (15:04 -0700)
committerColin Cross <ccross@android.com>
Thu, 25 Jul 2013 22:11:39 +0000 (15:11 -0700)
Add overlays config_lowMemoryKillerMinFreeKbytesAbsolute and
config_lowMemoryKillerMinFreeKbytesAdjust to allow a product to
modify the size of the lowmemorykiller minfree buckts.  The absolute
overlay sets the size of the largest bucket to the specified value
and scales the smaller buckets proportionally.  The adjust overlay
(which can be negative) directly adds to the size of the largest
bucket and to the the smaller buckets proportionally.

Change-Id: I0d6b7662be12fd151deb2bf9591f2c7a8b1cb6f7

core/res/res/values/config.xml
core/res/res/values/symbols.xml
services/java/com/android/server/am/ProcessList.java

index 1a5dc37..7647917 100644 (file)
          off features. -->
     <bool name="config_avoidGfxAccel">false</bool>
 
+    <!-- Device configuration setting the minfree tunable in the lowmemorykiller in the kernel.
+         A high value will cause the lowmemorykiller to fire earlier, keeping more memory
+         in the file cache and preventing I/O thrashing, but allowing fewer processes to
+         stay in memory.  A low value will keep more processes in memory but may cause
+         thrashing if set too low.  Overrides the default value chosen by ActivityManager
+         based on screen size and total memory for the largest lowmemorykiller bucket, and
+         scaled proportionally to the smaller buckets.  -1 keeps the default. -->
+    <integer name="config_lowMemoryKillerMinFreeKbytesAbsolute">-1</integer>
+
+    <!-- Device configuration adjusting the minfree tunable in the lowmemorykiller in the
+         kernel.  A high value will cause the lowmemorykiller to fire earlier, keeping more
+         memory in the file cache and preventing I/O thrashing, but allowing fewer processes
+         to stay in memory.  A low value will keep more processes in memory but may cause
+         thrashing if set too low.  Directly added to the default value chosen by
+         ActivityManager based on screen size and total memory for the largest lowmemorykiller
+         bucket, and scaled proportionally to the smaller buckets. 0 keeps the default. -->
+    <integer name="config_lowMemoryKillerMinFreeKbytesAdjust">0</integer>
+
     <!-- The duration (in milliseconds) that the radio will scan for a signal
          when there's no network connection. If the scan doesn't timeout, use zero -->
     <integer name="config_radioScanningTimeout">0</integer>
index 055b7eb..f1eae82 100755 (executable)
 
   <java-symbol type="integer" name="config_cursorWindowSize" />
   <java-symbol type="integer" name="config_longPressOnPowerBehavior" />
+  <java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAdjust" />
+  <java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAbsolute" />
   <java-symbol type="integer" name="config_max_pan_devices" />
   <java-symbol type="integer" name="config_ntpPollingInterval" />
   <java-symbol type="integer" name="config_ntpPollingIntervalShorter" />
   <java-symbol type="integer" name="config_lockSoundVolumeDb" />
   <java-symbol type="integer" name="config_multiuserMaximumUsers" />
   <java-symbol type="integer" name="config_safe_media_volume_index" />
-
   <java-symbol type="color" name="tab_indicator_text_v4" />
 
   <java-symbol type="dimen" name="accessibility_touch_slop" />
index 106ba22..0642a6c 100644 (file)
@@ -22,6 +22,7 @@ import java.io.IOException;
 import com.android.internal.util.MemInfoReader;
 import com.android.server.wm.WindowManagerService;
 
+import android.content.res.Resources;
 import android.graphics.Point;
 import android.util.Slog;
 import android.view.Display;
@@ -203,11 +204,31 @@ final class ProcessList {
         float scale = scaleMem > scaleDisp ? scaleMem : scaleDisp;
         if (scale < 0) scale = 0;
         else if (scale > 1) scale = 1;
+        int minfree_adj = Resources.getSystem().getInteger(com.android.internal.R.integer.config_lowMemoryKillerMinFreeKbytesAdjust);
+        int minfree_abs = Resources.getSystem().getInteger(com.android.internal.R.integer.config_lowMemoryKillerMinFreeKbytesAbsolute);
+
         for (int i=0; i<mOomAdj.length; i++) {
             long low = mOomMinFreeLow[i];
             long high = mOomMinFreeHigh[i];
             mOomMinFree[i] = (long)(low + ((high-low)*scale));
+        }
+
+        if (minfree_abs >= 0) {
+            for (int i=0; i<mOomAdj.length; i++) {
+                mOomMinFree[i] = (long)((float)minfree_abs * mOomMinFree[i] / mOomMinFree[mOomAdj.length - 1]);
+            }
+        }
 
+        if (minfree_adj != 0) {
+            for (int i=0; i<mOomAdj.length; i++) {
+                mOomMinFree[i] += (long)((float)minfree_adj * mOomMinFree[i] / mOomMinFree[mOomAdj.length - 1]);
+                if (mOomMinFree[i] < 0) {
+                    mOomMinFree[i] = 0;
+                }
+            }
+        }
+
+        for (int i=0; i<mOomAdj.length; i++) {
             if (i > 0) {
                 adjString.append(',');
                 memString.append(',');