android_system_core/libprocessgroup
Li Li d0464b0c01 libprocessgroup: Do not remove uid cgroups directory
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
2021-07-02 10:27:00 -07:00
..
cgrouprc Replace llndk_library with llndk clause in cc_library 2021-04-21 19:13:41 -07:00
cgrouprc_format [LSC] Add LOCAL_LICENSE_KINDS to system/core 2021-02-19 12:59:05 -08:00
include/processgroup libprocessgroup: remove hardcoded freezer path 2021-02-25 23:39:52 +00:00
profiles task_profiles.json: add taskprofile for SurfaceFlinger 2021-06-15 15:18:23 -07:00
setup libprocessgroup: introduce optional attribute for cgroup controllers 2021-03-11 17:42:30 +00:00
Android.bp [LSC] Add LOCAL_LICENSE_KINDS to system/core 2021-02-19 12:59:05 -08:00
cgroup_map.cpp Cgroup APIs are guarded 2021-01-12 20:50:27 +09:00
cgroup_map.h Fix IsUsable to check for each controller separately 2019-06-26 11:35:11 -07:00
OWNERS Add new owners to various sub-projects. 2020-12-11 12:45:45 -08:00
processgroup.cpp libprocessgroup: Do not remove uid cgroups directory 2021-07-02 10:27:00 -07:00
sched_policy.cpp libprocessgroup: Fix warnings when legacy schedtune cgroup is absent 2021-04-26 09:28:08 -07:00
task_profiles.cpp Merge "libprocessgroup: remove failure log for aggregate profiles" 2021-05-14 22:06:37 +00:00
task_profiles.h libprocessgroup: Add control of printing log in WriteFileAction 2021-01-28 03:26:18 +00:00