Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcdad6f2 authored by Colin Cross's avatar Colin Cross
Browse files

add overlays to override lowmemorykiller adjustment values

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
parent eb632544
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -134,6 +134,24 @@
         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>
+2 −1
Original line number Diff line number Diff line
@@ -284,6 +284,8 @@

  <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" />
@@ -302,7 +304,6 @@
  <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" />
+21 −0
Original line number Diff line number Diff line
@@ -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(',');