diff --git a/modula/Components/DLManager.cpp b/modula/Components/DLManager.cpp index af5424450..2f9a65d2b 100644 --- a/modula/Components/DLManager.cpp +++ b/modula/Components/DLManager.cpp @@ -7,6 +7,7 @@ DLManager::DLManager(int32_t linkerInUse) { this->mLinkerInUse = linkerInUse; this->mHead = this->mTail = nullptr; this->mSize = 0; + this->mRank = 0; } // Insert at end diff --git a/modula/Components/Include/DLManager.h b/modula/Components/Include/DLManager.h index 9f0ee6faa..276d3e9e0 100644 --- a/modula/Components/Include/DLManager.h +++ b/modula/Components/Include/DLManager.h @@ -138,6 +138,7 @@ class DLManager { int32_t mTotalLinkers; int32_t mLinkerInUse; // must be a value b/w 0 to mTotalLinkers - 1 int32_t mSize; + int32_t mRank; // Declared as public so that the cb's can be selectively set at DLManager creation time. PolicyRepo mSavedPolicies; diff --git a/resource-tuner/core/CocoTable.cpp b/resource-tuner/core/CocoTable.cpp index 5dddcebc6..8ea47bdbc 100644 --- a/resource-tuner/core/CocoTable.cpp +++ b/resource-tuner/core/CocoTable.cpp @@ -47,11 +47,6 @@ static int8_t comparLBetter(DLRootNode* newNode, DLRootNode* targetNode) { return newValue < targetValue; } -int8_t CocoTable::needsAllocation(Resource* res) { - ResConfInfo* rConf = this->mResourceRegistry->getResConf(res->getResCode()); - return (rConf->mPolicy != Policy::PASS_THROUGH); -} - std::shared_ptr CocoTable::mCocoTableInstance = nullptr; std::mutex CocoTable::instanceProtectionLock {}; @@ -237,13 +232,6 @@ int8_t CocoTable::insertInCocoTable(ResIterable* newNode, int8_t priority) { Resource* resource = (Resource*) newNode->mData; ResConfInfo* rConf = this->mResourceRegistry->getResConf(resource->getResCode()); - // Special handling for resources with policy: "pass_through" - if(rConf->mPolicy == Policy::PASS_THROUGH) { - // straightaway apply the action - this->fastPathApply(resource); - return true; - } - int32_t primaryIndex = this->getCocoTablePrimaryIndex(resource->getResCode()); int32_t secondaryIndex = this->getCocoTableSecondaryIndex(resource, priority); @@ -262,6 +250,14 @@ int8_t CocoTable::insertInCocoTable(ResIterable* newNode, int8_t priority) { return false; } + // Special handling for resources with policy: "pass_through" + if(rConf->mPolicy == Policy::PASS_THROUGH) { + // straightaway apply the action + dlm->mRank++; + this->fastPathApply(resource); + return true; + } + switch(policy) { case INSTANT_APPLY: { // Insert this Request at the head of the linked list and apply it. @@ -425,12 +421,6 @@ int8_t CocoTable::removeRequest(Request* request) { Resource* resource = (Resource*) resIter->mData; - ResConfInfo* resourceConfig = this->mResourceRegistry->getResConf(resource->getResCode()); - if(resourceConfig->mPolicy == Policy::PASS_THROUGH) { - this->fastPathReset(resource); - continue; - } - int8_t priority = request->getPriority(); int32_t primaryIndex = this->getCocoTablePrimaryIndex(resource->getResCode()); int32_t secondaryIndex = this->getCocoTableSecondaryIndex(resource, priority); @@ -443,6 +433,15 @@ int8_t CocoTable::removeRequest(Request* request) { DLManager* dlm = this->mCocoTable[primaryIndex][secondaryIndex]; if(dlm == nullptr) continue; + + ResConfInfo* resourceConfig = this->mResourceRegistry->getResConf(resource->getResCode()); + if(resourceConfig->mPolicy == Policy::PASS_THROUGH) { + if(--dlm->mRank == 0) { + this->fastPathReset(resource); + } + continue; + } + int8_t nodeIsHead = dlm->isNodeNth(0, iter); // Proceed with removal of the node from CocoTable diff --git a/resource-tuner/core/Include/CocoTable.h b/resource-tuner/core/Include/CocoTable.h index b9a01f86d..61c6ee694 100644 --- a/resource-tuner/core/Include/CocoTable.h +++ b/resource-tuner/core/Include/CocoTable.h @@ -126,7 +126,6 @@ class CocoTable { void fastPathApply(Resource* resource); void fastPathReset(Resource* resource); - int8_t needsAllocation(Resource* res); public: ~CocoTable();