Commit graph

3275 commits

Author SHA1 Message Date
Danny Lin
1aea24d503 init.rc: Disable native stats collection service
When opening and closing activities in Settings, a measurably
significant amount of CPU time is spent processing and logging stats
events in statsd:

0.02%     /apex/com.android.os.statsd/lib64/libstatspull.so                                                                                         @plt
0.01%     /apex/com.android.os.statsd/bin/statsd                                                                                                    @plt
0.01%     /apex/com.android.os.statsd/bin/statsd                                                                                                    SocketListener::runListener()
0.01%     /apex/com.android.os.statsd/bin/statsd                                                                                                    android::os::statsd::LogEvent::parseBuffer(unsigned char*, unsigned long)
0.01%     /apex/com.android.os.statsd/bin/statsd                                                                                                    android::os::statsd::LogEvent::parseAnnotations(unsigned char, int)

Over longer device uptimes with real-world usage, statsd uses a
substantial amount of total CPU time. We have no use for the stats
recorded by statsd, so disable the service entirely to save CPU in
potential hotpaths.

This is the system/core part of the change; changes to frameworks/base
are also required.

Test: simpleperf record -a; verify that statsd no longer appears in
      sample hits
Change-Id: Idf6fdb0eff987169bd5f370dd72315e831a669e6
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
Signed-off-by: Dmitrii <bankersenator@gmail.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
2025-05-16 23:25:48 +00:00
Juhyung Park
2e24debf3c init.rc: tune dirty data writebacks
To relieve memory pressure on Android, we should start writing
dirty data sooner than later.

The Linux kernel's default is way too conservative on Android.
Android doesn't have a good reason to delay writing dirty data
anyways.

This change will make the kernel start writing dirty data when
it reaches 50M and switch to synchronous on 200M, which is far
more sensible values than 1.2G and 2.4G respectively on a device
with 12G of RAM.

Change-Id: I22f9ec9010dd028710a1a5c2e3d26d8444a4c914
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
2025-05-16 23:25:48 +00:00
hydrangea07
367e295c4b init.rc: Tune F2FS and dirty writeout policy for modern devices
In a previous commit bb0838b511, the gc_urgent_sleep_time for F2FS was aggressively set to 50ms to optimize GC.
This change, however, led to performance regressions on most devices, particularly of those running in 4.19+ kernels.
From our tests, the heightened CPU and I/O activity from this aggressive garbage collection setting is the likely cause.
To address this, we're revising the gc_urgent_sleep_time parameter to strike a balance between aggressive GC and device performance, taking
bb0838b511 goal into consideration.
Furthermore, the dirty writeout policy has been aligned with the latest configurations used in Pixel devices,
and cp_interval has been adjusted to surpass dirty_expire_centisecs for improved power efficiency during idle times.

Test: booted partner device, monitor performance
Change-Id: Ie4d0c870d734e915aaebcc53e64acdabac47b6dc
Signed-off-by: minaripenguin <minaripenguin@users.noreply.github.com>
2025-05-16 23:25:48 +00:00
Manjunatha Ramachandra
3b41535d6c Set swappiness of apps and system under /dev/memcg from init.rc
Set swappiness of apps and system under /dev/memcg from init.rc

CRs-Fixed: 2791027
Change-Id: I90e5feb8e52f9e98582b8d8666537b12d4864ce8
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
2025-05-16 23:25:48 +00:00
xNombre
10c00cd79d init.rc: Don't enable f2fs iostat by default
It is only intended for performance analysis and can
impact I/O throughput.

Change-Id: Ia7d3a449d52625d911e2cea16249972d01e5cfcf
Signed-off-by: Adithya <gh0strider.2k18.reborn@gmail.com>
Signed-off-by: Nishant Kumar <www.rajsonu13@gmail.com>

Former-commit-id: a766ea9189219e8ff4450bf86358f6f9c20cc7eb
Change-Id: I202956b4427b4ae7f88df496a108d717a6b8be57
Signed-off-by: minaripenguin <minaripenguin@users.noreply.github.com>
2025-05-16 23:25:48 +00:00
Kai Shi
489d9c456d init.rc: Set TCP memory size
Set ipv4 min/default/max write and read memory size and socket max send/receive memory size to values that are high enough to reach 1+Gbps over wifi and cellular. Moving forward there is no need to override them in per device init.rc or framework config file.

Bug: 213596972
Test: manual test to confirm TCP memory size is increased and wifi TCP throughput with default TCP window size can reach 700Mbps in HE80 mode.
Change-Id: I0eb644453ab44804d33e3ed21e64aaccdc8c1ecd
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
2025-05-16 23:25:48 +00:00
Alex Naidis
97ce690746 init.rc: don't start console unless asked to
This can have a major impact on performance.

We don't want this, even on userdebug/eng builds.

Use the new property "ro.console.enable" to
enable the console service explicitly.

Change-Id: I93e7c65e92261443d1c9c70cfef9aa2ed5ff328a
Signed-off-by: Alex Naidis <alex.naidis@linux.com>
Signed-off-by: Jason Edson <jaysonedson@gmail.com>
Signed-off-by: Dmitrii <bankersenator@gmail.com>
Signed-off-by: Joey Huab <joey@evolution-x.org>

Former-commit-id: 4d36ac6b9fe0a26dcfa4fc32de377c502f49eb3e
Former-commit-id: 1dc24bca6c98f3a9a23ce5ec3bf76c2019973694
Former-commit-id: c31e332873ff454d4203da5c67188a79260d2c1c
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
2025-05-16 23:25:21 +00:00
Giovanni Ricca
7934335c2a
Revert "init: Remove schedtune support"
This reverts commit 50fd822149.

Change-Id: Ife5bbcba6327022cabeb1a2b7362e2c8b2891cbf
2025-03-13 20:11:40 +01:00
Pechetty Sravani (xWF)
d189b8755a Revert "Define ueventd.rc.recovery"
This reverts commit f9b38f91ac.

Reason for revert: <Froidmonitor created revert due to b/382795480.Will be verified through ABTD for standard invesigation.>

Change-Id: Ib6f759fc3dee7800acf9a2c1e24eea2962730167
2024-12-09 02:46:21 +00:00
Jihoon Kang
f9b38f91ac Define ueventd.rc.recovery
By removing `recovery_available` property from "ueventd.rc" and
defining a dedicated recovery-specific module for "ueventd.rc".
`recovery_available` property should be used to allow the reverse
dependencies recovery modules to depend on the module, not to
install the module to the recovery partition.

Test: m soong_generated_recovery_filesystem_test
Bug: 381888358
Change-Id: I6921cae72a1757e065003efc9d77241625f645e9
2024-12-06 23:53:38 +00:00
Dennis Shen
683e3c0761 Start aconfigd socket defined in configinfra mainline module
Context: to have better future updatability. The responsiblity of
managing mainline module storage files and a socket service for flag
overrides will be moved to the configinfra mainline module. Later,
aconfigd on /system will only be repsopnsbile for managing platform
partition storage files.

Bug: b/369810972
Test: m, launch avd and then inspect the logcat log to confirm the
service is launched.

Change-Id: I490e5aa432fa4afa236689ad0999e5602f7d297e
2024-12-03 23:52:00 +00:00
Eric Biggers
6dc0ed1758 Merge "Fix the dm-verity Merkle tree caches to not expire so quickly" into main 2024-12-02 18:11:34 +00:00
Dennis Shen
db80953238 Merge "Deprecate cc_binary aconfigd and the controlling flag" into main 2024-11-27 13:33:23 +00:00
Dennis Shen
52d2446b4e Deprecate cc_binary aconfigd and the controlling flag
cc_binary aconfigd is replaced with rust_binary aconfigd-system. The
replacement is flag guarded and is already in TF full for more than a
week. Thus delete the flag and deprecate old cc_binary aconfigd.

Test: m
Change-Id: Ib128adc2ef8178e02222f77e6b89bcc7ac83c1da
2024-11-26 15:26:52 +00:00
Eric Biggers
cadad290a7 Fix the dm-verity Merkle tree caches to not expire so quickly
Bug: 335233956
Test: cat /sys/module/dm_bufio/parameters/max_age_seconds
Change-Id: I20e4df7dd3eb2ac1f462510e900568e946195faf
2024-11-26 03:24:44 +00:00
Dennis Shen
c532409c5c Merge "move aconfigd platform init service from init.rc into aconfigd.rc" into main 2024-11-25 17:27:03 +00:00
Jooyung Han
fef2dff80a Remove /data/apex/hashtree directory
This directory is no longer used.

Bug: 184914612
Change-Id: Iaa094e2df39c363fe0a5ffd4b27b5c3075bb4f7f
Test: (device doesn't have the directory)
2024-11-25 08:32:05 +00:00
Shin Kawamura
640e32478f Merge "Fix permission of zram writeback and idle file" into main 2024-11-22 03:58:13 +00:00
Akilesh Kailash
35ab96a423 Add prefetch directory in /metadata
Bug: 362507272
Test: Verify directory is created in /metadata
Change-Id: Ie1c2312f405d4b41e06a248e4d2b93cd8fc62a93
Signed-off-by: Akilesh Kailash <akailash@google.com>
2024-11-21 05:59:54 -08:00
Shintaro Kawamura
b912e3e548 Fix permission of zram writeback and idle file
The default permission of "/sys/block/zram0/idle" and
"/sys/block/zram0/writeback" are "0200".

Adding read permission to the files does not make sense because reading
those files fail as EIO error.

We should keep permission as minimum as possible.

Bug: 117682284
Bug: 375432468
Test: ls -la /sys/block/zram0

Change-Id: I11ed5d9eee257002f4698edcd81de39d2c317ea1
2024-11-21 16:28:34 +09:00
Gabriel Biren
6105d9dc8a Create the mainline supplicant directory
during initialization.

Bug: 365585450
Test: Manual test - verify that the mainline
      supplicant can add/remove interfaces
Change-Id: Ib41b361a8b032c04586f108be9d1933214934286
2024-11-18 20:24:58 +00:00
Dennis Shen
f1eaa75168 move aconfigd platform init service from init.rc into aconfigd.rc
Bug: 378079539
Test: m
Change-Id: I10c306468bf3efe3b5186851cb09b576b143512a
2024-11-11 17:44:14 +00:00
Ted Bauer
3c700588c7 Start aconfigd_system processes in init.rc
aconfigd_system is replacing aconfigd. Which one executes is toggled
by RO flag enable_system_aconfigd_rust, introduced in https://android-review.googlesource.com/q/topic:%22switch-to-aconfigd-system%22.

Bug: 378079539
Test: m
Change-Id: I6a04c38e9ef22da2b230046ddace73d6f7e39652
2024-11-08 17:45:16 +00:00
Jooyung Han
03429accee init: mount tracefs before apexd-bootstrap
This removes the error log when apexd-bootstrap starts:

  cutils-trace: Error opening trace file: No such file or directory (2)

Bug: 376150518
Test: boot-time trace shows apexd-bootstrap
  see https://source.android.com/docs/core/perf/boot-times#systrace
Change-Id: I5feaece50663a602b61377cee034060fd30217f9
2024-10-29 16:28:33 +09:00
David Anderson
097b607ac6 Merge "init: Issue a wipe on boot if trade-in mode was active." into main 2024-10-18 21:55:09 +00:00
Treehugger Robot
499643e456 Merge "init: Remove schedtune support" into main 2024-10-09 20:45:29 +00:00
T.J. Mercier
50fd822149 init: Remove schedtune support
Schedtune was an out of tree cgroup controller present in Android
kernels up to 4.19. It was replaced with uclamp and the cpu controller.
Now that 4.19 is EOL and unsupported, and schedtune is not present in
any supported Android kernels, remove the userspace support for
schedtune.

Bug: 362504801
Change-Id: Iab7b7295d1fb443209d5868ac5c65dca0aabfbab
2024-10-04 14:53:27 +00:00
Rob Barnes
da77c2e1dc Change owner of ACPI BERT tables to system
Changes the owner of the following files to system:system:

* /sys/firmware/acpi/tables
* /sys/firmware/acpi/tables/BERT
* /sys/firmware/acpi/tables/data/BERT

This allows the bert_collector deamon to read these files for error reporting.

Bug: 357626966
Test: m && atest bert_collector_test

Change-Id: Iba3a169f1851566ee6fed6d41b538dae448bf811
2024-10-03 13:54:52 +00:00
David Anderson
6f451a9c8c init: Issue a wipe on boot if trade-in mode was active.
This modifies first-stage init to check for /metadata/tradeinmode/wipe
as soon as /metadata is mounted. If the file exists, we issue a request
to the bootloader to reboot to recovery and wipe /data. Since this also
wipes /metadata, the wipe indicator will be removed too.

In case some kind of failure happens in recovery, this also implements a
quick-and-dirty counter mechanism to fallback to the recovery menu.

Bug: 307713521
Test: touch /metadata/tradeinmode/wipe && adb reboot
Change-Id: I2d05903cadcdadf9c05f6736454db790a9e6b5bb
2024-10-02 20:19:08 -07:00
Maciej Żenczykowski
b4b3950e52 Fix the trigger name for loading bpf programs.
The trigger name should be load-bpf-programs, not load_bpf_programs.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I00cff0a3dd971de39dfc3226b140be972854ea28
2024-09-23 21:34:33 +00:00
Maciej Żenczykowski
3e8f0b53e4 Merge "start netd earlier" into main 2024-09-23 21:16:05 +00:00
Maciej Żenczykowski
e60b760e74 start netd earlier
In this change we're moving the asynchronous netd startup ahead of
the async statd and *synchronous* update_verifier.

This is desirable as we want a netd failure (which could
happen due to some mainline incompatibility wrt. bpf
or mainline shipped shared libs: resolver or netd updatable)
to be considered a signal for a bad boot.

It's still asynchronous though, so it's not ideal.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib3e252f085f569864feddaf20ac80858a3bb969d
2024-09-23 21:15:01 +00:00
Inseob Kim
65daca3b88 Merge "Mount /mnt/vm earlier" into main 2024-09-20 08:01:56 +00:00
Inseob Kim
f5af00e79f Mount /mnt/vm earlier
To support early VM in the init stage.

Bug: 331320802
Test: boot and check /mnt/vm
Change-Id: If6f20a616ad24ae194e6fae292c9be200b63185b
2024-09-13 14:02:10 +09:00
Justin Yun
807ab25891 Define linker.config.json as a filegroup
The linker.config.json file is required for soong to generate a
system image.

Bug: 365670526
Test: lunch aosp_cf_x86_64_phone_soong_system-trunk_staging-userdebug
      && m
Change-Id: I86389e4143cd2fc08b812d50962bf7ec007894ab
2024-09-12 18:32:47 +09:00
Nelson Li
c1ad204f85 Rename system/core/rootdir/Android.mk to create_root_structure.mk
Since Soong currently doesn't support the `install_directory`
functionality, this file cannot be directly converted to Android.bp.
Moreover, the main content of `system/core/rootdir/Android.mk` is to
create directories and symlinks for the root file system. Therefore,
we'll first rename it and move it to build/core/main.mk for handling.

In addition, consolidate the handling of `meta-lic` related parts into
build/core/tasks/meta-lic.mk.

Bug: 353642907
Test: m -j init.environ.rc
Change-Id: I356c4b05c56b02b0243c12dbeddd4653ba4e137c
2024-09-10 06:50:19 +00:00
Inseob Kim
715dd707c4 Move adb_keys to product partition
/adb_keys will be moved to /product/etc/security as it's a
product-specific file. To prevent regression, /adb_keys will be a
symlink to the new location.

Bug: 353430323
Test: boot and connect adb with ADB_VENDOR_KEYS
Change-Id: I3dd200a1583be8f99bd5c30ecfed1bdc544ca783
2024-08-28 15:47:33 +09:00
Nick Kralevich
1220d17108 init.rc: Fix entropy pool initialization
Init is responsible for initializing the /dev/[u]random entropy
pool, to ensure that high quality random numbers are available
to all Android processes. Previously Android mixed in data
from /system/etc/prop.default, which included properties which
differed on a device-by-device basis. That file no longer exists,
and init generates the following error at boot:

  init: Command 'copy /system/etc/prop.default /dev/urandom'
  action=init (/system/etc/init/hw/init.rc:106) took 0ms and
  failed: Could not read input file '/system/etc/prop.default':
  open() failed: No such file or directory

Instead of reading a property file, this change modifies init.rc
to read from /proc/bootconfig. The bootconfig file contains
per-device data which was previously on the command line, such
as androidboot.serialno. Additionally, it contains device-class
information such as androidboot.hardware,
androidboot.hardware.platform, and data which frequently churns
such as androidboot.vbmeta.digest. These help ensure that the
random number initialization is at least unique on a per
device-class basis.

Relying on /proc/bootconfig accomplishes the same goal that
relying on /system/etc/prop.default was intended to accomplish.
And /proc/bootconfig is in a more stable location than
/system/etc/prop.default, hopefully preventing future regressions.

Bug: 361624398
Test: Device boots and error above goes away
Change-Id: Id5c891e871217d62ff6517c5804b4acc2d723622
2024-08-23 11:17:41 -07:00
Jooyung Han
148f602f23 init: clean up unused Service[List]::post_data
post_data was used by Userspace Reboot, which was removed.

Bug: 293377020
Test: atest CtsInitTestCases
Change-Id: I1a5bf328f62b8afbe58eef62c64689471e6b018c
2024-08-19 14:30:37 +09:00
Treehugger Robot
50a5cc57fe Merge "Convert ramdisk_node_list to Android.bp" into main 2024-08-16 14:51:15 +00:00
Nelson Li
560cb93d9e Convert ramdisk_node_list to Android.bp
`ramdisk_node_list` is a hardcoded dependency in
`build/make/core/Makefile`, but it only serves as an input for
generating `ramdisk.img` and isn't installed on the device.

Therefore, we can directly use a `filegroup` and set
`export_to_make_var` for use in build/make/core/Makefile.

In addition, since there are no `Android.mk` files in the
subdirectories of `system/core/rootdir/`,
`include (callall−makefiles−under,(LOCAL_PATH))` can also be
deleted.

Bug: 359423289
Test: m -j $(PRODUCT_OUT)/ramdisk.img
Change-Id: Ia2bf636bfd7917bf7044d9726b4b52932bb161c8
2024-08-15 11:36:12 +08:00
Rick Yiu
673e6bb089 Create a new group for foreground of multi-window
In multi-window mode, currently the focused window will be top-app,
and others will be foreground. However, the cpu resource we assign to
typical foreground group may not meet the performance need of those
windows. Therefore, create a new group for them so that we could
distinguish their performance need.

Bug: 200769420
Test: group created
Change-Id: I84c61f9ed4d167e156dafb7a816b6482e80a8523
2024-08-15 01:29:48 +00:00
Jooyung Han
b29f0dcb5b Merge changes I00deb50c,I82650277 into main
* changes:
  Clean up userspace-reboot (#2)
  Clean up userspace-reboot
2024-08-12 00:40:07 +00:00
Jooyung Han
e34549af33 Clean up userspace-reboot
The feature was deprecated last year.

Bug: 292469129
Test: atest CtsInitTestCases
Change-Id: I826502770ab3fa566be57a33829f1103efa893fb
2024-08-09 15:58:53 +09:00
Inseob Kim
b6e4179dab Add /mnt/vm and mount tmpfs onto it for early VM
It will be used as a storage for early boot virtmgr.

Bug: 354059281
Test: boot and check /mnt/vm
Change-Id: I4a0c604161356b631c21913a0f8c3f2d796a3c65
2024-08-09 15:20:18 +09:00
Inseob Kim
3ce6cb9b6e Refactor init.environ.rc to append than replace
Bug: 353429422
Test: boot
Change-Id: Ibd432fa39fc75f8b49ae26fbc6b74f11fb3f771d
2024-08-02 15:55:39 +09:00
Inseob Kim
b7fa335ed8 Reland "Migrate init.environ.rc module to Soong"
Makefile module still remains to handle post install commands. We're
going to move that to somewhere else as a followup.

Relanding with a fix for hwasan build.
HWADDRESS_SANITIZER_GLOBAL_OPTIONS is set by Soong's MakeVars, so we
can't refer the variable on soong config modules. Instead, as the
variable is hard-coded, this change hard-codes options in Android.bp.

Bug: 353429422
Test: boot cuttlefish w/ and w/o USE_SOONG_DEFINED_SYSTEM_IMAGE
Test: boot shiba with SANITIZE_TARGET=hwaddress
Change-Id: I4f61d7f800e0563c49dec0151d4a648ce9814bc9
2024-08-01 03:30:56 +00:00
Liana Kazanova
bd153e76db Revert "Migrate init.environ.rc module to Soong"
Revert submission 3197177-init_environ_rc_soong

Reason for revert: DroidMonitor: Potential culprit for b/356587212 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Reverted changes: /q/submissionid:3197177-init_environ_rc_soong

Change-Id: I3834d7f76f4baef747f3536167ad9bd2d2a474b4
2024-07-31 17:56:36 +00:00
Inseob Kim
fcbb743d86 Migrate init.environ.rc module to Soong
Makefile module still remains to handle post install commands. We're
going to move that to somewhere else as a followup.

Bug: 353429422
Test: boot with and without USE_SOONG_DEFINED_SYSTEM_IMAGE
Change-Id: I85ec048e6e57981ad4496ea90762aa34bd9a5ca1
2024-07-31 13:10:41 +09:00
Treehugger Robot
d909570786 Merge "init: set a new trigger when a vold checkpoint is committed" into main 2024-07-22 09:12:29 +00:00