Commit graph

359 commits

Author SHA1 Message Date
Carlos Galo
456a4066f8 Merge "Updating owners of libprocessgroup" am: ce318e8818 am: 9b2d8d218a am: 7a7d614d7a
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2359681

Change-Id: I495cd314fd256095440557e6507b68d4fa4a4d29
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-16 02:02:13 +00:00
Carlos Galo
ce318e8818 Merge "Updating owners of libprocessgroup" 2022-12-16 00:02:01 +00:00
Carlos Galo
8ceaf0c636 Updating owners of libprocessgroup
Adding tjmercier@google.com and carlosgalo@google.com, and removing
ccross@google.com, in the OWNERS file. Adding buganizer component to
OWNERS.

Bug: 262738363
Test: N/A
Change-Id: I7f8cdc513232b46eb341f3c98f64dfb1d9bd9d7a
2022-12-15 19:12:33 +00:00
Inseob Kim
110cd77b30 Don't retry kill if cgroups isn't available
It makes no sense, because there are no cgroup procs file.

Bug: 257264124
Test: atest MicrodroidBenchmarkApp
Change-Id: I4e3a118d2237afc46aa8fbcbad055afb7d56f464
2022-12-15 15:29:38 +09:00
Jiakai Zhang
70d34f01a3 Merge changes I52e778d1,I33f4d1d2
* changes:
  Rename "Dex2OatBootBackground" to "Dex2OatBackground".
  Add task profile "Dex2OatBackground".
2022-12-12 17:37:42 +00:00
Jiakai Zhang
180a51d6f3 Rename "Dex2OatBootBackground" to "Dex2OatBackground".
Bug: 261557677
Change-Id: I52e778d13cffcae4212acb05ef2bd62b827fbaf3
Test: Presubmit
Merged-In: I52e778d13cffcae4212acb05ef2bd62b827fbaf3
(cherry picked from commit 473f03bfd9)
2022-12-12 16:28:11 +00:00
Jiakai Zhang
38e9373a4b Add task profile "Dex2OatBackground".
Bug: 261557677
Test: Presubmit
Change-Id: I33f4d1d2270da82cf90a772ef52b450bcecafec2
Merged-In: I33f4d1d2270da82cf90a772ef52b450bcecafec2
(cherry picked from commit ecfbf9c6f4)
2022-12-12 16:27:15 +00:00
TreeHugger Robot
3ece2dbcb1 Merge "Rename "Dex2OatBootBackground" to "Dex2OatBackground"." 2022-12-12 16:02:08 +00:00
Treehugger Robot
4b960f5ce0 Merge "Kill services even when cgroups is disabled" am: 5c3e24816d am: 18a41fbf65 am: 916f52d74d
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2305473

Change-Id: I19814da1b59fc2d82949f992d1b03caf44d4dd11
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-12 03:11:13 +00:00
Inseob Kim
a049a9928b Kill services even when cgroups is disabled
process_cgroup_empty_ is used to indicate that a service is already
killed or not. If cgroup support lacks, services cannot be killed
because process_cgroup_empty_ is always true.

This change fixes it by not assigning process_cgroup_empty_ as true.
Instead, make KillProcessGroup send signals even when cgroup is
disabled. Also DoKillProcessGroupOnce() is updated so it returns a number of killed processes, excluding already dead processes. This behavior agrees with its name (DoKillProcessOnce), and it prevents regression upon missing cgroups, because kill(-pgid) will always
"succeed" so KillProcessGroup will loop even when all processes are
already dead.

Bug: 257264124
Test: boot microdroid, see services are terminated
Change-Id: I19abf19ff1b70c666cd6f12d0a12956765174aaa
2022-12-12 01:19:26 +00:00
Jiakai Zhang
473f03bfd9 Rename "Dex2OatBootBackground" to "Dex2OatBackground".
Bug: 261557677
Change-Id: I52e778d13cffcae4212acb05ef2bd62b827fbaf3
Test: Presubmit
Ignore-AOSP-First: Will cherry-pick as soon as the CL is merged.
2022-12-09 23:51:03 +00:00
Jiakai Zhang
ecfbf9c6f4 Add task profile "Dex2OatBackground".
Bug: 261557677
Test: Presubmit
Ignore-AOSP-First: Will cherry-pick as soon as the CL is merged.
Change-Id: I33f4d1d2270da82cf90a772ef52b450bcecafec2
2022-12-06 15:51:38 +00:00
Nikita Ioffe
20e253b40c Merge "init: skip cgroup/task_profiles configuration if cgroups are disabled" am: 537ab23872 am: 9bd7375aab am: e28c9185fb
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2263261

Change-Id: I0f74ba4e9b9ce878a8a7cb79d0c0c99170c8dc8b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-24 09:09:43 +00:00
Nikita Ioffe
c2b1654c11 init: skip cgroup/task_profiles configuration if cgroups are disabled
We are planning to remove cgroups from the Micrdroid kernel, since the
entire VM belongs exclusively to a single owner, and is in the control
of the cgroups on the host side.

This patch expoxes CgroupAvailable API from libprocessgroup, and changes
init to query the CgroupAvailable API before doing any
cgroups/task_profiles related work.

Bug: 239367015
Test: run MicrodroidDemoApp
Test: atest --test-mapping packages/modules/Virtualization:avf-presubmit
Change-Id: I82787141cd2a7f9309a4e9b24acbd92ca21c145b
2022-10-21 13:14:23 +01:00
Treehugger Robot
f0b7d34133 Merge "libprocessgroup: Improve error messages" am: 29752d276e am: 0ad558c55a am: b4048a5693
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2252953

Change-Id: I6a18fd7a93f9f7c7f198e07851be0d40032c4bfc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-13 17:51:24 +00:00
Bart Van Assche
7a952617f6 libprocessgroup: Improve error messages
Change two PLOG() statements into LOG() statements since PLOG() should
only be used if errno has been set. Make it easier to find the code that
logs an error message.

Bug: 213617178
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I73443f3adb7d7ba3fc0d39a55777f0b132529fbd
2022-10-12 13:48:52 -07:00
T.J. Mercier
c41a6348b3 Merge "Revert "Revert "libprocessgroup: Add support for SetUserProfiles""" 2022-10-05 16:11:22 +00:00
T.J. Mercier
673da5b972 Revert "Revert "libprocessgroup: Add support for SetUserProfiles""
This reverts commit aee11b0a3d.

This change was originally reverted because its only user was reverted
under b/243096961 at ag/19679188. We bring it back now with a fixed user.

Bug: 236708592
Bug: 148425913
Ignore-AOSP-First: Topic with AMS changes which is developed on git_master

Change-Id: I2a8ae0d9faabe7950b758a09870d128889be4d0a
2022-09-27 17:42:19 +00:00
Jiyong Park
eb7ec7b9e8 Annotate symbols correctly
Currently, tagging a symbol with #apex (# systemapi or # llndk) is not
required when the symbol is in a non-NDK library. However, this is
considered dangerous because such a symbol will automatically be
promoted to NDK APIs when the library is promoted to an NDK library.
When that happens, the native API council won't be able to notice the
promotion because promoting a non-NDK library into an NDK library
doesn't require an update of the map.txt file, but Android.bp only.

To prevent that, we should mandate those tags for Mainline APIs
regardless of whether the library the API belongs to is an NDK library
or not.

Upcoming changes in build/soong will enforce this. This change is to
prepare for the enforcement.

Note that this is a build-time only change. There's no behavior change
at runtime.

Bug: 184712170
Test: m
Change-Id: I769c5318e0cfd092f2f2b368f1a860065c79818f
2022-09-26 22:14:43 +09:00
Bart Van Assche
9c0fcbb0f7 libprocessgroup: Add I/O scheduler attributes to task_profiles.json
The differences between the v1 and v2 hierarchies are as follows:
* Different mountpoints. In Android the blkio v1 hierarchy has
  /dev/blkio as top directory while the v2 hierarchy has /sys/fs/cgroup
  as top directory.
* Different directory structure. In Android there are two directories in
  the v1 blkio hierarchy (. and background) while in the v2 hierarchy
  there is one subdirectory per process and per task.
* Different controller names. The name of the blkio controller in the v1
  hierarchy is "blkio" while it is "io" in the v2 hierarchy.
* In the v1 hierarchy the NormalIoPriority policy is applied at process
  creation time but that policy is not applied at process creation time
  if the blkio controller exists in the v2 hierarchy.

Prepare for migration of the blkio controller to the v2 hierarchy by
adding the blkio v2 attributes in task_profiles.json. All these
attributes have been marked as optional because:
* The "io" controller does not exist in the v1 hierarchy.
* Which attributes can be applied depends on the I/O scheduler that has
  been selected (CFQ, BFQ, ...).

This patch causes the following warnings to appear in the logs of
devices that mount the blkio controller in the v1 hierarchy:
 W libprocessgroup: Controller io is not found
 W libprocessgroup: Controller io is not found
 W libprocessgroup: Controller io is not found
 W libprocessgroup: SetAttribute: unknown attribute: CfqGroupIdle
 W libprocessgroup: SetAttribute: unknown attribute: CfqWeight
 W libprocessgroup: SetAttribute: unknown attribute: BfqWeight

This patch restores a subset of aosp/1962326 and prepares for the
migration of the blkcg controller to the cgroup v2 hierarchy.

Bug: 213617178
Change-Id: Ia7b117bc777239b416e2ac268308e634b018144d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-08-25 14:01:01 -07:00
Bart Van Assche
f32c4ecebb libprocessgroup: Provide SetProcessProfiles() and SetTaskProfiles() alternatives
Provide alternative versions that do not force callers to create
std::string objects. This patch has the intended side-effect that all
callers that pass a {string} initializer list to the 'profiles' argument
now call an std::initializer_list<> overload instead of the const
std::vector<std::string>& overload.

Additionally, add std::function<> arguments instead of calling
ExecuteForProcess() or ExecuteForTask() directly to make it easier to
write unit tests for SetTaskProfiles() and SetProcessProfiles().

Bug: 213617178
Change-Id: Ica61e944a66a17178ee43a113b8ca082f7eb834b
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-08-19 07:06:30 -07:00
Bart Van Assche
d0b8ce2115 libprocessgroup: Make GetProfile() and GetAttribute() more efficient
Do not force callers to create an std::string object. This patch
implements the following advice from go/totw/1: "Google’s preferred
option for accepting such string parameters is through a string_view."
Use std::less<> as comparison type to prevent that std::string_view
objects have to be converted into std::string objects for lookups in
std::map<>.

Bug: 213617178
Change-Id: I08125a02220a8c003d9202a7e177be776c3b9829
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-08-19 07:06:30 -07:00
Bart Van Assche
a823bee9d3 libprocessgroup: Switch from gnu++-17 to gnu++-20
This change enables headers like <span>. Inside the <span> header file
file the following guard makes its functionality unavailable when
building with std=gnu++-17:

 #if _LIBCPP_STD_VER > 17
 [ ... ]
 #endif

Bug: 213617178
Change-Id: I5c40708ea196ab112990b5ca6fae9370b75f8752
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-08-18 12:34:21 -07:00
Bart Van Assche
ccaac4ad21 libprocessgroup: Fix a log message
Fix the function name in a log message inside CgroupSetup().

Bug: 213617178
Change-Id: I897c831f5e53093df2664e0e8ceefadf9a89369c
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-08-08 11:07:02 -07:00
Suren Baghdasaryan
fd933786d8 libprocessgroup: Handle temporarily non-empty group removal failure
Cgroup removal fails with EBUSY if there are active processes or threads
still alive in the cgroup. Occasionally a thread or a process might be
stuck in an interruptible sleep and take some time during exit. In such
cases attempts to remove the cgroup it belongs to will fail. This
results in occasional leftover cgroups. These empty unused cgroups
consume memory.
Ensure RemoveProcessGroup always retries and increase the retries to
keep trying for 2 secs before giving up. In majority of cases only a few
retries are needed but in rare cases a thread can be blocked for longer
time, therefore the number of retries is set large enough to cover them.

Bug: 233319780
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I2e4bb1f7b7e19c904c85faea7bbabbfdef9c8125
2022-06-03 21:15:14 +00:00
Victor Hsieh
29b26409e4 Rename VMCompilationPerformance to SCHED_SP_COMPUTE
There isn't any reason to keep the VMCompilationPerformance special, so
rename to a more generic, reusable name.

One day we may support whatever-purpose VMs using other generic
profiles.

Bug: 231437770
Test: TH
Change-Id: Id7e78ba4d6ea0dc415ed0bc1f4bdf051f7e7fe05
2022-05-23 11:06:09 -07:00
Victor Hsieh
c9e0f79593 Make VMCompilationPerformance an aggregated profile with default
The VMCompilationPerformance profile is used to run Isolated Compilation
in a Protected VM, normally during the device idle, where relevant
APEXes are staged.

The original VMCompilationPerformance introduced in aosp/2060891 does
not have any specific definition and requires vendors to customize it.
This change re-defines it as an aggregated profile with a default set of
existing profiles, so that performance can be reasonable by default.

This profile may be renamed to a more generic name later, e.g.
"SCHED_SP_COMPUTE".

Bug: 231437770
Test: Run `composd_cmd test-compile` on a local device.
      Before: 1m50s +/- 10s (with whatever that's default)
      After: 1m25s +/- 5s
Change-Id: Ib8cd65782c818474fb129efbd9ef9a3e23ad1eb3
2022-05-16 14:09:37 -07:00
Suren Baghdasaryan
4345f3f50a libprocessgroup: Add a function to remove only empty process groups
When system_server and zygote crash or get killed, all apps also get
killed but their process groups are left empty. Provide a function to
remove all empty process groups so that init can purge them when this
even happens.

Bug: 228160715
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ife38ca021e80cd38106f218ae13183e8c2631bf0
2022-04-29 10:17:17 -07:00
Jiyong Park
cc9932b291 Fix: null name is added when using android_set_process_profiles
This CL fixes a bug that null names are passed when profiles are set
via android_set_process_profiles. This is because the `profiles_` vector
was initialized with the number of task profiles and then we append the
actual task profile names to the vector. As a result, when {"a", "b"}
was given, the vector ended up having {"", "", "a", "b"}. Fixing this by
correctly using reserve().

Bug: N/A
Test: m
Change-Id: I28d6c2e891b01a2d3a8a88d9d0652fe0dbffac96
2022-04-20 17:11:42 +09:00
Rick Yiu
a18660fb82 Merge "Add profile for VM compilation" 2022-04-20 00:12:59 +00:00
Rick Yiu
a38d83440a Add profile for VM compilation
Add VMCompilationPerformance.

Bug: 223790172
Test: build pass
Change-Id: I27b939ddee4b039ba3037195a4f23c823bf9c8ff
2022-04-19 14:27:48 +08:00
Jiyong Park
8bf5940012 c wrapper for SetProcessProfiles
The wrapper is to call SetProcessFiles (C++ API) from crosvm via FFI.

Bug: 223790172
Bug: 216788146
Test: m

Change-Id: If342ca0d19deb1cb7ee581bba2cc543385199cbe
2022-04-15 00:05:34 +09:00
Inseob Kim
538fc1fab1 Reland "libprocessgroup: return false on failure"
This reverts commit c109b13b5a.

Reason for revert: uploading with a CL fixing the broken test

Change-Id: I97a0a49ded8bc17c2d70c82f8e48fce09e49b2bd
2022-04-13 18:50:12 +00:00
Jiyong Park
c109b13b5a Revert "libprocessgroup: return false on failure"
This reverts commit 9818f95c9e.

Reason for revert: broke some tests. b/228910109

Change-Id: I2d5f837969e433b765de89d899fc172ceeef27a6
2022-04-12 19:48:04 +00:00
Jiyong Park
9818f95c9e libprocessgroup: return false on failure
SetProcessProfiles and SetTaskProfiles now correctly return false on
failure.

Bug: N/A
Test: settaskprofile <some_pid> <non_existing_name>

Change-Id: I7936303e71cd073c0ba713109328b960c66bdacc
2022-04-11 01:51:23 +09:00
Bart Van Assche
54136f8bf4 Add a comment to explain how errno is set
Since it is nontrivial which modifies `errno` is modified in
ExecuteForTask(), add a comment that explains this.

Bug: 213617178
Test: Compile-tested only.
Change-Id: I49ce9c8054fdc59e61b2e5f9ffe6f16743a94401
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-31 11:30:03 -07:00
Wei Wang
921d266c81 Merge "Revert "Migrate the blkio controller to the v2 cgroup hierarchy"" 2022-03-30 16:02:45 +00:00
Bart Van Assche
159563561a Revert "Migrate the blkio controller to the v2 cgroup hierarchy"
Revert "Migrate the blkio controller to the cgroup v2 hierarchy"

Revert "Migrate the blkio controller to the cgroup v2 hierarchy"

Revert "Migrate the blkio controller to the cgroup v2 hierarchy"

Revert submission 1962326-blkio-cgroup-v2

Reason for revert: This set of changes is suspected to have caused a redfin boot time regression for the git_tm-dev branch.

Reverted Changes:
Id18d876b6:Migrate the blkio controller to the cgroup v2 hier...
I7dfa52136:Migrate the blkio controller to the v2 cgroup hier...
I5336167be:Migrate the blkio controller to the cgroup v2 hier...
I3f0131d8f:Migrate the blkio controller to the cgroup v2 hier...
Ibb62b2d4d:Migrate the blkio controller to the cgroup v2 hier...

Bug: 227382327
Bug: 227389363
Change-Id: I6c8183ed1c3044c8947c4fca07799deff98101b3
2022-03-30 14:58:20 +00:00
Bart Van Assche
8eb7a6edea Revert "Fix the cgroup directory owner in createProcessGroupInternal()"
This reverts commit 812d7698d8.

Reason for revert: this patch is suspected to have caused b/227337425.

Bug: 227337425
Bug: 227331047
Change-Id: I4ae26ccf61ad7c63dacc85da878ba0920736951c
2022-03-30 01:40:50 +00:00
Bart Van Assche
07f6c82a4c Migrate the blkio controller to the v2 cgroup hierarchy
This patch preserves the following parameter values:
* Foreground BFQ weight:      100
* Foreground CFQ group_idle:    0
* Foreground CFQ weight:     1000
* Background BFQ weight:       10
* Background CFQ group_idle:    0
* Background CFQ weight:      200

The foreground BFQ weight in task_profiles.json is the default BFQ
weight. From
https://www.kernel.org/doc/Documentation/block/bfq-iosched.txt:
"weight (namely blkio.bfq.weight or io.bfq-weight): the weight of the
group inside its parent. Available values: 1..10000 (default 100). The
linear mapping between ioprio and weights, described at the beginning
of the tunable section, is still valid, but all weights higher than
IOPRIO_BE_NR*10 are mapped to ioprio 0."

Bug: 213617178
Test: Booted Android in Cuttlefish and ran the following test:
Test: adb -e shell cat /sys/fs/cgroup/*/*/io.bfq.weight | sort | uniq -c
Test: 22 default 10
Test: 98 default 100
Change-Id: I7dfa521363a316592852fecce9192708c7a90514
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-28 20:56:15 +00:00
Bart Van Assche
d31602063e Canonicalize cgroup paths
Make it possible to verify whether the memory cgroup controller has been
mounted in the v2 hierarchy by comparing its path with the cgroup v2
path. This patch changes the path of cgroup controllers mounted in the
v2 hierarchy from /sys/fs/cgroup/. into /sys/fs/cgroup (no trailing /.).

Bug: 213617178
Test: Added debug code that prints the path for the memory cgroup in the
Test: v2 hierarchy.
Change-Id: I8a2764a6daae84caecf360a918eab62778e3f546
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-25 16:11:45 -07:00
Bart Van Assche
ebea9097a8 Micro-optimize MergeCgroupToDescriptors()
Introduce a local variable for an expression that occurs twice. Use
string append instead of string concatenation because the former is more
efficient.

Bug: 213617178
Test: Compile-tested only.
Change-Id: I6e8b9d63b10accb220216dc484dffd18f5c54ce7
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-25 16:11:10 -07:00
Bart Van Assche
9b5a232083 Fix support for optional cgroup attributes
The Linux kernel returns error code EACCES (Permission denied) if either
a cgroup attribute does not exist or if the process that is trying to
write into a cgroup attribute does not have permission to write. In
other words, it is not possible to tell the difference between these two
scenarios by checking the value of 'errno'. Hence this patch that adds a
stat() call to check whether or not a cgroup attribute exists. This
patch makes lines like the following disappear from logcat for optional
cgroup attributes:

03-22 23:16:04.816   616   649 E libprocessgroup: Failed to write '0' to /sys/fs/cgroup/./uid_10077/p
id_1695/io.group_idle: Permission denied

Bug: 213617178
Test: Booted Android in Cuttlefish and inspected logcat.
Change-Id: I6e041dfc34a52c9bdb75a8c70d99ad79b06eee06
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-25 14:37:16 -07:00
Bart Van Assche
812d7698d8 Fix the cgroup directory owner in createProcessGroupInternal()
Without this patch attempts to modify the blkio cgroup attributes by
/system/bin/mediaserver fail as follows:

03-23 09:27:59.542   517  1811 E libprocessgroup: Failed to write '100' to /sys/fs/cgroup/./uid_1013/pid_517/io.bfq.weight: Permission denied

This is because the mediaserver process is started as user 'media',
because the mediaserver process is not in the system group and hence
does not have permission to write into a directory with the following
owner, group and permissions:

vsoc_x86_64:/ # ls -ld /sys/fs/cgroup/./uid_1013/pid_517/io.bfq.weight
-rwxrwxr-x 1 system system 0 2022-03-23 09:27 /sys/fs/cgroup/./uid_1013/pid_517/io.bfq.weight

Bug: 213617178
Test: Booted Android in Cuttlefish and inspected logcat.
Change-Id: I788acc9a137ae29898177f492cae2f954a9c811c
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-25 07:32:56 -07:00
Bart Van Assche
55a9b1e22d Fix the stat() return value check in createProcessGroupInternal()
From the stat() man page: "RETURN VALUE On success, zero is returned.
On error, -1 is returned, and errno is set appropriately." Hence check
for failure by checking whether the return value is negative instead of
1.

Bug: 213617178
Test: Booted Android in Cuttlefish and inspected logcat.
Fixes: 9e628a6b42 ("libprocessgroup: fix uid/pid hierarchy for recovery mode")
Change-Id: I774d142058b083403d32b3f6aae4a4b3de00192c
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-24 15:08:16 -07:00
Bart Van Assche
4c95712c9f Use the proper memcg directory for the v2 hierarchy
When using the v1 hierarchy per process memcg directories exist under
/dev/memcg/apps. When using the v2 hierarchy per process memcg
directories exist under /sys/fs/cgroup. Hence this patch that selects
the proper top-level directory depending on the memcg version.

Bug: 213617178
Test: Verified Android operation inside the Cuttlefish emulator.
Change-Id: I7373fb407cb6ad2b1181579691ff54886fd36c24
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-23 14:12:43 -07:00
Bart Van Assche
4f2e62913d Enable the memory_recursiveprot mount option
Enable the memory_recursiveprot mount option for v2 cgroups because the
v2 memcg documentation mentions the following: "Recursively apply
memory.min and memory.low protection to entire subtrees, without
requiring explicit downward propagation into leaf cgroups.  This allows
protecting entire subtrees from one another, while retaining free
competition within those subtrees. This should have been the default
behavior but is a mount-option to avoid regressing setups relying on the
original semantics (e.g. specifying bogusly high 'bypass' protection
values at higher tree levels)."

Source: https://www.kernel.org/doc/Documentation/admin-guide/cgroup-v2.rst

Bug: 213617178
Test: Verified this change inside the Cuttlefish emulator.
Change-Id: Iecd86109d9ecb9d3354f9d28577b147edf7c50a8
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-23 10:37:26 -07:00
Bart Van Assche
bc077ff110 Add support for memcg v2 attributes
Some but not all memcg v1 attributes exist in the v2 hierarchy. The
following information comes from Shakeel Butt and Kamil Yurtsever,
"cgroup v2 migration at Google", Linux Plumbers Conference 2018
( https://lpc.events/event/2/contributions/204/attachments/143/378/LPC2018-cgroup-v2.pdf ):

         v1                    v2
-------------------------- ----------
memory.limit_in_bytes      memory.max
memory.soft_limit_in_bytes memory.low

Add support for cgroup attributes that have different names in the v1
and v2 hierarchies. Also add those memcg attributes that are used in
lmkd.

Bug: 213617178
Test: Tested lmkd with v1 and v2 memcg.
Change-Id: Ia5c5f02974f3b783d5cdaad85b33169ced8db55f
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-17 14:18:14 -07:00
Bart Van Assche
59af680023 Add support for optional cgroup attributes
Cgroup attributes like io.weight or io.bfq.weight only exist if the
corresponding I/O scheduler has been loaded. Hence add support for
ignoring failures to write to a cgroup attribute that does not exist.

Bug: 213617178
Test: This patch has been tested in combination with patch "Migrate the blkio controller to the cgroup v2 hierarchy".
Change-Id: I5debafabc4dd430a1b98ea343bf3740c764edcc3
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-16 19:55:46 +00:00
Bart Van Assche
32a9b1c320 Use uid_t for user IDs and gid_t for group IDs
This patch makes the intent of the code more clear without changing any
functionality since uid_t and gid_t are both aliases for uint32_t on
Android systems. See also
https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/types.h

Bug: 213617178
Test: Compile-tested only.
Change-Id: Ib5012456a7357e79368f00e71e9a280fd6f96063
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-15 23:02:20 +00:00
Bart Van Assche
990194fe2f Fix cgroup directory permissions
Cgroup attributes are set from three different contexts:
(1) From the process that creates the cgroup directories. These
    processes are /system/bin/init, zygote and zygote64.
(2) From the created process. Some but not all created processes have
    user ID and/or group ID 'system'.
(3) The system_server process modifies certain cgroup attributes from
    other processes.

Allow all processes from the system group, including system_server, to
modify cgroup attributes from other processes. As one can see in
init.rc, that file includes commands for granting the system group
write permission for blkcg attributes. See also
https://cs.android.com/android/platform/superproject/+/master:system/core/rootdir/init.rc

Bug: 213617178
Test: Verified in the Cuttlefish emulator that this patch makes the
Test: io.bfq.weight write errors disappear from logcat.
Change-Id: Idbfb49c25afec12b21daea7a17db5322bc981ff0
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-15 23:02:20 +00:00
Bart Van Assche
f508ede763 Simplify cgroups.json
cgroups.json causes the following changes to be applied twice to
/sys/fs/cgroup: change user ID to system, change group ID to system and
change mode to 0755. Apply these settings once instead of twice.

Bug: 213617178
Test: Ran ls -ld /sys/fs/cgroup in Cuttlefish.
Change-Id: Ieb953c186c027b989599cbbaa70a9c9324678cdf
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-15 23:02:19 +00:00
Wei Wang
a323e0233d Merge "Support process path for WriteFileAction" 2022-03-01 00:06:57 +00:00
Rick Yiu
9221b1eeae Support process path for WriteFileAction
Currently, there is no distinguish between SetTaskProfiles and
SetProcessProfiles in WriteFileAction because they use the same task
path. Add ProcFilePath attribute so that WriteFileAction could use
a separate path for process in SetProcessProfiles.

Bug: 218684257
Test: function works
Change-Id: I004b8c8799240c54f1ef1fed0566fa5057341cf4
2022-02-26 12:38:03 +00:00
Bart Van Assche
f096bd2d24 Make task profiles easier to debug
Add support for querying the task profile and action names at runtime.
Log more information with verbose logging enabled. The additional
logging statements make it easier to verify whether changes in
task_profiles.json work as expected.

Bug: 213617178
Test: Booted Android in Cuttlefish.
Change-Id: I175e46d142bb015732b135952fdbeb9986f20ee3
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-18 03:06:30 +00:00
Bart Van Assche
4c99e96e2b Introduce interface class IProfileAttribute
This patch does not change any functionality but makes it easier to add
unit tests in a later patch.

Bug: 213617178
Test: Compile-tested only.
Change-Id: I6fbbb3297795c9d7ece8fb3263b3a9b0e5115b18
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-15 22:31:11 +00:00
Bart Van Assche
6e814b0eb2 Make two error messages more detailed
Provide context information to make it easier to map error messages to
the source code that reported these error messages.

Bug: 213617178
Test: Booted Android in Cuttlefish and verified the error messages in logcat.
Change-Id: I22e6d91476d91dcf32bafe5ead922e5652136584
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-15 00:09:34 +00:00
Bart Van Assche
6856cfcb21 Use the 'override' keyword where appropriate
This patch implements the following advice from the Google C++ Style
Guide: "Explicitly annotate overrides of virtual functions or virtual
destructors with exactly one of an override or (less frequently) final
specifier. Do not use virtual when declaring an override. Rationale: A
function or destructor marked override or final that is not an override
of a base class virtual function will not compile, and this helps catch
common errors. The specifiers serve as documentation; if no specifier is
present, the reader has to check all ancestors of the class in question
to determine if the function or destructor is virtual or not."

Bug: 213617178
Test: Booted Android in Cuttlefish.
Change-Id: Iabe7ecd91a2c09a77922c60ff4a00314da509d4a
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-15 00:09:34 +00:00
Bart Van Assche
8923d72252 Micro-optimize CgroupMap::ActivateControllers()
The C++ string concatenation operator is inefficient because it always
allocates a new string, even in cases where std::string::apppend() does
not allocate a new string. Hence this patch that replaces string
concatenation with a call to std::string::append().

Bug: 213617178
Test: Booted Android in Cuttlefish.
Change-Id: I79bdb89e957d3cfb40e48ef00c3e5576b4f533a5
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-15 00:09:34 +00:00
Bart Van Assche
20d59bd21b Make class SetTimerSlackAction easier to maintain
Unify the Darwin and Linux class declarations. Move all #ifdefs for this
class into the .cpp file. This patch does not change any functionality.

Bug: 213617178
Test: Booted Android in Cuttlefish.
Change-Id: I6a3cedc75c2dbf8aa062edda76cae9959767a763
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-15 00:09:34 +00:00
Suren Baghdasaryan
f3bdac78a0 libprocessgroup: Add fd caching support for SetProcessProfiles
Process profiles operating on paths that do not depend on pid or uid of
the process can cache the fd of the file they are operating on. Add
support for fd caching similar to how SetTaskProfiles caches the fd
of the file it needs to write to.

Bug: 215557553
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ie73ebcbbf1919d90409f40c1f6b08743f4edf97c
2022-01-25 00:05:34 +00:00
Suren Baghdasaryan
c2ee2e5774 libprocessgroup: Move fd caching code into FdCacheHelper
Refactor file descriptor caching code and move it into FdCacheHelper
because later on when we introduce fd caching for SetProcessProfiles
the children of CachedFdProfileAction become different enough that
sharing the same parent becomes a hindrance.

Bug: 215557553
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: If3812a0090c81a29e25f0888b0511cfaf48edea3
2022-01-25 00:05:24 +00:00
Wei Wang
77ad7c798a libprocessgroup: fall back to cpuset in get_sched_policy
Since vendor has a way to override the group cpu/schedtune setup, we
cannot assume the group will always return valid data. This CL let
get_sched_policy to fallback to cpuset if no valid data found in
cpu/schedtune cgroup. In longer term, we should find a way to cache the
group or app's process state in framework other than relying on reading
cgroup back.

Test: /data/nativetest64/libcutils_test/libcutils_test
Bug: 210066228
Signed-off-by: Wei Wang <wvw@google.com>
Merged-In: I8b4396365a7fc2d93e3a22746195585c140eef3c
Change-Id: I8b4396365a7fc2d93e3a22746195585c140eef3c
(cherry picked from commit c8c0b5415c14af56277f5e543ebff5fbba7fb7b2)
2021-12-14 10:56:34 -08:00
Rick Yiu
9dfff25365 Merge "libprocessgroup: Use WriteStringToFd for WriteFileAction" 2021-12-11 00:17:55 +00:00
Rick Yiu
d4c53518fe libprocessgroup: Use WriteStringToFd for WriteFileAction
Using WriteStringToFile will hold kernfs_mutex which is a big lock,
so use WriteStringToFd instead. Besides, also support fd cache for it.

Bug: 206970384
Test: build pass
Change-Id: Id79f9e1095f52079393c58edb9a4d526f4cc6b5e
2021-12-10 11:46:26 +08:00
Rick Yiu
91ce8bd935 Add a profile for OTA
Add an aggregated profile, OtaProfiles, for OTA process.

Bug: 199006579
Test: build pass
Change-Id: Ie6d5c593096d6ca77cdd8e3765b21bfcfd6641a5
2021-12-09 01:06:59 +00:00
Suren Baghdasaryan
8e9beea947 Merge "libprocessgroup/tools: Add settaskprofile command-line tool" 2021-11-10 17:18:41 +00:00
Suren Baghdasaryan
d48d7c8150 libprocessgroup/tools: Add settaskprofile command-line tool
Add a command-line tool to apply task profile(s) to a given thread.

Test: taskprofile $pid ProcessCapacityHigh; grep cpuset /proc/$pid/cgroup
Test: taskprofile $pid ProcessCapacityNormal; grep cpuset /proc/$pid/cgroup
Bug: 204808810
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I1c13731f7a9a1161f36e27436ee104964aacbfd0
2021-11-09 22:35:51 +00:00
Suren Baghdasaryan
9e3ace52bb libprocessgroup: Add CgroupGetControllerFromPath API function
Add new CgroupGetControllerFromPath function to retrieve the name of the
cgroup using a file path. If the file does not belong to any cgroup, the
function returns false.

Bug: 191283136
Test: build and boot
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic17a474cb25a80a3339b33ed8bc27b07af053abb
2021-11-08 21:24:33 +00:00
Suren Baghdasaryan
43293deffe Merge "libprocessgroup: Prevent error spam when tests disable all cpus in a cpuset" 2021-10-26 16:23:24 +00:00
Suren Baghdasaryan
ec88556460 libprocessgroup: Prevent error spam when tests disable all cpus in a cpuset
UserLifecycleTests test disables all Little cores in the course of the
test, which causes attempts to add a process into /dev/cpuset/restricted
cpuset cgroup to fail with ENOSPC error code, indicating that a process
is joining a cpuset cgroup with no online cpus. Current libprocessgroup
implementation will log an error on each such occurrence, which spams
the logs and makes it hard to analyze test results. Because this
situation does not happen in production environment (we do not offline
cpus), we can prevent flooding the logs by identifying this case,
logging an appropriate error one time and ignore all later similar errors.

Bug: 158766131
Test: adb shell "echo 0 > /sys/devices/system/cpu/cpu[0-3]/online"
Test: start some apps, observe libprocessgroup errors in the logcat
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia91d8839d86787569c255481bde077be51c43d93
2021-10-25 16:18:08 -07:00
Rick Yiu
014446d702 init.rc: Create a new group for dex2oat
Create a new group for dex2oat in cpu cgroup, which is dedicated for
dex2oat processes. Also modify task profiles for this change.

Bug: 201223712
Test: dex2oat group created
Change-Id: Ic61f4b8a64d01c03549b680970805e12b9ce4fcc
2021-10-22 22:20:07 +08:00
Wei Wang
1132977223 Merge changes from topic "sysbg_aosp"
* changes:
  task_profiles: add ServicePerformance to legacy device policy
  libutils: use system_background for low prio tasks in framework
2021-10-07 17:54:40 +00:00
Wei Wang
c53d794ca8 task_profiles: add ServicePerformance to legacy device policy
Since we are adding SCHED_SP_SYSTEM into framework, the policy is needed
on older releases as well.

Bug: 201428466
Test: Build
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I0784820bfec84fd8ef98f2feb2caee084d0a14a2
2021-10-06 15:08:42 -07:00
Colin Cross
80e34e3017 Fix compiling libprocessgroup against musl
Include sys/cdefs.h before using __BEGIN_DECLS.

Bug: 190084016
Test: m USE_HOST_MUSL=true
Change-Id: Iac009275f7198476dd83ac70dbbc626b70f88ed1
2021-09-14 12:35:01 -07:00
Suren Baghdasaryan
25ad3f9b86 libprocessgroup: Activate controllers in cgroup v2 hierarchy at intermediate levels
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
2021-08-02 20:02:51 +00:00
Wei Wang
814673ace3 task_profiles.json: add taskprofile for dex2oat boot_complete policy
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)
2021-07-12 18:49:52 -07:00
Suren Baghdasaryan
29c9e26776 libprocessgroup: Remove unnecessary permissions change in uid/pid hierarchy
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
2021-07-07 19:42:25 +00:00
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
Wei Wang
6c54679758 task_profiles.json: add taskprofile for SurfaceFlinger
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)
2021-06-15 15:18:23 -07:00
Treehugger Robot
08a7cf2baa Merge "libprocessgroup: remove failure log for aggregate profiles" 2021-05-14 22:06:37 +00:00
Wei Wang
8722e4d219 libprocessgroup: remove failure log for aggregate profiles
The inner profile should print error message if needed.

Bug: 178070122
Test: Build
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I2d9d54e21fb064678feccdbae453a398806d51d6
2021-05-14 12:44:45 -07:00
Treehugger Robot
3b0ec907f7 Merge "libprocessgroup: Fix warnings when legacy schedtune cgroup is absent" 2021-04-27 09:00:54 +00:00
Suren Baghdasaryan
e3d38969aa libprocessgroup: Fix warnings when legacy schedtune cgroup is absent
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
2021-04-26 09:28:08 -07:00
Colin Cross
176ec1b805 Replace llndk_library with llndk clause in cc_library
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
2021-04-21 19:13:41 -07:00
Li Li
50d8f9d299 Merge "task_profiles.json: use cgroup v2 uid/pid freezer" 2021-04-10 07:40:19 +00:00
Li Li
2470e479cf task_profiles.json: use cgroup v2 uid/pid freezer
Bug: 184800106
Bug: 184893012
Test: Verify the app status in frozen and unfrozen states.

Change-Id: Ic27529d71839076a0ac816383b52ec28c5d17be5
2021-04-10 02:27:43 +00:00
Rick Yiu
49fce9571a libprocessgroup: Change LogFailures to string
To match the definition of proto file.

Bug: 184715843
Test: function works
Change-Id: I1ef4b3509069d8c83e8afd192c72edf62c772c26
2021-04-09 00:37:44 +00:00
Suren Baghdasaryan
7f19b1e6de libprocessgroup: introduce optional attribute for cgroup controllers
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
2021-03-11 17:42:30 +00:00
Suren Baghdasaryan
f46a2297d0 libprocessgroup: remove a false error message
Remove an error message generated when changing permissions succeed.

Bug: 181866655
Test: boot and observe libprocessgroup messages in logcat
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: If95fcbd5171b73191504beffdc504c44eef3b4c1
2021-03-11 03:01:46 +00:00
Haibo Huang
d9ac92a739 [libprocessgroup] Use new jsoncpp API
Reader / StyledWriter are deprecated upstream

Bug: 170642246
Change-Id: Iadc944af17cad9640ed31364116d16f2b971434f
2021-03-01 23:09:26 +00:00
Marco Ballesio
b47969b62e libprocessgroup: remove hardcoded freezer path
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
2021-02-25 23:39:52 +00:00
Marco Ballesio
4e644c445f libprocessgroup: new method to get cgroup paths
Bug: 180056337
Test: Verified the app freezer is correctly enabled via logs
Change-Id: I3d954dd9bb0f1fa509a275d587e603f33a9d563f
2021-02-24 17:08:51 -08:00
Bob Badour
d69ad69a93 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Id740a7d2884556081fdb68876584b25eb95e1bef
2021-02-19 12:59:05 -08:00
Elliott Hughes
c3a206ccda Revert "[LSC] Add LOCAL_LICENSE_KINDS to system/core"
This reverts commit 187b7d1950.

Reason for revert: system/core is multiple projects, not one.

Change-Id: I790ea41741f8cd9b8b6db2f59a49e71fb0958fd6
2021-02-16 20:01:20 +00:00
Bob Badour
187b7d1950 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  Android.bp
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I5bd81adb5cdcf2b4dd4141b204eb430ff526af8f
2021-02-16 04:10:03 -08:00
Marco Ballesio
9e628a6b42 libprocessgroup: fix uid/pid hierarchy for recovery mode
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
2021-02-11 17:03:19 -08:00
Marco Ballesio
a7148f82a1 libprocessgroup: adopt cgroup v2 freezer search path
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
2021-02-11 17:03:06 -08:00
Marco Ballesio
4dac81680f Revert^4 "libprocessgroup: uid/pid hierarchy for cgroup v2"
This reverts commit 088924af2a.

Bug: 168907513
Test: verified correct function of the cgroup v2 hierarchy in normal and
recovery mode

Change-Id: I6e9d21ebe832326ed5a5b2c356fe8363c1546a80
2021-02-11 15:01:43 -08:00
Marco Ballesio
23fddab32b libprocessgroup: define path for freezer search
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
2021-02-05 12:20:56 -08:00
Marco Ballesio
079477468f Revert^3 "libprocessgroup: move freezer to uid/pid hierarchy"
This reverts commit 7707909ba2.
Bug: 179006802
Test: verified correct functioning of the freezer after reverting

Change-Id: I848146a18a0879010abf5b00e7081f2771059064
2021-02-05 12:19:58 -08:00
Treehugger Robot
fe13d497f4 Merge "Symbol files describing APIs across updatable components are reviewed" 2021-02-05 03:12:45 +00:00
Treehugger Robot
cfb743e42c Merge "Revert^3 "libprocessgroup: uid/pid hierarchy for cgroup v2"" 2021-02-05 01:59:15 +00:00
Marco Ballesio
088924af2a Revert^3 "libprocessgroup: uid/pid hierarchy for cgroup v2"
a1a0497984

Bug: 151660495
Test: verified proper boot in regular mode and proper working of adb in
recovery

Change-Id: I1276796e982fee932cdea7eb145f20b3f1b3463d
2021-02-04 22:33:34 +00:00
Julien Desprez
427e9f08f9 Remove TEST_MAPPING entry based on go/a-unit-tests update
cc_test_host now all run in presubmit without any need for explicit TEST_MAPPING

Change-Id: I379ef754b4cb645976daedcd04eae58f2eb32a75
Test: presubmit
Bug: 177450457
2021-02-04 16:50:56 +00:00
Jiyong Park
9ae5daba80 Symbol files describing APIs across updatable components are reviewed
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
2021-02-04 21:05:21 +09:00
Rick Yiu
d76053a4c5 libprocessgroup: Add control of printing log in WriteFileAction
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
2021-01-28 03:26:18 +00:00
Marco Ballesio
7707909ba2 Revert "Revert "libprocessgroup: move freezer to uid/pid hierarchy""
This reverts commit b01aa99408.

Reason for revert: blocking issue was resolved https://partner-android-review.googlesource.com/c/kernel/private/gs-google/+/1846507

Change-Id: If125fe9af53e2b519955f021208d5d5530c6277e
2021-01-27 16:43:07 +00:00
Marco Ballesio
a1a0497984 Revert^2 "libprocessgroup: uid/pid hierarchy for cgroup v2"
4bbabe4ca4

Change-Id: I6742ffd19a6ea1fe3bf6b4386da69f5885b13be4
2021-01-27 06:07:25 +00:00
Jiyong Park
ab8a7d2a03 Cgroup APIs are guarded
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
2021-01-12 20:50:27 +09:00
Jiyong Park
2d30fe48d4 Remove __ANDROID_API__ guards
__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
2021-01-12 20:50:27 +09:00
Treehugger Robot
bde5350eed Merge "Revert "libprocessgroup: move freezer to uid/pid hierarchy"" 2021-01-05 23:33:12 +00:00
Marco Ballesio
b01aa99408 Revert "libprocessgroup: move freezer to uid/pid hierarchy"
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
2021-01-05 21:36:44 +00:00
Elliott Hughes
21de4e727e Add new owners to various sub-projects.
Test: treehugger
Change-Id: Ia2a99c0499633ccc5d23c37a1ec93867c876d637
2020-12-11 12:45:45 -08:00
Jonglin Lee
ac216acad5 Merge "Revert "libprocessgroup: uid/pid hierarchy for cgroup v2"" 2020-12-04 04:47:39 +00:00
Jonglin Lee
4bbabe4ca4 Revert "libprocessgroup: uid/pid hierarchy for cgroup v2"
Revert "sepolicy: rules for uid/pid cgroups v2 hierarchy"

Revert submission 1511692-cgroup v2 uid/pid hierarchy

Reason for revert: Causing intermittent cgroup kernel panics
Reverted Changes:
I80c2a069b:sepolicy: rules for uid/pid cgroups v2 hierarchy
I73f3e767d:libprocessgroup: uid/pid hierarchy for cgroup v2

Bug: 174776875
Change-Id: I2af586d63bb0312407b90b52909330cde4b7b074
Test: Locally reverted and booted 100 times without kernel panic
2020-12-04 03:12:59 +00:00
Justin Yun
feef4d390f Add product_available to product available modules
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
2020-12-04 09:59:20 +09:00
Marco Ballesio
1414a0d4d8 libprocessgroup: move freezer to uid/pid hierarchy
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
2020-12-03 22:00:33 +00:00
Suren Baghdasaryan
756a60459c libprocessgroup: Change per-API level task profiles to override the diffs
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
2020-12-03 19:39:31 +00:00
Wei Wang
673b6d47bc Merge changes I13c9660a,I41745e7b,I0e6722b8
* changes:
  init.rc: correct the obsolete comment
  Add system-background cpu group
  init.rc: create camera-deamon stune cgroup
2020-12-03 18:57:25 +00:00
Marco Ballesio
4d45b59f80 libprocessgroup: uid/pid hierarchy for cgroup v2
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
2020-12-02 09:51:42 -08:00
Wei Wang
ab87979a00 Add system-background cpu group
Add system-background cgroup hierarchy for uclamp and cpu bandwidth
tuning.

Bug: 170507876
Bug: 171740453
Test: boot and check cgroup
Change-Id: I41745e7b3ac5c1d7ea7dd77f5db39c6895047446
2020-12-01 19:46:02 -08:00
Suren Baghdasaryan
35221b5338 libprocessgroup: Support per-API level task profiles
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
2020-11-23 22:08:41 +00:00
Wei Wang
b90e23efc7 task_profiles.json: use system subgroup for NormalPerformance
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
2020-11-20 10:54:55 -08:00
Rick Yiu
b4a3f080e6 Merge "libprocessgroup: Support write to file feature" 2020-11-04 04:54:42 +00:00
Rick Yiu
bc1ad9671a libprocessgroup: Support write to file feature
There may be some use cases that it needs to write string to a
file. This patch support write "Value" to "FilePath", where
both parameters could use special string "<uid>" and "<pid>" to
represent actual uid and pid.

Bug: 170507963
Test: function works
Change-Id: I543846f523518a9bcb3dd1b3437163a1b3157d95
2020-11-03 20:56:48 +08:00
Yifan Hong
92836b2e95 Merge changes from topic "toybox_vendor_ramdisk"
* changes:
  Add shell_and_utilities_vendor_ramdisk
  Make libraries {vendor_,}ramdisk_available.
2020-11-02 18:33:33 +00:00
Rick Yiu
32809d8231 Merge changes from topic "aosp_use_uclamp"
* changes:
  init: Add cpu controller hierarchy to use utilclamp controller
  libprocessgroup: Replace stune with utilclamp profiles
2020-10-30 07:12:32 +00:00
Suren Baghdasaryan
1b53c2496d libprocessgroup: Replace stune with utilclamp profiles
Replace schedtune out-of-tree controller's usage in the performance
profiles with utilclamp controller. Stop mounting schedtune controller.

Bug: 170507876
Test: cpuctl groups worked
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ib7fa6c902581398587c75414845c2ff6c8bdb005
2020-10-29 16:21:09 +00:00
Yifan Hong
67c71a1b4f libprocessgroup_headers: make vendor_ramdisk_available.
Test: pass
Bug: 156098440
Change-Id: I4d66c3e0aa2bbc972d2d6fe16dec95a45bfb2889
2020-10-28 10:57:51 -07:00
Yifan Hong
89d1c19ca0 Make libraries {vendor_,}ramdisk_available.
Test: pass
Bug: 156098440
Change-Id: I07bb2fdc5113a5113b648795a1f60c09f20e12f1
2020-10-28 10:57:51 -07:00
Colin Cross
6a2b16693c Make the connection between implementation and llndk_library explicit
Instead of assuming a module with the .llndk suffix exists, add an
llndk_stubs property to every cc_library module that has a
corresponding llndk_library.  Also rename the llndk_library to have
an explicit .llndk suffix.

Bug: 170784825
Test: no changes to build.ninja (excluding comments) or Android-${TARGET_PRODUCT}.mk
Change-Id: Ifba79a1ae64a67a9d7393dac2fb012cd8af8e149
2020-10-19 13:38:05 -07:00
Dan Shi
67b7dd570f Remove vts10 related configs
Bug: 169582597
Test: build
Change-Id: I38e1e0f8e32b86ab14b905d040c1c62245a1a9e3
2020-10-06 13:52:44 -07:00
Marco Ballesio
43050baa7f libprocessgroup: json prototype for cgroups v2
cgroups v2 support introduces new fields in the json format. Adapt the
proto file accordingly

Bug: 154548692
Test: atest libprocessgroup_proto_test --
Change-Id: I40f8757a8f4e6a0b839caa7faa976dfebf3aac98
2020-08-20 15:53:48 -07:00
Marco Ballesio
1c755e22c8 libprocessgroup: switch freezer to cgroup v2
remove cgroup v1 freezer entries from init.rc, add a new cgroup v2
controller and modify plists to properly interact with it.

Bug: 154548692
Test: manually verified the the cgroup v1 freezer controller isn't
created and a new controller for cgroup v2 is created under the correct
sysfs directory.

Change-Id: I1b811300ade486f88fdbd157255a7f37750cc54d
2020-08-20 15:11:41 -07:00
Marco Ballesio
76eca5b4c1 freezer: allow dynamic changes to freezer.state
create new profiles to allowing thawing and freezing back the freezer
cgroup

Bug: 151225245
Test: Manually verified that using the SetTaskProfiles method on the
profiles thaws and freezes back the freezer cgroup.

Change-Id: I7f3e193ebe79b49c1f6ac52b6138ff4ec26fc570
2020-08-19 13:18:28 -07:00
Suren Baghdasaryan
81b9f0b763 libprocessgroup: Allow vendor profile attributes to override system ones
In the current implementation vendor profile attributes do not override
system ones and instead generate a warning. Fix that by overriding existing
attribute if a new definition is found.

Bug: 160318642
Test: add vendor attributes and confirm no warnings
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I71a2ee4d4b3c585e7c9a01b791e973390d409cbc
2020-07-01 20:44:24 +00:00
Marco Ballesio
f16f9417b0 libprocessgroup: support for cgroup v2 hierarchy
for a first implementation the cgroup v2 freezer controller will be used in a
way similar to cgroup v1, that is a single child group will hold all frozen
processes. Some adjustments are needed for the new structure.

- Add support for cgroup v2 syntax under procfs.
- Separate creation of a directory with ownership/mode changes to allow changes
    after mounting the cgroup kernfs root.
- Allow the creation of sub-groups under a cgroup v2 hierarchy.

Bug: 154548692
Test: manually verified that a proper cgroup v2 hierarchy is created and
accessible

Change-Id: I9af59e8214acaead3f520a94c95e75394c0df948
2020-06-10 09:14:00 -07:00
Yifan Hong
2572f23af8 vts_processgroup_validate_test: make deps static
Test: pass
Fixes: 155959743
Change-Id: I730526955a40ae00a97f487e423a00c743f75d53
2020-05-07 12:41:45 -07:00
Treehugger Robot
f9273c2aa3 Merge "processgroup: Set min_sdk_version" 2020-05-04 15:52:39 +00:00
Suren Baghdasaryan
8c604e8615 task_profiles.json: add a new task profile used by camera HAL
Add new CameraServicePerformance task profile used by camera HAL.

Bug: 155419956
Test: confirm profile applies correctly
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I21cf942eca279a5ad4c1ff75c735560954f4ebc1
2020-05-01 01:05:42 +00:00
Dan Shi
63a07aafcf Add vts_processgroup_validate_test to vts suite
Bug: 154727600
Test: atest vts_processgroup_validate_test
Change-Id: I53bd4f9fd097878deaa77159feb2d48f66c464d1
Merged-In: I53bd4f9fd097878deaa77159feb2d48f66c464d1
2020-04-28 09:58:14 -07:00
Jooyung Han
4f55f3efd3 processgroup: Set min_sdk_version
Modules contributing mainline modules (APK/APEX) should set
min_sdk_version as well as apex_available.

For now setting min_sdk_version doesn't change build outputs.
But build-time checks will be added soon.

Bug: 152655956
Test: m
Change-Id: Idaa27ce24cc13d13145eaef85a08b9033922c7bc
2020-04-23 23:53:19 +09:00
Jiyong Park
e3d371e319 Set apex_available property
The marked library(ies) were available to the APEXes via the
hand-written whitelist in build/soong/apex/apex.go. Trying to remove the
whitelist by adding apex_available property to the Android.bp of the
libraries.

Bug: 150999716
Test: m
Change-Id: Id08058f3105463558c6c82298344a33af0efb2d3
2020-04-08 22:37:42 +09:00
Dan Willemsen
a8f188f011 Convert vts configs to Android.bp
Test: treehugger
Change-Id: Ibe8ed03555ac78ee38be6511eb4169cddfcd3555
2020-03-07 21:21:33 -08:00
Suren Baghdasaryan
911109c414 libprocessgroup: Prevent SetProcessProfiles from using cached fd
Because we cache file descriptors associated with cgroup "tasks" file it
should not be used with SetProcessProfiles API which operates on entire
processes rather than tasks. Change SetProcessProfiles API to prevent
cache fd usage, modify ExecuteForProcess to not attempt to use cached
fd. Also fix unconditional calls to EnableResourceCaching from
ExecuteForTask which should be called only when SetTaskProfiles is used
with use_fd_cache set to true.

Bug: 149524788
Change-Id: I880efaf8217a4dd7ccfbb4fb167b2295cefc057a
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2020-02-14 01:42:11 +00:00
Quentin Perret
20b2f1e0ab task_profiles.json: Fix uclamp attribute
task_profiles.json currently uses attributes of a defunct version of
uclamp, which was used for testing.

Let's use the attributes that actually got merged upstream instead.

Bug: 143710295
Change-Id: Ic6a14f52e14efeefc91f6e6bf580c15e2eded82e
Signed-off-by: Quentin Perret <qperret@google.com>
2020-02-04 13:10:31 +00:00
Suren Baghdasaryan
cee468fb79 Revive ACgroupController_getFlags LLNDK function to detect missing cgroups
ACgroupController_getFlags was reverted due to LLNDK breakage, however
it allows detection of cgroups that failed to mount in a more efficient
way. Revive the function as a weakly linked symbol to allow for it to
be missing in case older LLNDK library is being used with the new
system software. This effectively reverts the commit
aa1d54f0cc "Remove ACgroupController_getFlags to fix API breakage"'
except it declares ACgroupController_getFlags function as weak and
targets it for API level 30. If LLNKD library does not contain
ACgroupController_getFlags the behavior falls back to the current
way of identifying cgroups that failed to mount.

Test: build and verify correct operation with a missing cgroup
Change-Id: I9158ef53aba97972d41d71dd3396ac43796a7004
Merged-In: I9158ef53aba97972d41d71dd3396ac43796a7004
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2020-01-29 17:24:06 +00:00
Suren Baghdasaryan
8438595f21 libprocessgroup: Prevent aggregate profiles from referencing stale ones
Currently when vendor overrides a profile the profile object is being
replaced with a new one. However the old profile might have been
referenced by an aggregate profile and with such profile replacement
the aggregate profile is left referencing a stale object. Fix this by
replacing the content of the old profile with the content from the new
one instead of replacing the object itself.

Bug: 148311066
Test: override profiles referenced in aggregate profile and verify
Test: correct replacement
Change-Id: Iabddbf3580455e5263fedad6665cf52fb323e50a
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2020-01-27 21:07:27 +00:00
Quentin Perret
64811b7b13 libprocessgroup: ensure schedboost_enabled is true with uclamp
In the current state, schedboost_enabled() is true if and only if
schedtune is in use. As a result, all tests conditioned by
schedboost_enabled() will be skipped on devices using uclamp since it is
and extension of the CPU controller.

Fix this by making schedboost_enabled() return true if either schedtune
or the CPU controller is enabled.

Bug: 44953631
Change-Id: Idaadf252c9cf411a176180ab8988d559ca8a1332
Signed-off-by: Quentin Perret <qperret@google.com>
2020-01-27 11:04:03 +00:00