Ensure that virtmgr and crosvm runs with max profile during benchmarking
Bug: 325745564
Test: atest MicrodroidBenchmarkApp
While the test runs, execute `cat /proc/$(pidof crosvm)/cgroup`.
It shows `3:cpuset:/top-app`. Without this change, it shows foreground.
Change-Id: I323685c33ba83685c96d7521ffc8357d667822a1
diff --git a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
index ba02067..acd6f2c 100644
--- a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
+++ b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
@@ -127,12 +127,21 @@
}
}
+ public MicrodroidBenchmarks() throws IOException {
+ // See b/325745564#comment28. Calling this method here ensures that threads spawned for
+ // @Test methods are with the desired task profile. If this is called in @Before, the task
+ // profile may not be set to the test threads because they may be spanwed prior to the
+ // execution of the @Before method (though the test methods will be executed after the
+ // @Before method). With this, children of this benchmark process (virtmgr and crosvm) also
+ // run in the desired task profile.
+ setMaxPerformanceTaskProfile();
+ }
+
@Before
public void setup() throws IOException {
grantPermission(VirtualMachine.MANAGE_VIRTUAL_MACHINE_PERMISSION);
grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
prepareTestSetup(mProtectedVm, mGki);
- setMaxPerformanceTaskProfile();
mInstrumentation = getInstrumentation();
}