4#ifndef TARGET_REGISTRY_H
5#define TARGET_REGISTRY_H
21#include <unordered_map>
25#include "AuxRoutines.h"
27#define POLICY_DIR_PATH "/sys/devices/system/cpu/cpufreq/"
28#define ONLINE_CPU_FILE_PATH "/sys/devices/system/cpu/online"
29#define CPU_CAPACITY_FILE_PATH "/sys/devices/system/cpu/cpu%d/cpu_capacity"
35 GET_PHYSICAL_CLUSTER_ID,
89 static std::shared_ptr<TargetRegistry> targetRegistryInstance;
91 std::unordered_map<int32_t, int32_t> mLogicalToPhysicalClusterMapping;
92 std::unordered_map<int32_t, ClusterInfo*> mPhysicalClusters;
93 std::unordered_map<int32_t, CGroupConfigInfo*> mCGroupMapping;
94 std::unordered_map<int32_t, MpamGroupConfigInfo*> mMpamGroupMapping;
95 std::unordered_map<std::string, CacheInfo*> mCacheInfoMapping;
99 void generatePolicyBasedMapping(std::vector<std::string>& policyDirs);
100 void getClusterIdBasedMapping();
106 void addClusterSpreadInfo(
const std::string& physicalID,
const std::string& coreCount);
107 void addClusterMapping(
const std::string& logicalID,
const std::string& physicalID);
115 void addCacheInfoMapping(
CacheInfo* cacheInfo);
117 void getClusterIDs(std::vector<int32_t>& clusterIDs);
143 ClusterInfo* getClusterInfo(int32_t physicalClusterID);
164 void getCGroupNames(std::vector<std::string>& cGroupNames);
165 void getCGroupConfigs(std::vector<CGroupConfigInfo*>& cGroupConfigs);
166 int32_t getCreatedCGroupsCount();
169 void getMpamGroupNames(std::vector<std::string>& cGroupNames);
170 int32_t getCreatedMpamGroupsCount();
172 void displayTargetInfo();
174 ErrCode addIrqAffine(std::vector<std::string>& values,
175 int8_t areClusterValues =
false);
176 ErrCode addLogLimit(std::vector<std::string>& values);
178 static std::shared_ptr<TargetRegistry> getInstance() {
179 if(targetRegistryInstance ==
nullptr) {
180 targetRegistryInstance = std::shared_ptr<TargetRegistry>(
new TargetRegistry());
182 return targetRegistryInstance;
186class CGroupConfigInfoBuilder {
188 CGroupConfigInfo* mCGroupConfigInfo;
191 CGroupConfigInfoBuilder();
193 ErrCode setCGroupName(
const std::string& cGroupName);
194 ErrCode setCGroupID(
const std::string& cGroupIdentifier);
195 ErrCode setCreationNeeded(
const std::string& creationNeeded);
196 ErrCode setThreaded(
const std::string& isThreaded);
198 CGroupConfigInfo* build();
201class MpamGroupConfigInfoBuilder {
203 MpamGroupConfigInfo* mMpamGroupInfo;
206 MpamGroupConfigInfoBuilder();
208 ErrCode setName(
const std::string& name);
209 ErrCode setLgcID(
const std::string& logicalID);
210 ErrCode setPriority(
const std::string& priority);
212 MpamGroupConfigInfo* build();
215class CacheInfoBuilder {
217 CacheInfo* mCacheInfo;
222 ErrCode setType(
const std::string& type);
223 ErrCode setNumBlocks(
const std::string& numBlocks);
224 ErrCode setPriorityAware(
const std::string& isPriorityAware);
230uint64_t GET_TARGET_INFO(int32_t option,
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.