Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-extras: Commit

system/extras


Commit MetaInfo

Revision23fa94128f73282f62a410a37bdcd415265a62f7 (tree)
Time2018-09-29 02:49:51
AuthorWei Wang <wvw@goog...>
CommiterWei Wang

Log Message

libperfmgr: Update nodes in 2 passes

Some nodes have dependency in each other: e.g cpufreq min/max

Bug: 116855734
Test: libperfmgr_test pass
Change-Id: Ica639b94e78d40fd0f21fb8f241dc1887a6756fc

Change Summary

Incremental Difference

--- a/libperfmgr/Node.cc
+++ b/libperfmgr/Node.cc
@@ -66,7 +66,7 @@ bool Node::RemoveRequest(const std::string& hint_type) {
6666 return ret;
6767 }
6868
69-std::chrono::milliseconds Node::Update() {
69+std::chrono::milliseconds Node::Update(bool log_error) {
7070 std::size_t value_index = default_val_index_;
7171 std::chrono::milliseconds expire_time = std::chrono::milliseconds::max();
7272
@@ -86,8 +86,10 @@ std::chrono::milliseconds Node::Update() {
8686 open(node_path_.c_str(), O_WRONLY | O_CLOEXEC | O_TRUNC)));
8787
8888 if (fd_ == -1 || !android::base::WriteStringToFd(req_value, fd_)) {
89- LOG(ERROR) << "Failed to write to node: " << node_path_
90- << " with value: " << req_value << ", fd: " << fd_;
89+ if (log_error) {
90+ LOG(WARNING) << "Failed to write to node: " << node_path_
91+ << " with value: " << req_value << ", fd: " << fd_;
92+ }
9193 // Retry in 500ms or sooner
9294 expire_time = std::min(expire_time, std::chrono::milliseconds(500));
9395 } else {
--- a/libperfmgr/NodeLooperThread.cc
+++ b/libperfmgr/NodeLooperThread.cc
@@ -98,9 +98,15 @@ void NodeLooperThread::DumpToFd(int fd) {
9898 bool NodeLooperThread::threadLoop() {
9999 ::android::AutoMutex _l(lock_);
100100 std::chrono::milliseconds timeout_ms = kMaxUpdatePeriod;
101+
102+ // Update 2 passes: some node may have dependency in other node
103+ // e.g. update cpufreq min to VAL while cpufreq max still set to
104+ // a value lower than VAL, is expected to fail in first pass
105+ for (auto& n : nodes_) {
106+ n->Update(false);
107+ }
101108 for (auto& n : nodes_) {
102- auto t = n->Update();
103- timeout_ms = std::min(t, timeout_ms);
109+ timeout_ms = std::min(n->Update(), timeout_ms);
104110 }
105111
106112 nsecs_t sleep_timeout_ns = std::numeric_limits<nsecs_t>::max();
--- a/libperfmgr/include/perfmgr/Node.h
+++ b/libperfmgr/include/perfmgr/Node.h
@@ -61,7 +61,7 @@ class Node {
6161 // std::chrono::milliseconds::max() if no active request on Node; update
6262 // node's controlled file node value and the current value index based on
6363 // active request.
64- std::chrono::milliseconds Update();
64+ std::chrono::milliseconds Update(bool log_error = true);
6565
6666 std::string GetName() const;
6767 std::string GetPath() const;
Show on old repository browser