Commit graph

266 commits

Author SHA1 Message Date
Bart Van Assche
eef0f563fd [DO NOT MERGE] Migrate the blkio controller to the v2 cgroup hierarchy
There are multiple use cases in Android for which background writes need
to be controlled via the cgroup mechanism. The cgroup mechanism can only
control background writes if both the blkio and memcg controllers are
mounted in the v2 cgroup hierarchy. Hence this patch that migrates the
blkio controller from the v1 to the v2 cgroup hierarchy.

The blkio controller has been marked as optional since not all Android
kernels enable this controller (CONFIG_BLK_CGROUP).

This patch increases the TOTAL_BOOT_TIME for devices with a 4.19 kernel
(redfin) from 18.9 s to 20 s. This patch does not affect the boot time
for devices with a 5.10 or 5.15 kernel.

This patch increases the time spent in CgroupMap::ActivateControllers()
by 25 microseconds in Cuttlefish on an x86-64 CPU.
CgroupMap::ActivateControllers() is called by Service::Start().

Bug: 213617178
Test: Cuttlefish and various phones
Change-Id: I3c07c1be84c3feb277b7d7003652d5d3b57c6541
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-03-22 11:39:53 -07:00
Bart Van Assche
51e58aced4 libprocessgroup: Add argument checks in KillProcessGroup()
Apparently there is Java code that calls KillProcessGroup() with an
invalid initialPid argument. Hence this CL that makes KillProcessGroup()
fail early if one of its arguments is invalid.

Change-Id: I42f98eed139d9d0950428d04180e4613ba74b4e6
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-03-15 09:35:06 -07:00
Suren Baghdasaryan
4f7cc8c345 libprocessgroup: fix boot time performance regression
The way processes are accounted in DoKillProcessGroupOnce has been
changed recently, which affects retries in KillProcessGroup. More specifically, initialPid was not counted before and would not
cause a retry with 5ms sleep.
Restore previous behavior to avoid boot time regressions.

Bug: 271198843
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ibc1bdd855898688a4a03806671e6ac31570aedf9
2023-03-03 00:11:13 +00:00
Krzysztof Kosiński
0f90ba64bd Merge "Fix invalid uses of PLOG." 2023-03-02 00:52:20 +00:00
Krzysztof Kosiński
0310ec4b55 Fix invalid uses of PLOG.
PLOG reports the value of errno. These four PLOG statements are
after functions that are not syscalls, leading to confusing logs
such as "Failed to apply Foo task profile: Success".

Bug: 271196526
Test: N/A
Change-Id: Iede5274d1ceebabec8432527112291ba63dca090
2023-03-01 04:17:57 +00:00
Jing Ji
304c0f1c14 Kill its process group even if the given process is already dead
So the child processes in the process group won't be orphaned
when we decide to kill the process group of a given process but
find it's already dead.

Bug: 266633286
Test: atest MicrodroidDemoApp
Change-Id: Ib6f45b992566f0ab5cf152463c95294a306dd736
2023-02-27 22:01:34 -08:00
Bart Van Assche
b0947e008a libprocessgroup: Proceed if activation of an optional controller fails
Not all Android kernels support all the cgroup controllers mentioned in
task_profiles.json and/or cgroups.json. Support such kernels by ignoring
certain cgroup activation failures.

Bug: 213617178
Change-Id: I90c0bd959f8a6484c4f2fbc895845e073527271e
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-10 15:02:44 -08:00
Bart Van Assche
1ec6ec4f57 libprocessgroup: Rework SetupCgroup()
Improve the readability of this function by splitting it.

This CL includes the following behavior changes:
- If changing the directory owner and/or mode fails for /sys/fs/cgroup,
  this is considered as a fatal error instead of something that should
  only fail if "Optional" has not been set.
- If mounting the v2 cgroup controller fails, this is considered as an
  error.
- Activating/mounting a cgroup controller only fails if the controller
  has not been marked as optional.

Bug: 213617178
Change-Id: If6908dfdbcb2e1c9637ab4ac8a7625f0a17dc9e0
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-10 14:18:38 -08:00
Bart Van Assche
17c84b9ffb libprocessgroup: Introduce a local variable in CgroupMap::ActivateControllers()
This CL prepares for introducing an additional flag test.

Bug: 213617178
Change-Id: Ia74c1990792b5839f76498de2cac0008ed92040f
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-09 13:26:17 -08:00
Bart Van Assche
0e8e4f87fd Fix the cgroup v2 thread path
The name for the file with thread IDs is "tasks" in the v1 hierarchy and
"cgroup.threads" in the v2 hierarchy.

References:
* https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v1/cgroups.html
* https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html

Bug: 213617178
Fixes: 82b72a5667 ("libprocessgroup: Add support for task profiles")
Change-Id: I87d67edeb12803cb83486be8f1b1b56a3f275a9d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-09 14:40:51 -08:00
Jooyung Han
c7a6fe684c Revert "Migrate the blkio controller to the v2 cgroup hierarchy"
Revert submission 2218645-blkio-cgroup-v2

Reason for revert: 260143932, 264620181

Reverted changes: /q/submissionid:2218645-blkio-cgroup-v2

Change-Id: I8bf1592cd5f7234f28094fe80341c37d42fa609b
2023-01-06 06:20:54 +00:00
Bart Van Assche
5400ae2440 Migrate the blkio controller to the v2 cgroup hierarchy
There are multiple use cases in Android for which background writes need
to be controlled via the cgroup mechanism. The cgroup mechanism can only
control background writes if both the blkio and memcg controllers are
mounted in the v2 cgroup hierarchy. Hence this patch that migrates the
blkio controller from the v1 to the v2 cgroup hierarchy.

This patch increases the TOTAL_BOOT_TIME for devices with a 4.19 kernel
(redfin) from 18.9 s to 20 s. This patch does not affect the boot time
for devices with a 5.10 or 5.15 kernel.

This patch increases the time spent in CgroupMap::ActivateControllers()
by 25 microseconds in Cuttlefish on an x86-64 CPU.
CgroupMap::ActivateControllers() is called by Service::Start().

Bug: 213617178
Test: Cuttlefish and various phones
Change-Id: I490740e1c9ee4f7bb5bb7afba721a083f952c8f2
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-05 13:07:00 -08:00
Bart Van Assche
6ad747ac2d task_profiles.json: Convert tabs into spaces
Commit 9c0fcbb0f7 ("libprocessgroup: Add I/O scheduler attributes to
task_profiles.json") accidentally introduced tabs in task_profiles.json.
Convert these tabs into spaces.

Bug: 213617178
Change-Id: I7ac59dbd40aa3da295646792e35b8275fbb97991
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-05 13:03:47 -08:00
Inseob Kim
eb3912ea73 Merge "Don't retry kill if cgroups isn't available" 2022-12-27 01:48:37 +00:00
Bart Van Assche
91bc6d30dd Merge "Updating Attributes on task_profiles.json" 2022-12-26 01:31:14 +00:00
Carlos Galo
92153fb955 Updating Attributes on task_profiles.json
Adjusting attributes that correspond to the `blkio`(v1)/`io`(v2) controller. The migration of the `blkio` v1 controller to v2 requires renaming it to `io`, therefore we want to update the `File` field to point to `blkio` file and `FileV2` to point to `io` file.

Test: Verified with cuttlefish that this works with the `io` controller migration by cherry-picking aosp/2218645
Bug: 263269364
Bug: 213617178
Change-Id: I0aacfc6d74e3eec61ebb2ce443b04c792392aa9e
2022-12-22 00:53:00 +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
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
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
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
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