diff options
| author | 2025-01-21 14:26:59 -0800 | |
|---|---|---|
| committer | 2025-01-21 14:26:59 -0800 | |
| commit | 900a550ef5669d6785cab8aef050087fb5bbc483 (patch) | |
| tree | 4c828dfa33a7dc9ac3ef0433ef9cebd6f23ea757 | |
| parent | bdb3bc4f121e6a6c899ef38222f980ed6f27fb22 (diff) | |
| parent | 4944c1111997ada80501abf84b4a75565f5a3ea4 (diff) | |
Merge "Add debug sysprops to disable sched fifo in surfaceflinger" into main
9 files changed, 53 insertions, 9 deletions
diff --git a/libs/renderengine/threaded/RenderEngineThreaded.cpp b/libs/renderengine/threaded/RenderEngineThreaded.cpp index ea5605d4bd..67f4aa10f8 100644 --- a/libs/renderengine/threaded/RenderEngineThreaded.cpp +++ b/libs/renderengine/threaded/RenderEngineThreaded.cpp @@ -23,6 +23,7 @@ #include <future> #include <android-base/stringprintf.h> +#include <common/FlagManager.h> #include <common/trace.h> #include <private/gui/SyncFeatures.h> #include <processgroup/processgroup.h> @@ -60,7 +61,7 @@ status_t RenderEngineThreaded::setSchedFifo(bool enabled) { struct sched_param param = {0}; int sched_policy; - if (enabled) { + if (enabled && !FlagManager::getInstance().disable_sched_fifo_re()) { sched_policy = SCHED_FIFO; param.sched_priority = kFifoPriority; } else { diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp index 5cef0514b4..bb6bebed8d 100644 --- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp @@ -357,7 +357,9 @@ void AidlComposer::registerCallback(HWC2::ComposerCallback& callback) { mAidlComposerCallback = ndk::SharedRefBase::make<AidlIComposerCallbackWrapper>(callback); ndk::SpAIBinder binder = mAidlComposerCallback->asBinder(); - AIBinder_setMinSchedulerPolicy(binder.get(), SCHED_FIFO, 2); + if (!FlagManager::getInstance().disable_sched_fifo_composer_callback()) { + AIBinder_setMinSchedulerPolicy(binder.get(), SCHED_FIFO, 2); + } const auto status = mAidlComposerClient->registerCallback(mAidlComposerCallback); if (!status.isOk()) { diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp index fc317f3f27..a010353423 100644 --- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp @@ -28,6 +28,7 @@ #include <aidl/android/hardware/graphics/common/DisplayHotplugEvent.h> #include <android/binder_manager.h> #include <android/hardware/graphics/composer/2.1/types.h> +#include <common/FlagManager.h> #include <common/trace.h> #include <composer-command-buffer/2.2/ComposerCommandBuffer.h> #include <hidl/HidlTransportSupport.h> @@ -301,7 +302,9 @@ std::string HidlComposer::dumpDebugInfo() { } void HidlComposer::registerCallback(const sp<IComposerCallback>& callback) { - android::hardware::setMinSchedulerPolicy(callback, SCHED_FIFO, 2); + if (!FlagManager::getInstance().disable_sched_fifo_composer_callback()) { + android::hardware::setMinSchedulerPolicy(callback, SCHED_FIFO, 2); + } auto ret = [&]() { if (mClient_2_4) { diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp index c6d7160818..0efc396bcb 100644 --- a/services/surfaceflinger/Scheduler/EventThread.cpp +++ b/services/surfaceflinger/Scheduler/EventThread.cpp @@ -344,7 +344,8 @@ sp<EventThreadConnection> EventThread::createEventConnection( auto connection = sp<EventThreadConnection>::make(const_cast<EventThread*>(this), IPCThreadState::self()->getCallingUid(), eventRegistration); - if (FlagManager::getInstance().misc1()) { + if (FlagManager::getInstance().misc1() && + !FlagManager::getInstance().disable_sched_fifo_sf_sched()) { const int policy = SCHED_FIFO; connection->setMinSchedulerPolicy(policy, sched_get_priority_min(policy)); } diff --git a/services/surfaceflinger/Scheduler/src/Timer.cpp b/services/surfaceflinger/Scheduler/src/Timer.cpp index 20c58eb52f..6a5eeba823 100644 --- a/services/surfaceflinger/Scheduler/src/Timer.cpp +++ b/services/surfaceflinger/Scheduler/src/Timer.cpp @@ -24,6 +24,7 @@ #include <sys/timerfd.h> #include <sys/unistd.h> +#include <common/FlagManager.h> #include <common/trace.h> #include <ftl/concat.h> #include <ftl/enum.h> @@ -155,8 +156,10 @@ bool Timer::dispatch() { setDebugState(DebugState::Running); struct sched_param param = {0}; param.sched_priority = 2; - if (pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) != 0) { - ALOGW("Failed to set SCHED_FIFO on dispatch thread"); + if (!FlagManager::getInstance().disable_sched_fifo_sf_sched()) { + if (pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) != 0) { + ALOGW("Failed to set SCHED_FIFO on dispatch thread"); + } } if (pthread_setname_np(pthread_self(), "TimerDispatch") != 0) { diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index d6225e2eaa..becfab9c50 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -7116,7 +7116,7 @@ status_t SurfaceFlinger::setSchedFifo(bool enabled) { struct sched_param param = {0}; int sched_policy; - if (enabled) { + if (enabled && !FlagManager::getInstance().disable_sched_fifo_sf()) { sched_policy = SCHED_FIFO; param.sched_priority = kFifoPriority; } else { diff --git a/services/surfaceflinger/common/FlagManager.cpp b/services/surfaceflinger/common/FlagManager.cpp index e80cd78cbd..15df1528de 100644 --- a/services/surfaceflinger/common/FlagManager.cpp +++ b/services/surfaceflinger/common/FlagManager.cpp @@ -104,9 +104,19 @@ void FlagManager::dump(std::string& result) const { dumpFlag(result, (aconfig), #name, std::bind(&FlagManager::name, this)) #define DUMP_LEGACY_SERVER_FLAG(name) DUMP_FLAG_INTERNAL(name, false) #define DUMP_ACONFIG_FLAG(name) DUMP_FLAG_INTERNAL(name, true) +#define DUMP_SYSPROP_FLAG(name) \ + dumpFlag(result, (true), "debug.sf." #name, std::bind(&FlagManager::name, this)) base::StringAppendF(&result, "FlagManager values: \n"); + /// Sysprop flags /// + DUMP_SYSPROP_FLAG(disable_sched_fifo_sf); + DUMP_SYSPROP_FLAG(disable_sched_fifo_sf_binder); + DUMP_SYSPROP_FLAG(disable_sched_fifo_sf_sched); + DUMP_SYSPROP_FLAG(disable_sched_fifo_re); + DUMP_SYSPROP_FLAG(disable_sched_fifo_composer); + DUMP_SYSPROP_FLAG(disable_sched_fifo_composer_callback); + /// Legacy server flags /// DUMP_LEGACY_SERVER_FLAG(use_adpf_cpu_hint); DUMP_LEGACY_SERVER_FLAG(use_skia_tracing); @@ -185,6 +195,12 @@ bool FlagManager::getServerConfigurableFlag(const char* experimentFlagName) cons const auto res = parseBool(value.c_str()); return res.has_value() && res.value(); } +#define FLAG_MANAGER_SYSPROP_FLAG(name, defaultVal) \ + bool FlagManager::name() const { \ + static const bool kFlagValue = \ + base::GetBoolProperty("debug.sf." #name, /* default value*/ defaultVal); \ + return kFlagValue; \ + } #define FLAG_MANAGER_LEGACY_SERVER_FLAG(name, syspropOverride, serverFlagName) \ bool FlagManager::name() const { \ @@ -215,6 +231,14 @@ bool FlagManager::getServerConfigurableFlag(const char* experimentFlagName) cons #define FLAG_MANAGER_ACONFIG_FLAG_IMPORTED(name, syspropOverride, owner) \ FLAG_MANAGER_ACONFIG_INTERNAL(name, syspropOverride, owner) +/// Debug sysprop flags - default value is always false /// +FLAG_MANAGER_SYSPROP_FLAG(disable_sched_fifo_sf, /* default */ false) +FLAG_MANAGER_SYSPROP_FLAG(disable_sched_fifo_sf_binder, /* default */ false) +FLAG_MANAGER_SYSPROP_FLAG(disable_sched_fifo_sf_sched, /* default */ false) +FLAG_MANAGER_SYSPROP_FLAG(disable_sched_fifo_re, /* default */ false) +FLAG_MANAGER_SYSPROP_FLAG(disable_sched_fifo_composer, /* default */ false) +FLAG_MANAGER_SYSPROP_FLAG(disable_sched_fifo_composer_callback, /* default */ false) + /// Legacy server flags /// FLAG_MANAGER_LEGACY_SERVER_FLAG(test_flag, "", "") FLAG_MANAGER_LEGACY_SERVER_FLAG(use_adpf_cpu_hint, "debug.sf.enable_adpf_cpu_hint", diff --git a/services/surfaceflinger/common/include/common/FlagManager.h b/services/surfaceflinger/common/include/common/FlagManager.h index c7f97b4008..147e79edfa 100644 --- a/services/surfaceflinger/common/include/common/FlagManager.h +++ b/services/surfaceflinger/common/include/common/FlagManager.h @@ -42,6 +42,14 @@ public: void setUnitTestMode(); + /// Debug sysprop flags /// + bool disable_sched_fifo_sf() const; + bool disable_sched_fifo_sf_binder() const; + bool disable_sched_fifo_sf_sched() const; + bool disable_sched_fifo_re() const; + bool disable_sched_fifo_composer() const; + bool disable_sched_fifo_composer_callback() const; + /// Legacy server flags /// bool test_flag() const; bool use_adpf_cpu_hint() const; diff --git a/services/surfaceflinger/main_surfaceflinger.cpp b/services/surfaceflinger/main_surfaceflinger.cpp index 6c8972f1fb..73dfa9fa2f 100644 --- a/services/surfaceflinger/main_surfaceflinger.cpp +++ b/services/surfaceflinger/main_surfaceflinger.cpp @@ -132,7 +132,8 @@ int main(int, char**) { // Set the minimum policy of surfaceflinger node to be SCHED_FIFO. // So any thread with policy/priority lower than {SCHED_FIFO, 1}, will run // at least with SCHED_FIFO policy and priority 1. - if (errorInPriorityModification == 0) { + if (errorInPriorityModification == 0 && + !FlagManager::getInstance().disable_sched_fifo_sf_binder()) { flinger->setMinSchedulerPolicy(SCHED_FIFO, newPriority); } @@ -150,7 +151,8 @@ int main(int, char**) { // publish gui::ISurfaceComposer, the new AIDL interface sp<SurfaceComposerAIDL> composerAIDL = sp<SurfaceComposerAIDL>::make(flinger); - if (FlagManager::getInstance().misc1()) { + if (FlagManager::getInstance().misc1() && + !FlagManager::getInstance().disable_sched_fifo_composer()) { composerAIDL->setMinSchedulerPolicy(SCHED_FIFO, newPriority); } sm->addService(String16("SurfaceFlingerAIDL"), composerAIDL, false, |