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

Commit 1e650f5d authored by Wei Wang's avatar Wei Wang
Browse files

Set reset_on_fork flag for threads in power hint sessions

This ensures that the power hint session's sched policy is reset when a thread forks.

Bug: 370988407
Test: Build
Flag: com.android.server.power.hint.reset_on_fork_enabled
Change-Id: I8c93d8db870210b152b6441f8b0b6fc9077771c7
parent a90ea9c8
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.os.Flags.adpfUseFmqChannel;
import static com.android.internal.util.ConcurrentUtils.DIRECT_EXECUTOR;
import static com.android.server.power.hint.Flags.adpfSessionTag;
import static com.android.server.power.hint.Flags.powerhintThreadCleanup;
import static com.android.server.power.hint.Flags.resetOnForkEnabled;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -1057,6 +1058,11 @@ public final class HintManagerService extends SystemService {
                    Slogf.w(TAG, errMsg);
                    throw new SecurityException(errMsg);
                }
                if (resetOnForkEnabled()){
                    for (int tid : tids) {
                        Process.setThreadScheduler(tid, Process.SCHED_RESET_ON_FORK, 0);
                    }
                }

                if (adpfSessionTag() && tag == SessionTag.APP) {
                    // If the category of the app is a game,
@@ -1447,6 +1453,11 @@ public final class HintManagerService extends SystemService {
                            Slogf.w(TAG, errMsg);
                            throw new SecurityException(errMsg);
                        }
                        if (resetOnForkEnabled()){
                            for (int tid : tids) {
                                Process.setThreadScheduler(tid, Process.SCHED_RESET_ON_FORK, 0);
                            }
                        }
                        if (powerhintThreadCleanup()) {
                            synchronized (mNonIsolatedTidsLock) {
                                for (int i = nonIsolated.size() - 1; i >= 0; i--) {
+7 −0
Original line number Diff line number Diff line
@@ -14,3 +14,10 @@ flag {
    description: "Feature flag for adding session tag to hint session atom"
    bug: "345011125"
}

flag {
    name: "reset_on_fork_enabled"
    namespace: "game"
    description: "Set reset_on_fork flag."
    bug: "370988407"
}