Loading init/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -369,6 +369,7 @@ init_first_stage_cc_defaults { ], static_libs: [ "libapexd_flags", "libfs_avb", "libavf_cc_flags", "libfs_mgr", Loading init/block_dev_initializer.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,11 @@ bool BlockDevInitializer::InitBootDevicesFromPartUuid() { return true; } // Second_stage_init requires loop-control before ueventd starts. void BlockDevInitializer::InitLoopDevices() { (void)InitMiscDevice("loop-control"); } bool BlockDevInitializer::InitDeviceMapper() { return InitMiscDevice("device-mapper"); } Loading init/block_dev_initializer.h +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ class BlockDevInitializer final { bool InitDmDevice(const std::string& device); bool InitPlatformDevice(const std::string& device); bool InitHvcDevice(const std::string& device); void InitLoopDevices(); private: ListenerAction HandleUevent(const Uevent& uevent, std::set<std::string>* devices); Loading init/first_stage_mount.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android/avf_cc_flags.h> #include <com_android_apex_flags.h> #include <fs_avb/fs_avb.h> #include <fs_mgr.h> #include <fs_mgr_dm_linear.h> Loading Loading @@ -308,6 +309,11 @@ bool FirstStageMountVBootV2::InitDevices() { return false; } } if constexpr (com::android::apex::flags::mount_before_data()) { block_dev_init_.InitLoopDevices(); } return true; } Loading init/init.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -50,9 +50,11 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/thread_annotations.h> #include <com_android_apex_flags.h> #include <fs_avb/fs_avb.h> #include <fs_mgr_vendor_overlay.h> #include <libavb/libavb.h> #include <libdm/loop_control.h> #include <libgsi/libgsi.h> #include <libsnapshot/snapshot.h> #include <logwrap/logwrap.h> Loading Loading @@ -854,6 +856,22 @@ static void MountExtraFilesystems() { #undef CHECKCALL } static void InitExtraDevices() { if constexpr (com::android::apex::flags::mount_before_data()) { // Pre-create a bunch of loop devices to accelerate apexd later. This effectively overrides // CONFIG_BLK_DEV_LOOP_MIN_COUNT. 128 loop devices should be enough for now because most // devices have < 100 apexes. constexpr int kMaxLoopDevices = 128; // Fire off a thread to pre-create the loop devices to avoid blocking the init. std::thread([]() { dm::LoopControl loop_control; for (int i = 0; i < kMaxLoopDevices; i++) { (void)loop_control.Add(i); } }).detach(); } } static void RecordStageBoottimes(const boot_clock::time_point& second_stage_start_time) { int64_t first_stage_start_time_ns = -1; if (auto first_stage_start_time_str = getenv(kEnvFirstStageStartedAt); Loading Loading @@ -1049,6 +1067,11 @@ int SecondStageMain(int argc, char** argv) { InstallInitNotifier(&epoll); StartPropertyService(&property_fd); // Initialize extra devices required during second stage init. // This may spawn threads for background work. Hence, this should be after // InstallSignalFdHandler() which needs to be called before spawning any threads. InitExtraDevices(); // If boot_timeout property has been set in a debug build, start the boot monitor if (GetBoolProperty("ro.debuggable", false)) { int timeout = GetIntProperty("ro.boot.boot_timeout", 0); Loading Loading
init/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -369,6 +369,7 @@ init_first_stage_cc_defaults { ], static_libs: [ "libapexd_flags", "libfs_avb", "libavf_cc_flags", "libfs_mgr", Loading
init/block_dev_initializer.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,11 @@ bool BlockDevInitializer::InitBootDevicesFromPartUuid() { return true; } // Second_stage_init requires loop-control before ueventd starts. void BlockDevInitializer::InitLoopDevices() { (void)InitMiscDevice("loop-control"); } bool BlockDevInitializer::InitDeviceMapper() { return InitMiscDevice("device-mapper"); } Loading
init/block_dev_initializer.h +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ class BlockDevInitializer final { bool InitDmDevice(const std::string& device); bool InitPlatformDevice(const std::string& device); bool InitHvcDevice(const std::string& device); void InitLoopDevices(); private: ListenerAction HandleUevent(const Uevent& uevent, std::set<std::string>* devices); Loading
init/first_stage_mount.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android/avf_cc_flags.h> #include <com_android_apex_flags.h> #include <fs_avb/fs_avb.h> #include <fs_mgr.h> #include <fs_mgr_dm_linear.h> Loading Loading @@ -308,6 +309,11 @@ bool FirstStageMountVBootV2::InitDevices() { return false; } } if constexpr (com::android::apex::flags::mount_before_data()) { block_dev_init_.InitLoopDevices(); } return true; } Loading
init/init.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -50,9 +50,11 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/thread_annotations.h> #include <com_android_apex_flags.h> #include <fs_avb/fs_avb.h> #include <fs_mgr_vendor_overlay.h> #include <libavb/libavb.h> #include <libdm/loop_control.h> #include <libgsi/libgsi.h> #include <libsnapshot/snapshot.h> #include <logwrap/logwrap.h> Loading Loading @@ -854,6 +856,22 @@ static void MountExtraFilesystems() { #undef CHECKCALL } static void InitExtraDevices() { if constexpr (com::android::apex::flags::mount_before_data()) { // Pre-create a bunch of loop devices to accelerate apexd later. This effectively overrides // CONFIG_BLK_DEV_LOOP_MIN_COUNT. 128 loop devices should be enough for now because most // devices have < 100 apexes. constexpr int kMaxLoopDevices = 128; // Fire off a thread to pre-create the loop devices to avoid blocking the init. std::thread([]() { dm::LoopControl loop_control; for (int i = 0; i < kMaxLoopDevices; i++) { (void)loop_control.Add(i); } }).detach(); } } static void RecordStageBoottimes(const boot_clock::time_point& second_stage_start_time) { int64_t first_stage_start_time_ns = -1; if (auto first_stage_start_time_str = getenv(kEnvFirstStageStartedAt); Loading Loading @@ -1049,6 +1067,11 @@ int SecondStageMain(int argc, char** argv) { InstallInitNotifier(&epoll); StartPropertyService(&property_fd); // Initialize extra devices required during second stage init. // This may spawn threads for background work. Hence, this should be after // InstallSignalFdHandler() which needs to be called before spawning any threads. InitExtraDevices(); // If boot_timeout property has been set in a debug build, start the boot monitor if (GetBoolProperty("ro.debuggable", false)) { int timeout = GetIntProperty("ro.boot.boot_timeout", 0); Loading