4#ifndef TARGET_REGISTRY_H
5#define TARGET_REGISTRY_H
12#include <unordered_map>
24#include "ResourceTunerSettings.h"
25#include "AuxRoutines.h"
29#define POLICY_DIR_PATH "/sys/devices/system/cpu/cpufreq/"
30#define ONLINE_CPU_FILE_PATH "/sys/devices/system/cpu/online"
31#define CPU_CAPACITY_FILE_PATH "/sys/devices/system/cpu/cpu%d/cpu_capacity"
82 static std::shared_ptr<TargetRegistry> targetRegistryInstance;
84 std::unordered_map<int32_t, int32_t> mLogicalToPhysicalClusterMapping;
85 std::unordered_map<int32_t, ClusterInfo*> mPhysicalClusters;
86 std::unordered_map<int32_t, CGroupConfigInfo*> mCGroupMapping;
87 std::unordered_map<int32_t, MpamGroupConfigInfo*> mMpamGroupMapping;
88 std::unordered_map<std::string, CacheInfo*> mCacheInfoMapping;
92 void generatePolicyBasedMapping(std::vector<std::string>& policyDirs);
93 void getClusterIdBasedMapping();
99 void addClusterSpreadInfo(
const std::string& physicalID,
const std::string& coreCount);
100 void addClusterMapping(
const std::string& logicalID,
const std::string& physicalID);
108 void addCacheInfoMapping(
CacheInfo* cacheInfo);
110 void getClusterIDs(std::vector<int32_t>& clusterIDs);
155 void getCGroupNames(std::vector<std::string>& cGroupNames);
156 int32_t getCreatedCGroupsCount();
159 void getMpamGroupNames(std::vector<std::string>& cGroupNames);
160 int32_t getCreatedMpamGroupsCount();
162 void displayTargetInfo();
164 static std::shared_ptr<TargetRegistry> getInstance() {
165 if(targetRegistryInstance ==
nullptr) {
166 targetRegistryInstance = std::shared_ptr<TargetRegistry>(
new TargetRegistry());
168 return targetRegistryInstance;
172class CGroupConfigInfoBuilder {
177 CGroupConfigInfoBuilder();
179 ErrCode setCGroupName(
const std::string& cGroupName);
180 ErrCode setCGroupID(
const std::string& cGroupIdentifier);
181 ErrCode setCreationNeeded(
const std::string& creationNeeded);
182 ErrCode setThreaded(
const std::string& isThreaded);
187class MpamGroupConfigInfoBuilder {
192 MpamGroupConfigInfoBuilder();
194 ErrCode setName(
const std::string& name);
195 ErrCode setLgcID(
const std::string& logicalID);
196 ErrCode setPriority(
const std::string& priority);
201class CacheInfoBuilder {
208 ErrCode setType(
const std::string& type);
209 ErrCode setNumBlocks(
const std::string& numBlocks);
210 ErrCode setPriorityAware(
const std::string& isPriorityAware);
ErrCode
Custom Error Codes used by Resource Tuner APIs and Internal Functions.
int32_t getPhysicalCoreId(int32_t logicalClusterId, int32_t logicalCoreId)
Called by the Verifier to get the physical core ID corresponding to the Logical Core ID value.
void readTargetInfo()
Called during Server Init, to read and Parse the Logical To Physical Core / Cluster Mappings.
int32_t getPhysicalClusterId(int32_t logicalClusterId)
Called by the Verifier to get the physical Cluster ID corresponding to the Logical Cluster ID value.
Representation of a single CGroup Configuration Info.
int32_t mCgroupID
32-bit identifier for the Cgroup (to be used as part of tuneResources API)
int8_t mIsThreaded
Flag indicating if the Cgroup is threaded.
int8_t mCreationNeeded
Flag indicating if Cgroup needs to be created by Resource Tuner, or if it already exists.
std::string mCgroupName
Cgroup Name.
Representation for a single Cluster Type Info.
int8_t mPriorityAware
Flag indicating if the Cache type is priority aware.
int32_t mNumCacheBlocks
Number of cache blocks for this type.
std::string mCacheType
Cache Type, for example: L2 or L3.
Representation for various Clusters detected on the device.
int32_t mCapacity
Cluster Capacity.
int32_t mNumCpus
Number of CPUs part of the Cluster.
int32_t mPhysicalID
Physical Cluster ID corresponding to the logical ID.
int32_t mStartCpu
Starting CPU index in this cluster.
Representation of a single Mpam Group Configuration Info.
int32_t mPriority
Mpam group Priority.
int32_t mMpamGroupInfoID
32-bit identifier for the Mpam Group (to be used as part of tuneResources API)
std::string mMpamGroupName
Mpam group Name.