CachedAppOptimizer: Fallback to process_madvise when memcg doesn't support compaction

Compaction has 3 profiles: FULL, SOME (file pages), and ANON

Even if a kernel has a memory.reclaim memcg interface, it may not
support SOME or ANON profiles if it does not have [1]. The
isProfileValidForProcess function checks for kernel support based on
the profile and works correctly, but it's only called after we have
already committed to using memcg reclaim. So if it returns false then we
don't perform compaction of any kind.

Add a check that verifies memcg supports the requested compaction
profile, and fallback to process_madvise if not.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=68cd9050d871e4db5433420b5ceb32f5512d18bc

Bug: 377479218
Flag: com.android.server.am.use_memcg_for_compaction
Test: atest com.android.server.am.CachedAppOptimizerTest
Change-Id: I984bc6af5549a7fbaa4d4acacdcc436dc57c81d1
2 files changed