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

Commit 02cead23 authored by Tanguy Pruvot's avatar Tanguy Pruvot
Browse files

CpuGovernorService for all, optional iobusy server thread

This is not QCOM specific, enable the feature for all

- Disable easily the iowait busy feature by a flag
This sysfs ondemand feature requires kernel >= 2.6.35

- Add a DBG flag to remove the on/off spams, only keep the notifications
I/CpuGovernorService( 2332): intent action: android.intent.action.SCREEN_ON
I/CpuGovernorService( 2332): intent action: android.intent.action.SCREEN_OFF

Change-Id: Ib1b393caaa5608f54cc8525ea3657fcab0dbf7fe
parent 44a85a17
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -51,10 +51,14 @@ import android.util.Log;
class CpuGovernorService {
    private final String TAG = "CpuGovernorService";
    private Context mContext;

    private final boolean DBG = false;
    private final boolean mUseIOBusyFeature = true;

    private SamplingRateChangeProcessor mSamplingRateChangeProcessor =
        new SamplingRateChangeProcessor();
    private IOBusyVoteProcessor mIOBusyVoteChangeProcessor =
        new IOBusyVoteProcessor();

    private IOBusyVoteProcessor mIOBusyVoteChangeProcessor = null;

    public CpuGovernorService(Context context) {
        mContext = context;
@@ -62,10 +66,16 @@ class CpuGovernorService {

        intentFilter.addAction(Intent.ACTION_SCREEN_ON);
        intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
        new Thread(mSamplingRateChangeProcessor).start();

        if (mUseIOBusyFeature) {
            // IOBusy feature requires kernel >= 2.6.35
            intentFilter.addAction(IOBusyVoteProcessor.ACTION_IOBUSY_VOTE);
            intentFilter.addAction(IOBusyVoteProcessor.ACTION_IOBUSY_UNVOTE);
        new Thread(mSamplingRateChangeProcessor).start();

            mIOBusyVoteChangeProcessor = new IOBusyVoteProcessor();
            new Thread(mIOBusyVoteChangeProcessor).start();
        }
        mContext.registerReceiver(mReceiver, intentFilter);
    }

@@ -74,7 +84,7 @@ class CpuGovernorService {
        public void onReceive(Context context, Intent intent) {
            boolean changeAdded = false;

            Log.i(TAG, "intent action: " + intent.getAction());
            if (DBG) Log.d(TAG, "intent action: " + intent.getAction());

            if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
                if (SystemProperties.getInt("dev.pm.dyn_samplingrate", 0) != 0) {
+5 −5
Original line number Diff line number Diff line
@@ -270,13 +270,13 @@ class ServerThread extends Thread {
            if (SystemProperties.QCOM_HARDWARE) {
                Slog.i(TAG, "DynamicMemoryManager Service");
                dmm = new DynamicMemoryManagerService(context);
            }

            cpuGovernorManager = new CpuGovernorService(context);

            if (cpuGovernorManager == null) {
                Slog.e(TAG, "CpuGovernorService failed to start");
            }
            }

        } catch (RuntimeException e) {
            Slog.e("System", "******************************************");
            Slog.e("System", "************ Failure starting core service", e);