Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modula/Components/DLManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions modula/Components/Include/DLManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 17 additions & 18 deletions resource-tuner/core/CocoTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> CocoTable::mCocoTableInstance = nullptr;
std::mutex CocoTable::instanceProtectionLock {};

Expand Down Expand Up @@ -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);

Expand All @@ -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.
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion resource-tuner/core/Include/CocoTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class CocoTable {

void fastPathApply(Resource* resource);
void fastPathReset(Resource* resource);
int8_t needsAllocation(Resource* res);

public:
~CocoTable();
Expand Down