From de6707df0c0decfeb92a1e73a64d3a610e16d061 Mon Sep 17 00:00:00 2001 From: Liana Kazanova Date: Thu, 31 Oct 2024 18:43:18 +0000 Subject: [PATCH] Revert "Set input thread priority to RT" This reverts commit 930f77b02c8ba5a7bb8e54653455f9885d90748a. Reason for revert: DroidMonitor: Potential culprit for http://b/376665573 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Change-Id: I9b9914703946f1eb4e40e779aa9cb5154ea108d3 --- libprocessgroup/profiles/task_profiles.json | 15 +----- libprocessgroup/task_profiles.cpp | 56 ++++++--------------- 2 files changed, 17 insertions(+), 54 deletions(-) diff --git a/libprocessgroup/profiles/task_profiles.json b/libprocessgroup/profiles/task_profiles.json index d61939f29..feda3b49c 100644 --- a/libprocessgroup/profiles/task_profiles.json +++ b/libprocessgroup/profiles/task_profiles.json @@ -202,19 +202,6 @@ } ] }, - { - "Name": "RealTimeInputScheduling", - "Actions": [ - { - "Name": "SetSchedulerPolicy", - "Params": - { - "Policy": "SCHED_FIFO", - "Priority": "98" - } - } - ] - }, { "Name": "CameraServicePerformance", "Actions": [ @@ -717,7 +704,7 @@ }, { "Name": "InputPolicy", - "Profiles": [ "RealTimeInputScheduling", "MaxPerformance", "ProcessCapacityMax", "TimerSlackNormal" ] + "Profiles": [ "MaxPerformance", "ProcessCapacityMax", "TimerSlackNormal" ] } ] } diff --git a/libprocessgroup/task_profiles.cpp b/libprocessgroup/task_profiles.cpp index f3594e345..cc675b3fe 100644 --- a/libprocessgroup/task_profiles.cpp +++ b/libprocessgroup/task_profiles.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -55,7 +54,6 @@ static constexpr const char* TASK_PROFILE_DB_VENDOR_FILE = "/vendor/etc/task_pro static constexpr const char* TEMPLATE_TASK_PROFILE_API_FILE = "/etc/task_profiles/task_profiles_%u.json"; -namespace { class FdCacheHelper { public: @@ -66,11 +64,8 @@ class FdCacheHelper { }; static void Cache(const std::string& path, android::base::unique_fd& fd); - static void Drop(android::base::unique_fd& fd); - static void Init(const std::string& path, android::base::unique_fd& fd); - static bool IsCached(const android::base::unique_fd& fd) { return fd > FDS_INACCESSIBLE; } private: @@ -121,17 +116,6 @@ bool FdCacheHelper::IsAppDependentPath(const std::string& path) { return path.find("", 0) != std::string::npos || path.find("", 0) != std::string::npos; } -std::optional readLong(const std::string& str) { - char* end; - const long result = strtol(str.c_str(), &end, 10); - if (end > str.c_str()) { - return result; - } - return std::nullopt; -} - -} // namespace - IProfileAttribute::~IProfileAttribute() = default; const std::string& ProfileAttribute::file_name() const { @@ -940,12 +924,15 @@ bool TaskProfiles::Load(const CgroupMap& cg_map, const std::string& file_name) { LOG(WARNING) << "JoinCgroup: controller " << controller_name << " is not found"; } } else if (action_name == "SetTimerSlack") { - const std::string slack_string = params_val["Slack"].asString(); - std::optional slack = readLong(slack_string); - if (slack && *slack >= 0) { - profile->Add(std::make_unique(*slack)); + std::string slack_value = params_val["Slack"].asString(); + char* end; + unsigned long slack; + + slack = strtoul(slack_value.c_str(), &end, 10); + if (end > slack_value.c_str()) { + profile->Add(std::make_unique(slack)); } else { - LOG(WARNING) << "SetTimerSlack: invalid parameter: " << slack_string; + LOG(WARNING) << "SetTimerSlack: invalid parameter: " << slack_value; } } else if (action_name == "SetAttribute") { std::string attr_name = params_val["Name"].asString(); @@ -1004,19 +991,15 @@ bool TaskProfiles::Load(const CgroupMap& cg_map, const std::string& file_name) { // If present, this optional value will be passed in an additional syscall // to setpriority(), since the sched_priority value must be 0 for calls to // sched_setscheduler() with "normal" policies. - const std::string nice_string = params_val["Nice"].asString(); - const std::optional nice = readLong(nice_string); + const int nice = params_val["Nice"].asInt(); - if (!nice) { - LOG(FATAL) << "Invalid nice value specified: " << nice_string; - } const int LINUX_MIN_NICE = -20; const int LINUX_MAX_NICE = 19; - if (*nice < LINUX_MIN_NICE || *nice > LINUX_MAX_NICE) { - LOG(WARNING) << "SetSchedulerPolicy: Provided nice (" << *nice + if (nice < LINUX_MIN_NICE || nice > LINUX_MAX_NICE) { + LOG(WARNING) << "SetSchedulerPolicy: Provided nice (" << nice << ") appears out of range."; } - profile->Add(std::make_unique(policy, *nice)); + profile->Add(std::make_unique(policy, nice)); } else { profile->Add(std::make_unique(policy)); } @@ -1029,18 +1012,11 @@ bool TaskProfiles::Load(const CgroupMap& cg_map, const std::string& file_name) { // This is a "virtual priority" as described by `man 2 sched_get_priority_min` // that will be mapped onto the following range for the provided policy: // [sched_get_priority_min(), sched_get_priority_max()] + const int virtual_priority = params_val["Priority"].asInt(); - const std::string priority_string = params_val["Priority"].asString(); - std::optional virtual_priority = readLong(priority_string); - if (virtual_priority && *virtual_priority > 0) { - int priority; - if (SetSchedulerPolicyAction::toPriority(policy, *virtual_priority, - priority)) { - profile->Add( - std::make_unique(policy, priority)); - } - } else { - LOG(WARNING) << "Invalid priority value: " << priority_string; + int priority; + if (SetSchedulerPolicyAction::toPriority(policy, virtual_priority, priority)) { + profile->Add(std::make_unique(policy, priority)); } } } else {