When creating uid/pid hierarchy, cgroup.subtree_control should be set at
every level of that hierarchy except for the leaf level.
Bug: 195149205
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Iedc2e859715b31db62158c85016708f252db2b70
Since installation time is also critical and sometime we want a finer
control on its behavior for vendor. Instead of set dex2oat to background
group, add a new task profile.
The default policy is to mirror SP_BACKGROUND to be compatible with
legacy devices.
Test: Boot
Bug: 188947181
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I7d5e113d1c368205f712eadad27775de226131ce
(cherry picked from commit 3745ce7aa8)
When a new process is launched it ensures that all files under its uid/
and uid/pid hierarchy are accessible by the user/group of that process.
If the directory already exists that means the access permissions have
been already set before, therefore we do not need to reset them again.
This also avoids a race between two processes in the same uid with one
process being launched and walking the uid/ directory while the other
process is being killed and changing the content of that directory. In
such a race the process walking uid/ might find the uid/pid directory of
the process being killed but by the time it tries to set its permissions
the directory might be removed because the process got killed. The
change eliminates the possibility of this race.
Bug: 192421915
Bug: 192512069
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I182298c36f6b0b4580ab59e440bd3aea16f5fbfe
Merged-In: I182298c36f6b0b4580ab59e440bd3aea16f5fbfe
In some rare cases, race happens between 2 processes in the same uid.
1. Process A is dying
2. system_server calls RemoveProcessGroup() for A
3. Zygote forks Process B with the same uid of A
4. system_server calls MkdirAndChown(uid) for B
5. system_server calls MkdirAndChown(uid, pid) for B
As 2 & 4/5 belong to different threads, 2 might happens before or after
step 4/5, or even in the middle of 4/5. In such a case, 4 or 5 will
fail, leaving process B in wrong (Zygote) group.
The uid dir is only created when the corresponding apps have been
launched at least once. It's reasonable to assume one of them is going
to be launched again. Deleting and recreating the uid dir just slows
down applaunch.
Introducing a new lock in libprocessgroup can also solve the race issue.
But that will slow down the applaunch further.
Therefore, reusing the uid dir is an optimized way to solve the race.
Ignore-AOSP-First: Freezer is not a public feature yet
Bug: 192512069
Bug: 168907513
Test: Kill corresponding apps and check the uid cgroupfs dir
Merged-In: I2e91088f21f45e4eda6c709a4af65ace7e135801
Change-Id: I2e91088f21f45e4eda6c709a4af65ace7e135801
In some platforms, setting a different cpuset (or remove it) and/or
uclamp setting is beneficial to both performance and power. Adding 2
separate profiles for vendor to override surfaceflinger scheduling
policies.
Bug: 170507315
Test: build and boot
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: Ib313fd67c6ccd701109c5683d8dbab9ecd1580d8
(cherry picked from commit 6d6b71e582)
The inner profile should print error message if needed.
Bug: 178070122
Test: Build
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I2d9d54e21fb064678feccdbae453a398806d51d6
Issue a warning about missing cpu/schedtune controller only if both of
them are missing.
Bug: 185437398
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I3a9d3c9a8c91c8d2c5346bcb431bb0407c64a811
Remove the vestigial llndk_library modules and replace them with
properties in the llndk clause of the implementation cc_library.
Bug: 170784825
Test: m checkbuild
Test: compare out/soong/build.ninja
Change-Id: Ie3a1bffcf29bb1b6747f7f708826c61bd43ba5a1
Memory cgroup controller is not used by high-end Android devices and is
disabled in Android kernels 5.10+, however Android Go devices still
require this controller.
Similarly schedtune controller is being replaced with cpu controller's
utilclamp feature, however some devices are using older kernels which
only support schedtune.
To prevent spamming logcat with errors we need a way to mark a
controller optional in such cases without removing it from
cgroups.json file.
Introduce "Optional" attribute to cgroup controller's cgroups.json
description to accomodate these cases. When an optional controller
fails to mount due to lack of support in the kernel it will log an
informational message without generating further errors.
Bug: 181866655
Test: boot and observe libprocessgroup messages in logcat
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ib5bcfdd8d338704f3f9d8b326d8ddd88b67915a1
this removes the (temporary) hard-coded path to a cgroup.freeze file
to be used for checking the presence of the cgroup v2 uid/pid hierarchy
for the app freezer. From now on, only the new API must be used (see the
implementation under CacheAppOptimizer).
Bug: 180056337
Test: built without errors
Change-Id: Ifd0bce81a540a86c0c74d3e52fbe88fb731a02e1
configure the cgroup v2 hierarchy for recovery mode, and create uid/pid
groups with attributes following the container cgroup directory.
Bug: 168907513
Test: verified correct pid migration in normal and recovery modes
Change-Id: Idc8b96b4db075383a6a2e523c241b0bc632c7030
With the new uid/pid hierarchy the search path looks into uid_0, which
is always present.
Bug: 168907513
Test: verified that the cgroup v2 hierarchy works correctly in normal
mode
Test: verified that the cgroup v2 hierarchy works correctly in recovery
mode
Change-Id: If33594e4891128148da64bed47e68fa74667013d
This reverts commit 088924af2a.
Bug: 168907513
Test: verified correct function of the cgroup v2 hierarchy in normal and
recovery mode
Change-Id: I6e9d21ebe832326ed5a5b2c356fe8363c1546a80
This path can be used for clients to verify freezer support on a
specific platform.
Bug: 168058155
Test: verified correct functioning with ActivityManager
Change-Id: Ie15feed274ccbbe31228ee98c50eab3f4dd479a7
This reverts commit 7707909ba2.
Bug: 179006802
Test: verified correct functioning of the freezer after reverting
Change-Id: I848146a18a0879010abf5b00e7081f2771059064
a1a0497984
Bug: 151660495
Test: verified proper boot in regular mode and proper working of adb in
recovery
Change-Id: I1276796e982fee932cdea7eb145f20b3f1b3463d
cc_test_host now all run in presubmit without any need for explicit TEST_MAPPING
Change-Id: I379ef754b4cb645976daedcd04eae58f2eb32a75
Test: presubmit
Bug: 177450457
The build system will soon require that symbol files describing APIs
across updatable components (e.g. across APEXes or across sytem/vendor)
have the ".map.txt" suffix. This will trigger the NDK API review in the
gerrit so that backwards incompatible changes are prevented.
Bug: N/A
Test: m nothing
Change-Id: I114563782f8e796365ca141eb5d22d2e203a7f55
If there are known fail pattern, we could disable printing logs to
reduce log spam. Use "LogFailures": true or "LogFailures": false.
Default will be true if not specified.
Bug: 178070122
Test: function works
Change-Id: Ia4081a10daf738294937f459f006fbcc3171481b
The following API was added for the API level 30 and beyond. Currently,
its existence is tested using the null check which is done regardless of
the min sdk version of the compilation unit. (which in turn required us
to mark the API symbol weak regardless of the min sdk version.)
* AGroupController_getFlags
Now, we have a better way of testing the API availability;
__builtin_available. The null check is replaced with the call to the
compiler-provided macro which determines if the code is running in a
version of OS where the API is known to exist.
Bug: 150860940
Bug: 134795810
Test: m
Change-Id: I5d17fc877c553c402a62485b61af574a54658a76
__ANDROID_API__ guards are removed in favor of __INTRODUCED_IN macros.
Currently, __INTRODUCED_IN macro does nothing for these headers (it's
meaningful only to the headers processed by versioner which are limited
to binic headers). The plan is to make the macros to tag the declaration
with the availability attribute. Then, when the min_sdk_version of a
caller is set to an API level that is older than the API level of the
APIs, the compiler will provide them as weak symbols and enforce that
calling the APIs are guarded with a runtime check.
For now, these guards are preventing from making a build system change
to let __ANDROID_API__ track the min_sdk_version property instead of the
sdk_version property. With the build system change, __ANDROID_API__ will
suddenly drop for the native modules where min_sdk_version <
sdk_version, which is the case when the modules are included in APEXes.
As a result, some new APIs will be unavailable at build-time. Dropping
the hand-written guards fixes the problem.
Bug: 163288375
Test: m
Change-Id: If1cc6b9af410f536abe6d777c22711209fa76530
This reverts commit 1414a0d4d8.
Reason for revert: reversions of CLs from http://b/174776875 removed dependencies for this CL, and made the freezer non-functional. This CL has to be reverted as well
Bug:174776875
Change-Id: Idbd9532374bb661330b3c7546bbdf086a046aba3
vendor_available modules were available to product modules.
However, not all vendor_available modules are required to be
available to product modules. Some modules want to be available only
to product modules but not vendor modules.
To cover the requirement, we separate product_available from
vendor_available.
vendor_available will not provide product available module.
Rename libcutils/include_vndk to libcutils/include_outside_system as
it provides the headers to the modules outside the system partition
including /product.
Bug: 150902910
Test: build
Change-Id: I791b5a6a1dc99442065debfce6fa0f54a335fcea
Migrate the freezer controller as an attribute for the uid/pid hierarchy
Bug: 168907513
Test: manually verified that the freezer behavior was as expected after
applying the enablers in ActivityManager
Signed-off-by: Marco Ballesio <balejs@google.com>
Change-Id: Ica2c4bfd20190fb2f2dc0a530eb47e1a8427c522
Current per-API level task profiles replace the latest task profiles
rather than overriding the diffs. This poses an issue when a new
feature is added which is applicable to older devices as well we
have to change all per-API level profiles. Change the per-API task
profile support to load the latest task profiles first and then override
with per-API task profiles, similar to how vendor task profiles override
system task profiles. This minimizes the changes we need to do to the
per-API level task profiles going forward and is more consistent with
how vendor task profiles work.
Bug: 170507876
Test: boot with per-API task profiles
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I08cc4b374cede7363cf96a30ac96971d49bb7847
Enable the uid/pid hierarchy for all groups when using cgroup v2. Mount
the hierarchy under the cgroup v2 root. Make sure that all files under
the hierarchy are accessible by the system user.
Test: booted the device, tested the freezer cgroup, manually verified
the working of the freezer from logs and by checking statuses of
processes.
Bug: 168907513
Test: Booted the device, verified no regressions on process group access
Change-Id: I73f3e767d377902af6e12facb503b9136fb39e08
When task profiles changes happen, devices released under older API
levels might have to use the same profiles as before. This might be
due to for missing kernel features or some other reasons. Add support
for per-API task profiles to accommodate this scenario. With this
mechanism when ro.product.first_api_level is non-empty, the system
looks for /system/etc/profiles/task_profiles_<api level>.json file
and uses it if it exists. If ro.product.first_api_level is not defined
or per-API task profiles file does not exist the system falls back to
the default /system/etc/profiles/task_profiles.json file.
As before, these task profiles can be competely overwritten using
/vendor/etc/task_profiles.json if needed.
Bug: 172066799
Test: boot with per-API task profiles
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I1671b341b3a0fb5e99d0b0788315c61088326b09
Put tasks into a subgroup so that we can set things up e.g. soft cpu
bandwidth and/or uclamp.
Bug: 170507876
Bug: 171740453
Test: boot and check cgroup
Change-Id: Iaeb081bc4f214aa23eb281e0c28a81ea581bb4d1