diff options
author | Gabriele M <moto.falcon.git@gmail.com> | 2018-06-14 01:10:09 +0200 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2023-12-27 00:35:28 +0800 |
commit | 3821b4eeb50bdf0faf99577dcb1c0e47978e5692 (patch) | |
tree | 76c39c4476df0c7ab3660541bb983267254cb12b | |
parent | b52aa7706ec32556e3749284bc52f5de9ce595c7 (diff) |
update_engine: Add performance modeumineko
Author: Gabriele M <moto.falcon.git@gmail.com>
Date: Thu Jun 14 01:10:09 2018 +0200
update_engine: Add performance mode
Allow to move update_engine from the system-background cgroup
to the foreground cgroup to speed up the installation of the
updates.
Change-Id: Iaa531a925f9e1a26e834d7448c4755151adcfea2
Author: Luca Stefani <luca.stefani.ge1@gmail.com>
Date: Mon Mar 4 14:57:28 2019 +0100
Move performance mode to top app
Change-Id: I436102b4f8d046b8f3d897882613ec46acf9e2c5
luca020400: Move to TaskProfiles API
Change-Id: Id7e27b0c42d80c4a3ce1dc7f8540313a7042db53
-rw-r--r-- | Android.bp | 1 | ||||
-rw-r--r-- | aosp/binder_service_android.cc | 7 | ||||
-rw-r--r-- | aosp/binder_service_android.h | 1 | ||||
-rw-r--r-- | aosp/service_delegate_android_interface.h | 2 | ||||
-rw-r--r-- | aosp/update_attempter_android.cc | 19 | ||||
-rw-r--r-- | aosp/update_attempter_android.h | 4 | ||||
-rw-r--r-- | aosp/update_engine_client_android.cc | 5 | ||||
-rw-r--r-- | binder_bindings/android/os/IUpdateEngine.aidl | 2 | ||||
-rw-r--r-- | update_engine.rc | 1 |
9 files changed, 41 insertions, 1 deletions
@@ -215,6 +215,7 @@ cc_defaults { "libfec", "liblz4", "libziparchive", + "libprocessgroup", ], } diff --git a/aosp/binder_service_android.cc b/aosp/binder_service_android.cc index 84b5b7a9..c2231fb0 100644 --- a/aosp/binder_service_android.cc +++ b/aosp/binder_service_android.cc @@ -258,4 +258,11 @@ Status BinderUpdateEngineAndroidService::cleanupSuccessfulUpdate( return Status::ok(); } +Status BinderUpdateEngineAndroidService::setPerformanceMode(bool enable) { + brillo::ErrorPtr error; + if (!service_delegate_->SetPerformanceMode(enable, &error)) + return ErrorPtrToStatus(error); + return Status::ok(); +} + } // namespace chromeos_update_engine diff --git a/aosp/binder_service_android.h b/aosp/binder_service_android.h index f1ce6b5d..6bd1ee3c 100644 --- a/aosp/binder_service_android.h +++ b/aosp/binder_service_android.h @@ -79,6 +79,7 @@ class BinderUpdateEngineAndroidService : public android::os::BnUpdateEngine, int64_t* return_value) override; android::binder::Status cleanupSuccessfulUpdate( const android::sp<android::os::IUpdateEngineCallback>& callback) override; + android::binder::Status setPerformanceMode(bool enable) override; private: // Remove the passed |callback| from the list of registered callbacks. Called diff --git a/aosp/service_delegate_android_interface.h b/aosp/service_delegate_android_interface.h index b3660ab3..b50f0f93 100644 --- a/aosp/service_delegate_android_interface.h +++ b/aosp/service_delegate_android_interface.h @@ -129,6 +129,8 @@ class ServiceDelegateAndroidInterface { std::unique_ptr<CleanupSuccessfulUpdateCallbackInterface> callback, brillo::ErrorPtr* error) = 0; + virtual bool SetPerformanceMode(bool enable, brillo::ErrorPtr* error) = 0; + protected: ServiceDelegateAndroidInterface() = default; }; diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc index 56281092..92a0aad1 100644 --- a/aosp/update_attempter_android.cc +++ b/aosp/update_attempter_android.cc @@ -32,6 +32,7 @@ #include <brillo/message_loops/message_loop.h> #include <brillo/strings/string_utils.h> #include <log/log_safetynet.h> +#include <processgroup/processgroup.h> #include "update_engine/aosp/cleanup_previous_update_action.h" #include "update_engine/common/clock.h" @@ -151,6 +152,7 @@ UpdateAttempterAndroid::UpdateAttempterAndroid( metrics_reporter_ = metrics::CreateMetricsReporter( boot_control_->GetDynamicPartitionControl(), &install_plan_); network_selector_ = network::CreateNetworkSelector(); + SetTaskProfiles(0, {"OtaProfiles"}); } UpdateAttempterAndroid::~UpdateAttempterAndroid() { @@ -578,6 +580,23 @@ bool UpdateAttempterAndroid::VerifyPayloadApplicable( return true; } +bool UpdateAttempterAndroid::SetPerformanceMode(bool enable, + brillo::ErrorPtr* error) { + LOG(INFO) << (enable ? "Enabling" : "Disabling") << " performance mode."; + + if (performance_mode_ == enable) + return true; + bool ret; + if (enable) + ret = SetTaskProfiles(0, {"ProcessCapacityMax", "HighIoPriority", "MaxPerformance"}); + else + ret = SetTaskProfiles(0, {"OtaProfiles"}); + if (!ret) + return LogAndSetError(error, FROM_HERE, "Could not change profiles"); + performance_mode_ = enable; + return true; +} + void UpdateAttempterAndroid::ProcessingDone(const ActionProcessor* processor, ErrorCode code) { LOG(INFO) << "Processing Done."; diff --git a/aosp/update_attempter_android.h b/aosp/update_attempter_android.h index c2226b20..3c67941d 100644 --- a/aosp/update_attempter_android.h +++ b/aosp/update_attempter_android.h @@ -100,6 +100,8 @@ class UpdateAttempterAndroid brillo::ErrorPtr* error) override; bool resetShouldSwitchSlotOnReboot(brillo::ErrorPtr* error) override; + bool SetPerformanceMode(bool enable, brillo::ErrorPtr* error) override; + // ActionProcessorDelegate methods: void ProcessingDone(const ActionProcessor* processor, ErrorCode code) override; @@ -285,6 +287,8 @@ class UpdateAttempterAndroid metrics_utils::PersistedValue<int64_t> metric_bytes_downloaded_; metrics_utils::PersistedValue<int64_t> metric_total_bytes_downloaded_; + bool performance_mode_ = false; + DISALLOW_COPY_AND_ASSIGN(UpdateAttempterAndroid); }; diff --git a/aosp/update_engine_client_android.cc b/aosp/update_engine_client_android.cc index c00e9f58..a3504099 100644 --- a/aosp/update_engine_client_android.cc +++ b/aosp/update_engine_client_android.cc @@ -169,6 +169,7 @@ int UpdateEngineClientAndroid::OnInit() { false, "Wait for previous update to merge. " "Only available after rebooting to new slot."); + DEFINE_bool(perf_mode, false, "Enable perf mode."); // Boilerplate init commands. base::CommandLine::Init(argc_, argv_); brillo::FlagHelper::Init(argc_, argv_, "Android Update Engine Client"); @@ -292,6 +293,10 @@ int UpdateEngineClientAndroid::OnInit() { keep_running = true; } + if (FLAGS_perf_mode) { + return ExitWhenIdle(service_->setPerformanceMode(true)); + } + if (FLAGS_update) { auto and_headers = ParseHeaders(FLAGS_headers); Status status = service_->applyPayload( diff --git a/binder_bindings/android/os/IUpdateEngine.aidl b/binder_bindings/android/os/IUpdateEngine.aidl index 4043b1a5..061397cc 100644 --- a/binder_bindings/android/os/IUpdateEngine.aidl +++ b/binder_bindings/android/os/IUpdateEngine.aidl @@ -76,4 +76,6 @@ interface IUpdateEngine { * but needs reboot). DEVICE_CORRUPTED for permanent errors. */ void cleanupSuccessfulUpdate(IUpdateEngineCallback callback); + /** @hide */ + void setPerformanceMode(in boolean enable); } diff --git a/update_engine.rc b/update_engine.rc index bc6447b2..76072d54 100644 --- a/update_engine.rc +++ b/update_engine.rc @@ -2,7 +2,6 @@ service update_engine /system/bin/update_engine --logtostderr --logtofile --fore class late_start user root group root system wakelock inet cache media_rw - task_profiles OtaProfiles disabled on property:ro.boot.slot_suffix=* |