content: Enforce CPU affinity on Android
As a part of the experiment to run all execution on little cores
we want to make sure that the cpu affinity doesn't change at runtime,
e.g. when Chrome goes back from background. To do this, we introduce
an interface in content that allows to enforce affinity by checking
it on a regular basis (every 100 tasks) and setting it back when it
changes.
Change-Id: I766e94af42861870abe3a0079dd335a23462d481
Bug: 1111789
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418673
Commit-Queue: Mikhail Khokhlov <[email protected]>
Reviewed-by: Robert Sesek <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Eric Seckler <[email protected]>
Cr-Commit-Position: refs/heads/master@{#812027}
diff --git a/base/cpu_affinity_posix.h b/base/cpu_affinity_posix.h
index 938a64c..5434a67 100644
--- a/base/cpu_affinity_posix.h
+++ b/base/cpu_affinity_posix.h
@@ -28,6 +28,15 @@
BASE_EXPORT bool SetProcessCpuAffinityMode(ProcessHandle process_handle,
CpuAffinityMode affinity);
+// Return true if the current architecture has big or bigger cores.
+BASE_EXPORT bool HasBigCpuCores();
+
+// For architectures with big cores, return the affinity mode that matches
+// the CPU affinity of the current thread. If no affinity mode exactly matches,
+// or if the architecture doesn't have different types of cores,
+// return nullopt.
+BASE_EXPORT base::Optional<CpuAffinityMode> CurrentThreadCpuAffinityMode();
+
} // namespace base
#endif // BASE_CPU_AFFINITY_POSIX_H_