summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriele M <moto.falcon.git@gmail.com>2018-06-14 01:10:09 +0200
committeralk3pInjection <webmaster@raspii.tech>2022-02-05 20:27:30 +0800
commitec8d623b74826a51fa08599f62a354b473a7da24 (patch)
tree385bc9169f1d85abd0b87cc49296f32976f0e81b
parent2787b94effe7d2fa1496823d982692b394772c19 (diff)
update_engine: Add performance modeHEADsugisawa-mr1sugisawa
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.bp1
-rw-r--r--aosp/binder_service_android.cc7
-rw-r--r--aosp/binder_service_android.h1
-rw-r--r--aosp/service_delegate_android_interface.h2
-rw-r--r--aosp/update_attempter_android.cc19
-rw-r--r--aosp/update_attempter_android.h4
-rw-r--r--aosp/update_engine_client_android.cc5
-rw-r--r--binder_bindings/android/os/IUpdateEngine.aidl2
-rw-r--r--update_engine.rc1
9 files changed, 41 insertions, 1 deletions
diff --git a/Android.bp b/Android.bp
index d74e78f3..5b6b9e68 100644
--- a/Android.bp
+++ b/Android.bp
@@ -189,6 +189,7 @@ cc_defaults {
"libcrypto",
"libfec",
"libziparchive",
+ "libprocessgroup",
],
}
diff --git a/aosp/binder_service_android.cc b/aosp/binder_service_android.cc
index ed76c4a8..9efd272d 100644
--- a/aosp/binder_service_android.cc
+++ b/aosp/binder_service_android.cc
@@ -240,4 +240,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 f41fbdf2..6bfe2923 100644
--- a/aosp/binder_service_android.h
+++ b/aosp/binder_service_android.h
@@ -76,6 +76,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 3c287940..1ac71533 100644
--- a/aosp/service_delegate_android_interface.h
+++ b/aosp/service_delegate_android_interface.h
@@ -118,6 +118,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 4636c430..bc03a1f2 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -30,6 +30,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/constants.h"
@@ -144,6 +145,7 @@ UpdateAttempterAndroid::UpdateAttempterAndroid(
metrics_reporter_ = metrics::CreateMetricsReporter(
boot_control_->GetDynamicPartitionControl(), &install_plan_);
network_selector_ = network::CreateNetworkSelector();
+ SetTaskProfiles(0, {"ServiceCapacityLow", "LowIoPriority", "HighEnergySaving"});
}
UpdateAttempterAndroid::~UpdateAttempterAndroid() {
@@ -541,6 +543,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, {"ServiceCapacityLow", "LowIoPriority", "HighEnergySaving"});
+ 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 70938bcd..f7c48a2d 100644
--- a/aosp/update_attempter_android.h
+++ b/aosp/update_attempter_android.h
@@ -90,6 +90,8 @@ class UpdateAttempterAndroid
std::unique_ptr<CleanupSuccessfulUpdateCallbackInterface> callback,
brillo::ErrorPtr* error) override;
+ bool SetPerformanceMode(bool enable, brillo::ErrorPtr* error) override;
+
// ActionProcessorDelegate methods:
void ProcessingDone(const ActionProcessor* processor,
ErrorCode code) override;
@@ -245,6 +247,8 @@ class UpdateAttempterAndroid
// CleanupPreviousUpdateAction has not been executed.
std::optional<ErrorCode> cleanup_previous_update_code_{std::nullopt};
+ 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 1a68cf49..2b3cfffe 100644
--- a/aosp/update_engine_client_android.cc
+++ b/aosp/update_engine_client_android.cc
@@ -149,6 +149,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");
@@ -237,6 +238,10 @@ int UpdateEngineClientAndroid::OnInit() {
keep_running = true;
}
+ if (FLAGS_perf_mode) {
+ return ExitWhenIdle(service_->setPerformanceMode(true));
+ }
+
if (FLAGS_follow) {
// Register a callback object with the service.
callback_ = new UECallback(this);
diff --git a/binder_bindings/android/os/IUpdateEngine.aidl b/binder_bindings/android/os/IUpdateEngine.aidl
index c9580da4..363cec2c 100644
--- a/binder_bindings/android/os/IUpdateEngine.aidl
+++ b/binder_bindings/android/os/IUpdateEngine.aidl
@@ -71,4 +71,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 aa39211a..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 ServiceCapacityLow LowIoPriority HighEnergySaving
disabled
on property:ro.boot.slot_suffix=*