diff options
author | Wei Wang <wvw@google.com> | 2018-06-06 11:20:36 -0700 |
---|---|---|
committer | Wei Wang <wvw@google.com> | 2018-09-28 17:49:51 +0000 |
commit | 23fa94128f73282f62a410a37bdcd415265a62f7 (patch) | |
tree | 4e6f8daf58332069fde6f7fb36204ecbc2d862ed | |
parent | fa9ce0e4a240d50fde168369c2095d1e14241a97 (diff) | |
download | extras-23fa94128f73282f62a410a37bdcd415265a62f7.tar.gz |
libperfmgr: Update nodes in 2 passesandroid-9.0.0_r47android-9.0.0_r46android-9.0.0_r45android-9.0.0_r44android-9.0.0_r43android-9.0.0_r42android-9.0.0_r41android-9.0.0_r40android-9.0.0_r37android-9.0.0_r36pie-qpr3-s1-releasepie-qpr3-releasepie-qpr3-b-releasepie-b4s4-dev
Some nodes have dependency in each other: e.g cpufreq min/max
Bug: 116855734
Test: libperfmgr_test pass
Change-Id: Ica639b94e78d40fd0f21fb8f241dc1887a6756fc
-rw-r--r-- | libperfmgr/Node.cc | 8 | ||||
-rw-r--r-- | libperfmgr/NodeLooperThread.cc | 10 | ||||
-rw-r--r-- | libperfmgr/include/perfmgr/Node.h | 2 |
3 files changed, 14 insertions, 6 deletions
diff --git a/libperfmgr/Node.cc b/libperfmgr/Node.cc index 63cf8aaa..c35c3ca1 100644 --- a/libperfmgr/Node.cc +++ b/libperfmgr/Node.cc @@ -66,7 +66,7 @@ bool Node::RemoveRequest(const std::string& hint_type) { return ret; } -std::chrono::milliseconds Node::Update() { +std::chrono::milliseconds Node::Update(bool log_error) { std::size_t value_index = default_val_index_; std::chrono::milliseconds expire_time = std::chrono::milliseconds::max(); @@ -86,8 +86,10 @@ std::chrono::milliseconds Node::Update() { open(node_path_.c_str(), O_WRONLY | O_CLOEXEC | O_TRUNC))); if (fd_ == -1 || !android::base::WriteStringToFd(req_value, fd_)) { - LOG(ERROR) << "Failed to write to node: " << node_path_ - << " with value: " << req_value << ", fd: " << fd_; + if (log_error) { + LOG(WARNING) << "Failed to write to node: " << node_path_ + << " with value: " << req_value << ", fd: " << fd_; + } // Retry in 500ms or sooner expire_time = std::min(expire_time, std::chrono::milliseconds(500)); } else { diff --git a/libperfmgr/NodeLooperThread.cc b/libperfmgr/NodeLooperThread.cc index e7a63cc5..b4a27a96 100644 --- a/libperfmgr/NodeLooperThread.cc +++ b/libperfmgr/NodeLooperThread.cc @@ -98,9 +98,15 @@ void NodeLooperThread::DumpToFd(int fd) { bool NodeLooperThread::threadLoop() { ::android::AutoMutex _l(lock_); std::chrono::milliseconds timeout_ms = kMaxUpdatePeriod; + + // Update 2 passes: some node may have dependency in other node + // e.g. update cpufreq min to VAL while cpufreq max still set to + // a value lower than VAL, is expected to fail in first pass + for (auto& n : nodes_) { + n->Update(false); + } for (auto& n : nodes_) { - auto t = n->Update(); - timeout_ms = std::min(t, timeout_ms); + timeout_ms = std::min(n->Update(), timeout_ms); } nsecs_t sleep_timeout_ns = std::numeric_limits<nsecs_t>::max(); diff --git a/libperfmgr/include/perfmgr/Node.h b/libperfmgr/include/perfmgr/Node.h index ea4c3e34..560979b0 100644 --- a/libperfmgr/include/perfmgr/Node.h +++ b/libperfmgr/include/perfmgr/Node.h @@ -61,7 +61,7 @@ class Node { // std::chrono::milliseconds::max() if no active request on Node; update // node's controlled file node value and the current value index based on // active request. - std::chrono::milliseconds Update(); + std::chrono::milliseconds Update(bool log_error = true); std::string GetName() const; std::string GetPath() const; |