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

Commit a9ab6650 authored by Xiang Wang's avatar Xiang Wang
Browse files

Remove the affinity flag check

Since we want this to be part of the headroom API flag instead

Bug: 346604998
Change-Id: I5c079f0c2d1600c6563b4a768b2e644bc6bf7a94
Flag: android.os.cpu_gpu_headrooms
Test: atest HintManagerServiceTest
parent bfbc20d3
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.os.Flags.adpfUseFmqChannel;

import static com.android.internal.util.ConcurrentUtils.DIRECT_EXECUTOR;
import static com.android.server.power.hint.Flags.adpfSessionTag;
import static com.android.server.power.hint.Flags.cpuHeadroomAffinityCheck;
import static com.android.server.power.hint.Flags.powerhintThreadCleanup;
import static com.android.server.power.hint.Flags.resetOnForkEnabled;

@@ -1604,8 +1603,7 @@ public final class HintManagerService extends SystemService {
                        }
                    }
                }
                if (cpuHeadroomAffinityCheck() && mCheckHeadroomAffinity
                        && params.tids.length > 1) {
                if (mCheckHeadroomAffinity && params.tids.length > 1) {
                    checkThreadAffinityForTids(params.tids);
                }
                halParams.tids = params.tids;
+1 −27
Original line number Diff line number Diff line
@@ -70,8 +70,6 @@ import android.os.PerformanceHintManager;
import android.os.Process;
import android.os.RemoteException;
import android.os.SessionCreationConfig;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
@@ -1388,7 +1386,6 @@ public class HintManagerServiceTest {


    @Test
    @EnableFlags({Flags.FLAG_CPU_HEADROOM_AFFINITY_CHECK})
    public void testCpuHeadroomCache() throws Exception {
        CpuHeadroomParamsInternal params1 = new CpuHeadroomParamsInternal();
        CpuHeadroomParams halParams1 = new CpuHeadroomParams();
@@ -1476,8 +1473,7 @@ public class HintManagerServiceTest {
    }

    @Test
    @EnableFlags({Flags.FLAG_CPU_HEADROOM_AFFINITY_CHECK})
    public void testGetCpuHeadroomDifferentAffinity_flagOn() throws Exception {
    public void testGetCpuHeadroomDifferentAffinity() throws Exception {
        CountDownLatch latch = new CountDownLatch(2);
        int[] tids = createThreads(2, latch);
        CpuHeadroomParamsInternal params = new CpuHeadroomParamsInternal();
@@ -1497,28 +1493,6 @@ public class HintManagerServiceTest {
        verify(mIPowerMock, times(0)).getCpuHeadroom(any());
    }

    @Test
    @DisableFlags({Flags.FLAG_CPU_HEADROOM_AFFINITY_CHECK})
    public void testGetCpuHeadroomDifferentAffinity_flagOff() throws Exception {
        CountDownLatch latch = new CountDownLatch(2);
        int[] tids = createThreads(2, latch);
        CpuHeadroomParamsInternal params = new CpuHeadroomParamsInternal();
        params.tids = tids;
        CpuHeadroomParams halParams = new CpuHeadroomParams();
        halParams.tids = tids;
        float headroom = 0.1f;
        CpuHeadroomResult halRet = CpuHeadroomResult.globalHeadroom(headroom);
        String ret1 = runAndWaitForCommand("taskset -p 1 " + tids[0]);
        String ret2 = runAndWaitForCommand("taskset -p 3 " + tids[1]);

        HintManagerService service = createService();
        clearInvocations(mIPowerMock);
        when(mIPowerMock.getCpuHeadroom(eq(halParams))).thenReturn(halRet);
        assertEquals("taskset cmd return: " + ret1 + "\n" + ret2, halRet,
                service.getBinderServiceInstance().getCpuHeadroom(params));
        verify(mIPowerMock, times(1)).getCpuHeadroom(any());
    }

    private String runAndWaitForCommand(String command) throws Exception {
        java.lang.Process process = Runtime.getRuntime().exec(command);
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));