@@ -1009,9 +1009,8 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {
10091009 mPowerAdvisor ->init ();
10101010
10111011 if (base::GetBoolProperty (" service.sf.prime_shader_cache" s, true )) {
1012- if (setSchedFifo (false ) != NO_ERROR) {
1013- ALOGW (" Can't set SCHED_OTHER for primeCache" );
1014- }
1012+ constexpr const char * kWhence = " primeCache" ;
1013+ setSchedFifo (false , kWhence );
10151014
10161015 mRenderEnginePrimeCacheFuture .callOnce ([this ] {
10171016 renderengine::PrimeCacheConfig config;
@@ -1047,9 +1046,7 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {
10471046 return getRenderEngine ().primeCache (config);
10481047 });
10491048
1050- if (setSchedFifo (true ) != NO_ERROR) {
1051- ALOGW (" Can't set SCHED_FIFO after primeCache" );
1052- }
1049+ setSchedFifo (true , kWhence );
10531050 }
10541051
10551052 // Avoid blocking the main thread on `init` to set properties.
@@ -5690,16 +5687,11 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
56905687 }
56915688
56925689 if (displayId == mActiveDisplayId ) {
5693- // TODO(b/281692563): Merge the syscalls. For now, keep uclamp in a separate syscall and
5694- // set it before SCHED_FIFO due to b/190237315.
5695- if (setSchedAttr (true ) != NO_ERROR) {
5696- ALOGW (" Failed to set uclamp.min after powering on active display: %s" ,
5697- strerror (errno));
5698- }
5699- if (setSchedFifo (true ) != NO_ERROR) {
5700- ALOGW (" Failed to set SCHED_FIFO after powering on active display: %s" ,
5701- strerror (errno));
5702- }
5690+ // TODO: b/281692563 - Merge the syscalls. For now, keep uclamp in a separate syscall
5691+ // and set it before SCHED_FIFO due to b/190237315.
5692+ constexpr const char * kWhence = " setPowerMode(ON)" ;
5693+ setSchedAttr (true , kWhence );
5694+ setSchedFifo (true , kWhence );
57035695 }
57045696
57055697 getHwComposer ().setPowerMode (displayId, mode);
@@ -5726,14 +5718,9 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
57265718 if (const auto display = getActivatableDisplay ()) {
57275719 onActiveDisplayChangedLocked (activeDisplay.get (), *display);
57285720 } else {
5729- if (setSchedFifo (false ) != NO_ERROR) {
5730- ALOGW (" Failed to set SCHED_OTHER after powering off active display: %s" ,
5731- strerror (errno));
5732- }
5733- if (setSchedAttr (false ) != NO_ERROR) {
5734- ALOGW (" Failed set uclamp.min after powering off active display: %s" ,
5735- strerror (errno));
5736- }
5721+ constexpr const char * kWhence = " setPowerMode(OFF)" ;
5722+ setSchedFifo (false , kWhence );
5723+ setSchedAttr (false , kWhence );
57375724
57385725 if (currentModeNotDozeSuspend) {
57395726 if (!FlagManager::getInstance ().multithreaded_present ()) {
@@ -7196,7 +7183,7 @@ static status_t validateScreenshotPermissions(const CaptureArgs& captureArgs) {
71967183 return PERMISSION_DENIED;
71977184}
71987185
7199- status_t SurfaceFlinger::setSchedFifo (bool enabled) {
7186+ void SurfaceFlinger::setSchedFifo (bool enabled, const char * whence ) {
72007187 static constexpr int kFifoPriority = 2 ;
72017188 static constexpr int kOtherPriority = 0 ;
72027189
@@ -7211,19 +7198,19 @@ status_t SurfaceFlinger::setSchedFifo(bool enabled) {
72117198 }
72127199
72137200 if (sched_setscheduler (0 , sched_policy, ¶m) != 0 ) {
7214- return -errno;
7201+ const char * kPolicy [] = {" SCHED_OTHER" , " SCHED_FIFO" };
7202+ ALOGW (" %s: Failed to set %s: %s" , whence, kPolicy [sched_policy == SCHED_FIFO],
7203+ strerror (errno));
72157204 }
7216-
7217- return NO_ERROR;
72187205}
72197206
7220- status_t SurfaceFlinger::setSchedAttr (bool enabled) {
7207+ void SurfaceFlinger::setSchedAttr (bool enabled, const char * whence ) {
72217208 static const unsigned int kUclampMin =
72227209 base::GetUintProperty<unsigned int >(" ro.surface_flinger.uclamp.min" s, 0U );
72237210
72247211 if (!kUclampMin ) {
72257212 // uclamp.min set to 0 (default), skip setting
7226- return NO_ERROR ;
7213+ return ;
72277214 }
72287215
72297216 sched_attr attr = {};
@@ -7234,10 +7221,9 @@ status_t SurfaceFlinger::setSchedAttr(bool enabled) {
72347221 attr.sched_util_max = 1024 ;
72357222
72367223 if (syscall (__NR_sched_setattr, 0 , &attr, 0 )) {
7237- return -errno;
7224+ const char * kAction [] = {" disable" , " enable" };
7225+ ALOGW (" %s: Failed to %s uclamp.min: %s" , whence, kAction [enabled], strerror (errno));
72387226 }
7239-
7240- return NO_ERROR;
72417227}
72427228
72437229namespace {
0 commit comments