From beea10e8e63cfcc80810ffaf87c80770c101d2d5 Mon Sep 17 00:00:00 2001 From: ramindani Date: Tue, 7 Dec 2021 21:02:49 +0000 Subject: [PATCH] Set the thread pool count to 4 for vts3 tests. Thread priority is from https://source.corp.google.com/android/frameworks/native/services/surfaceflinger/main_surfaceflinger.cpp;rcl=e9cdd276a89d512137f22650da0c45ee4b28bd66;l=97 Test: atest VtsHalGraphicsComposer3_TargetTest BUG: 207005096 Change-Id: Ic37b454c4ae3990fd8cb38fcdd50747083b2528c --- .../VtsHalGraphicsComposer3_TargetTest.cpp | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp index 7a20a53e3b..0d71b683b3 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp @@ -1950,5 +1950,41 @@ int main(int argc, char** argv) { ALOGE("Failed to stop init.svc.surfaceflinger"); return -1; } + + android::ProcessState::self()->setThreadPoolMaxThreadCount(4); + + // The binder threadpool we start will inherit sched policy and priority + // of (this) creating thread. We want the binder thread pool to have + // SCHED_FIFO policy and priority 1 (lowest RT priority) + // Once the pool is created we reset this thread's priority back to + // original. + // This thread policy is based on what we do in the SurfaceFlinger while starting + // the thread pool and we need to replicate that for the VTS tests. + int newPriority = 0; + int origPolicy = sched_getscheduler(0); + struct sched_param origSchedParam; + + int errorInPriorityModification = sched_getparam(0, &origSchedParam); + if (errorInPriorityModification == 0) { + int policy = SCHED_FIFO; + newPriority = sched_get_priority_min(policy); + + struct sched_param param; + param.sched_priority = newPriority; + + errorInPriorityModification = sched_setscheduler(0, policy, ¶m); + } + + // start the thread pool + android::ProcessState::self()->startThreadPool(); + + // Reset current thread's policy and priority + if (errorInPriorityModification == 0) { + errorInPriorityModification = sched_setscheduler(0, origPolicy, &origSchedParam); + } else { + ALOGE("Failed to set VtsHalGraphicsComposer3_TargetTest binder threadpool priority to " + "SCHED_FIFO"); + } + return RUN_ALL_TESTS(); }