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

Commit edab739e authored by Edgar Arriaga García's avatar Edgar Arriaga García Committed by Android (Google) Code Review
Browse files

Merge "Allow compaction non shared and non executable memory mappings" into main

parents 8ca98f3d a2264f99
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -241,7 +241,8 @@ public final class CachedAppOptimizer {
    private static final int FREEZE_BINDER_TIMEOUT_MS = 100;
    private static final int FREEZE_DEADLOCK_TIMEOUT_MS = 1000;

    @VisibleForTesting static final boolean ENABLE_FILE_COMPACT = false;
    // If enabled, any compaction issued will apply to code mappings and share memory mappings.
    @VisibleForTesting static final boolean ENABLE_SHARED_AND_CODE_COMPACT = false;

    // Defaults for phenotype flags.
    @VisibleForTesting static final boolean DEFAULT_USE_COMPACTION = true;
@@ -1686,7 +1687,7 @@ public final class CachedAppOptimizer {
            }
        }

        if (!ENABLE_FILE_COMPACT) {
        if (!ENABLE_SHARED_AND_CODE_COMPACT) {
            if (profile == CompactProfile.SOME) {
                profile = CompactProfile.NONE;
            } else if (profile == CompactProfile.FULL) {
+7 −1
Original line number Diff line number Diff line
@@ -333,7 +333,10 @@ static int getFilePageAdvice(const Vma& vma) {
    return -1;
}
static int getAnonPageAdvice(const Vma& vma) {
    if (vma.inode == 0 && !vma.is_shared) {
    bool hasReadFlag = (vma.flags & PROT_READ) > 0;
    bool hasWriteFlag = (vma.flags & PROT_WRITE) > 0;
    bool hasExecuteFlag = (vma.flags & PROT_EXEC) > 0;
    if ((hasReadFlag || hasWriteFlag) && !hasExecuteFlag && !vma.is_shared) {
        return MADV_PAGEOUT;
    }
    return -1;
@@ -376,6 +379,9 @@ static int64_t compactProcess(int pid, VmaToAdviseFunc vmaToAdviseFunc) {
                ++coldVmaIndex;
                break;
            case MADV_PAGEOUT:
#ifdef DEBUG_COMPACTION
                ALOGE("Adding to compact vma=%s", vma.name.c_str());
#endif
                if (pageoutVmaIndex < pageoutVmas.size()) {
                    pageoutVmas[pageoutVmaIndex] = vma;
                } else {
+1 −1
Original line number Diff line number Diff line
@@ -969,7 +969,7 @@ public final class CachedAppOptimizerTest {

        mCachedAppOptimizerUnderTest.mLastCompactionStats.clear();

        if (CachedAppOptimizer.ENABLE_FILE_COMPACT) {
        if (CachedAppOptimizer.ENABLE_SHARED_AND_CODE_COMPACT) {
            // We force a some compaction
            mCachedAppOptimizerUnderTest.compactApp(processRecord,
                    CachedAppOptimizer.CompactProfile.SOME, CachedAppOptimizer.CompactSource.APP,