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

Commit 319474c1 authored by Wei Wang's avatar Wei Wang
Browse files

Set reset_on_fork in setRenderThread as well

Also check the thread scheduler before setting it to SCHED_OTHER | SCHED_RESET_ON_FORK to avoid overhead.

Bug: 370988407
Change-Id: I946f653429978ae2be1c119dd4d99733acd372ff
Flag: com.android.server.am.reset_on_fork_enabled
Test: Build and check with chrt -p [APP_RT_PID]
parent bc57d803
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -8269,7 +8269,16 @@ public class ActivityManagerService extends IActivityManager.Stub
                        setThreadScheduler(proc.getRenderThreadTid(),
                                SCHED_FIFO | SCHED_RESET_ON_FORK, 1);
                    } else {
                        setThreadPriority(proc.getRenderThreadTid(), THREAD_PRIORITY_TOP_APP_BOOST);
                        if (Flags.resetOnForkEnabled()) {
                            if (Process.getThreadScheduler(proc.getRenderThreadTid())
                                    == Process.SCHED_OTHER) {
                                Process.setThreadScheduler(proc.getRenderThreadTid(),
                                    Process.SCHED_OTHER | Process.SCHED_RESET_ON_FORK,
                                    0);
                            }
                        }
                        setThreadPriority(proc.getRenderThreadTid(),
                            THREAD_PRIORITY_TOP_APP_BOOST);
                    }
                }
            } else {
+6 −5
Original line number Diff line number Diff line
@@ -459,13 +459,14 @@ public class OomAdjuster {

        void setThreadPriority(int tid, int priority) {
            if (Flags.resetOnForkEnabled()) {
                if (Process.getThreadScheduler(tid) == Process.SCHED_OTHER) {
                    Process.setThreadScheduler(tid,
                        Process.SCHED_OTHER | Process.SCHED_RESET_ON_FORK,
                    priority);
            } else {
                 Process.setThreadPriority(tid, priority);
                        0);
                }
            }
            Process.setThreadPriority(tid, priority);
        }

    }