Userspace Resource Manager
Loading...
Searching...
No Matches
CocoTable.h
Go to the documentation of this file.
1// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2// SPDX-License-Identifier: BSD-3-Clause-Clear
3
4#ifndef COCOQ_H
5#define COCOQ_H
6
7#include <fstream>
8#include <vector>
9#include <unordered_map>
10#include <mutex>
11#include <cerrno>
12#include <atomic>
13#include <cstring>
14#include <memory>
15
16#include "ResourceRegistry.h"
17#include "TargetRegistry.h"
18#include "Request.h"
19#include "RequestQueue.h"
20#include "UrmSettings.h"
21#include "MemoryPool.h"
22#include "Logger.h"
23#include "Utils.h"
24
90class CocoTable {
91private:
92 static std::shared_ptr<CocoTable> mCocoTableInstance;
93 static std::mutex instanceProtectionLock;
94
95 std::vector<ResConfInfo*> mResourceTable;
96 std::unordered_map<int32_t, int32_t> mFlatClusterMap;
97 std::unordered_map<int32_t, int32_t> mFlatCGroupMap;
98
99 std::shared_ptr<ResourceRegistry> mResourceRegistry;
100
105 std::vector<std::vector<DLManager*>> mCocoTable;
106
110 std::vector<int32_t> mCurrentlyAppliedPriority;
111
112 CocoTable();
113
114 void timerExpired(Request* req);
115 void applyAction(ResIterable* currNode, int32_t index, int8_t priority);
116 void removeAction(int32_t index, Resource* resource);
117
118 int32_t getCocoTablePrimaryIndex(uint32_t resCode);
119 int32_t getCocoTableSecondaryIndex(Resource* resource, int8_t priority);
120
121 void deleteNode(ResIterable* node,
122 int32_t primaryIndex,
123 int32_t secondaryIndex);
124
125 int8_t insertInCocoTable(ResIterable* currNode, int8_t priority);
126
127 void fastPathApply(Resource* resource);
128 void fastPathReset(Resource* resource);
129 int8_t needAllocation(Resource* res);
130
131public:
132 ~CocoTable();
133
145 int8_t insertRequest(Request* req);
146
158 int8_t removeRequest(Request* req);
159
171 int8_t updateRequest(Request* req, int64_t duration);
172
173 static std::shared_ptr<CocoTable> getInstance() {
174 if(mCocoTableInstance == nullptr) {
175 instanceProtectionLock.lock();
176 if(mCocoTableInstance == nullptr) {
177 try {
178 mCocoTableInstance = std::shared_ptr<CocoTable> (new CocoTable());
179 } catch(const std::bad_alloc& e) {
180 instanceProtectionLock.unlock();
181 return nullptr;
182 }
183 }
184 instanceProtectionLock.unlock();
185 }
186 return mCocoTableInstance;
187 }
188};
189
190#endif
191
CocoTable.
Definition CocoTable.h:90
int8_t insertRequest(Request *req)
Used to insert a request into the CocoTable, so that it can be applied to the desired Resource Nodes.
std::vector< int32_t > mCurrentlyAppliedPriority
Data structure storing the currently applied priority for each resource.
Definition CocoTable.h:110
int8_t removeRequest(Request *req)
Used to untune a previously issued Tune Request.
std::vector< std::vector< DLManager * > > mCocoTable
The main data structure which is a 2D vector. It stores entries for each resource and each entry stor...
Definition CocoTable.h:105
int8_t updateRequest(Request *req, int64_t duration)
Used to update the duration of an Active Request.
Encapsulation type for a Resource Provisioning Request.
Definition Request.h:23
Used to store information regarding Resources / Tunables which need to be Provisioned as part of the ...
Definition Resource.h:17