Merge "Revert "logd: yield in FlushTo() if a write is pending""
diff --git a/logd/LogdLock.h b/logd/LogdLock.h
index 305720e..6f637c8 100644
--- a/logd/LogdLock.h
+++ b/logd/LogdLock.h
@@ -16,29 +16,6 @@
 
 #pragma once
 
-#include <linux/futex.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-
 #include <mutex>
 
-static inline int FutexCall(volatile void* ftx, int op, int value, const timespec* timeout,
-                            int bitset) {
-    int saved_errno = errno;
-    int result = syscall(__NR_futex, ftx, op, value, timeout, NULL, bitset);
-    if (result == -1) {
-        result = -errno;
-        errno = saved_errno;
-    }
-    return result;
-}
-
-static inline int FutexWake(volatile void* ftx) {
-    return FutexCall(ftx, FUTEX_WAKE_PRIVATE, INT_MAX, nullptr, 0);
-}
-
-static inline int FutexWait(volatile void* ftx, int value) {
-    return FutexCall(ftx, FUTEX_WAIT_BITSET_PRIVATE, value, nullptr, FUTEX_BITSET_MATCH_ANY);
-}
-
 extern std::mutex logd_lock;
diff --git a/logd/SerializedLogBuffer.cpp b/logd/SerializedLogBuffer.cpp
index 09e44d9..aa80864 100644
--- a/logd/SerializedLogBuffer.cpp
+++ b/logd/SerializedLogBuffer.cpp
@@ -86,30 +86,24 @@
 
     auto sequence = sequence_.fetch_add(1, std::memory_order_relaxed);
 
-    pending_write_ = true;
-    {
-        auto lock = std::lock_guard{logd_lock};
+    auto lock = std::lock_guard{logd_lock};
 
-        if (logs_[log_id].empty()) {
-            logs_[log_id].push_back(SerializedLogChunk(max_size_[log_id] / 4));
-        }
-
-        auto total_len = sizeof(SerializedLogEntry) + len;
-        if (!logs_[log_id].back().CanLog(total_len)) {
-            logs_[log_id].back().FinishWriting();
-            logs_[log_id].push_back(SerializedLogChunk(max_size_[log_id] / 4));
-        }
-
-        auto entry = logs_[log_id].back().Log(sequence, realtime, uid, pid, tid, msg, len);
-        stats_->Add(entry->ToLogStatisticsElement(log_id));
-
-        MaybePrune(log_id);
-
-        reader_list_->NotifyNewLog(1 << log_id);
+    if (logs_[log_id].empty()) {
+        logs_[log_id].push_back(SerializedLogChunk(max_size_[log_id] / 4));
     }
-    pending_write_ = false;
-    FutexWake(&pending_write_);
 
+    auto total_len = sizeof(SerializedLogEntry) + len;
+    if (!logs_[log_id].back().CanLog(total_len)) {
+        logs_[log_id].back().FinishWriting();
+        logs_[log_id].push_back(SerializedLogChunk(max_size_[log_id] / 4));
+    }
+
+    auto entry = logs_[log_id].back().Log(sequence, realtime, uid, pid, tid, msg, len);
+    stats_->Add(entry->ToLogStatisticsElement(log_id));
+
+    MaybePrune(log_id);
+
+    reader_list_->NotifyNewLog(1 << log_id);
     return len;
 }
 
@@ -211,16 +205,7 @@
                                          log_time realtime)>& filter) {
     auto& state = reinterpret_cast<SerializedFlushToState&>(abstract_state);
 
-    while (true) {
-        if (pending_write_) {
-            logd_lock.unlock();
-            FutexWait(&pending_write_, true);
-            logd_lock.lock();
-        }
-
-        if (!state.HasUnreadLogs()) {
-            break;
-        }
+    while (state.HasUnreadLogs()) {
         LogWithId top = state.PopNextUnreadLog();
         auto* entry = top.entry;
         auto log_id = top.log_id;
diff --git a/logd/SerializedLogBuffer.h b/logd/SerializedLogBuffer.h
index 2e57e73..239a81e 100644
--- a/logd/SerializedLogBuffer.h
+++ b/logd/SerializedLogBuffer.h
@@ -71,6 +71,4 @@
     std::list<SerializedLogChunk> logs_[LOG_ID_MAX] GUARDED_BY(logd_lock);
 
     std::atomic<uint64_t> sequence_ = 1;
-
-    std::atomic<bool> pending_write_ = false;
 };