logd: clearAll by UID speedup
(cherry pick from commit 2b25c66070)
- If doing a clear, skip accounting
- Ensure for busy checking, behind a region lock for instance, only
break out if there was something to do. Basically move the filter
actions first, and defer checking the region lock to the ends of
the loops.
Bug: 23711431
Change-Id: Icc984f406880633516fb17dda84188a30d092e01
This commit is contained in:
parent
5679d8d572
commit
9bc35ef4c9
1 changed files with 11 additions and 16 deletions
|
|
@ -377,6 +377,7 @@ public:
|
|||
bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
|
||||
LogTimeEntry *oldest = NULL;
|
||||
bool busy = false;
|
||||
bool clearAll = pruneRows == ULONG_MAX;
|
||||
|
||||
LogTimeEntry::lock();
|
||||
|
||||
|
|
@ -394,29 +395,23 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
|
|||
LogBufferElementCollection::iterator it;
|
||||
|
||||
if (caller_uid != AID_ROOT) {
|
||||
// Only here if clearAll condition (pruneRows == ULONG_MAX)
|
||||
for(it = mLogElements.begin(); it != mLogElements.end();) {
|
||||
LogBufferElement *e = *it;
|
||||
|
||||
if ((e->getLogId() != id) || (e->getUid() != caller_uid)) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oldest && (oldest->mStart <= e->getSequence())) {
|
||||
oldest->triggerSkip_Locked(id, pruneRows);
|
||||
busy = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (e->getLogId() != id) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e->getUid() == caller_uid) {
|
||||
it = erase(it);
|
||||
pruneRows--;
|
||||
if (pruneRows == 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
it = erase(it);
|
||||
pruneRows--;
|
||||
}
|
||||
LogTimeEntry::unlock();
|
||||
return busy;
|
||||
|
|
@ -424,7 +419,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
|
|||
|
||||
// prune by worst offender by uid
|
||||
bool hasBlacklist = mPrune.naughty();
|
||||
while (pruneRows > 0) {
|
||||
while (!clearAll && (pruneRows > 0)) {
|
||||
// recalculate the worst offender on every batched pass
|
||||
uid_t worst = (uid_t) -1;
|
||||
size_t worst_sizes = 0;
|
||||
|
|
@ -592,7 +587,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
|
|||
}
|
||||
|
||||
bool whitelist = false;
|
||||
bool hasWhitelist = mPrune.nice();
|
||||
bool hasWhitelist = mPrune.nice() && !clearAll;
|
||||
it = mLogElements.begin();
|
||||
while((pruneRows > 0) && (it != mLogElements.end())) {
|
||||
LogBufferElement *e = *it;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue