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

Commit ce1bdbe5 authored by Edgar Arriaga's avatar Edgar Arriaga
Browse files

Add volatile to some cancel compaction signals to avoid compiler optimizations

The compaction cancel signals are delivered between different threads so
add volatile keyword for such variables to make sure the compiler does
not try to optimize the values avoiding them to be effective due to
potential register caching.

Bug: 227060330
Test: Manual

Change-Id: I42503e02627c6f76382a58da9320b3f5df15a75d
parent 463a08b2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1737,7 +1737,7 @@ public final class CachedAppOptimizer {
     * Default implementation for ProcessDependencies, public vor visibility to OomAdjuster class.
     */
    private static final class DefaultProcessDependencies implements ProcessDependencies {
        public static int mPidCompacting = -1;
        public static volatile int mPidCompacting = -1;

        // Get memory RSS from process.
        @Override
+2 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ using android::base::unique_fd;

namespace android {

// Signal happening in separate thread that would bail out compaction
// before starting next VMA batch
static std::atomic<bool> cancelRunningCompaction;

// Legacy method for compacting processes, any new code should