summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2017-04-18 16:09:45 -0500
committerMark Salyzyn2017-04-20 10:24:38 -0500
commit3c501b50b41086cde59a6811f4aa5cd3e736f5f2 (patch)
treef965acd1a431bce77613286cd9a6dd33ed1190a3 /logd/LogTimes.cpp
parente32517d7739f32014695d3082da50ab0186460c3 (diff)
downloadplatform-system-core-3c501b50b41086cde59a6811f4aa5cd3e736f5f2.tar.gz
platform-system-core-3c501b50b41086cde59a6811f4aa5cd3e736f5f2.tar.xz
platform-system-core-3c501b50b41086cde59a6811f4aa5cd3e736f5f2.zip
logd: reader/writer element locks
Switch to a reader writer lock for the Element List lock. Also setup for a reader writer lock for the Times list, but continue to use a mutex where rdlock() and wrlock() are the same implementation for now. This should improve general reader performance and prevent blocking of other reader operations or exit by a single hung logd.reader.per thread. For example, a full length logcat of an empty buffer (eg: crash log buffer) will hold a lock while the iterator scans the entire list. Test: gTest liblog-unit-tests, logd-unit-tests, logcat-unit-tests Bug: 37378309 Bug: 37483775 Change-Id: If5723ff4a978e17d828a75321e8f0ba91d4a09e0
Diffstat (limited to 'logd/LogTimes.cpp')
-rw-r--r--logd/LogTimes.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/logd/LogTimes.cpp b/logd/LogTimes.cpp
index ccc550a73..25c2ad2b7 100644
--- a/logd/LogTimes.cpp
+++ b/logd/LogTimes.cpp
@@ -78,7 +78,7 @@ void LogTimeEntry::startReader_Locked(void) {
78void LogTimeEntry::threadStop(void* obj) { 78void LogTimeEntry::threadStop(void* obj) {
79 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj); 79 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
80 80
81 lock(); 81 wrlock();
82 82
83 if (me->mNonBlock) { 83 if (me->mNonBlock) {
84 me->error_Locked(); 84 me->error_Locked();
@@ -134,7 +134,7 @@ void* LogTimeEntry::threadStart(void* obj) {
134 134
135 me->leadingDropped = true; 135 me->leadingDropped = true;
136 136
137 lock(); 137 wrlock();
138 138
139 log_time start = me->mStart; 139 log_time start = me->mStart;
140 140
@@ -160,7 +160,7 @@ void* LogTimeEntry::threadStart(void* obj) {
160 start = logbuf.flushTo(client, start, me->mLastTid, privileged, 160 start = logbuf.flushTo(client, start, me->mLastTid, privileged,
161 security, FilterSecondPass, me); 161 security, FilterSecondPass, me);
162 162
163 lock(); 163 wrlock();
164 164
165 if (start == LogBufferElement::FLUSH_ERROR) { 165 if (start == LogBufferElement::FLUSH_ERROR) {
166 me->error_Locked(); 166 me->error_Locked();
@@ -191,7 +191,7 @@ void* LogTimeEntry::threadStart(void* obj) {
191int LogTimeEntry::FilterFirstPass(const LogBufferElement* element, void* obj) { 191int LogTimeEntry::FilterFirstPass(const LogBufferElement* element, void* obj) {
192 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj); 192 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
193 193
194 LogTimeEntry::lock(); 194 LogTimeEntry::wrlock();
195 195
196 if (me->leadingDropped) { 196 if (me->leadingDropped) {
197 if (element->getDropped()) { 197 if (element->getDropped()) {
@@ -219,7 +219,7 @@ int LogTimeEntry::FilterFirstPass(const LogBufferElement* element, void* obj) {
219int LogTimeEntry::FilterSecondPass(const LogBufferElement* element, void* obj) { 219int LogTimeEntry::FilterSecondPass(const LogBufferElement* element, void* obj) {
220 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj); 220 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
221 221
222 LogTimeEntry::lock(); 222 LogTimeEntry::wrlock();
223 223
224 me->mStart = element->getRealTime(); 224 me->mStart = element->getRealTime();
225 225