Skip to content

Commit f312c4c

Browse files
authored
Init IRQ Options (#165)
--- Signed-off-by: Kartik Nema <kartnema@qti.qualcomm.com>
1 parent a89c172 commit f312c4c

8 files changed

Lines changed: 591 additions & 629 deletions

File tree

resource-tuner/core/Include/TargetRegistry.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ class TargetRegistry {
164164

165165
void displayTargetInfo();
166166

167+
ErrCode addIrqAffine(std::vector<std::string>& values,
168+
int8_t areClusterValues = false);
169+
167170
static std::shared_ptr<TargetRegistry> getInstance() {
168171
if(targetRegistryInstance == nullptr) {
169172
targetRegistryInstance = std::shared_ptr<TargetRegistry>(new TargetRegistry());

resource-tuner/core/TargetRegistry.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,74 @@ void TargetRegistry::addCacheInfoMapping(CacheInfo* cacheInfo) {
483483
this->mCacheInfoMapping[cacheInfo->mCacheType] = cacheInfo;
484484
}
485485

486+
ErrCode TargetRegistry::addIrqAffine(std::vector<std::string>& values,
487+
int8_t areClusterValues) {
488+
if(values.size() < 1) {
489+
return RC_INVALID_VALUE;
490+
}
491+
492+
uint64_t mask = 0;
493+
std::string dirPath = "/proc/irq/";
494+
495+
int32_t irqLine = std::stoi(values[0]);
496+
std::vector<int32_t> ids;
497+
for(int32_t i = 1; i < (int32_t)values.size(); i++) {
498+
ids.push_back(std::stoi(values[i]));
499+
}
500+
501+
if(areClusterValues) {
502+
for(int32_t i = 0; i < (int32_t)ids.size(); i++) {
503+
ids[i] = this->getPhysicalClusterId(ids[i]);
504+
}
505+
std::vector<int32_t> tmpCoreIds;
506+
for(int32_t id: ids) {
507+
ClusterInfo* cInfo = this->getClusterInfo(id);
508+
if(cInfo == nullptr) {
509+
continue;
510+
}
511+
for(int32_t c = cInfo->mStartCpu; c < cInfo->mStartCpu + cInfo->mNumCpus; c++) {
512+
tmpCoreIds.push_back(c);
513+
}
514+
}
515+
ids.clear();
516+
for(int32_t coreId: tmpCoreIds) {
517+
ids.push_back(coreId);
518+
}
519+
}
520+
521+
for(int32_t id: ids) {
522+
mask |= ((uint64_t)1 << id);
523+
}
524+
525+
if(irqLine == -1) {
526+
DIR* dir = opendir(dirPath.c_str());
527+
if(dir == nullptr) {
528+
return RC_SUCCESS;
529+
}
530+
531+
struct dirent* entry;
532+
while((entry = readdir(dir)) != nullptr) {
533+
std::string filePath = dirPath + std::string(entry->d_name) + "/";
534+
filePath.append("smp_affinity");
535+
536+
if(AuxRoutines::fileExists(filePath)) {
537+
AuxRoutines::writeToFile(filePath, std::to_string(mask));
538+
}
539+
}
540+
closedir(dir);
541+
542+
} else {
543+
std::string filePath = dirPath + std::to_string(irqLine) + "/";
544+
filePath.append("smp_affinity");
545+
546+
if(AuxRoutines::fileExists(filePath)) {
547+
AuxRoutines::writeToFile(filePath, std::to_string(mask));
548+
}
549+
}
550+
551+
return RC_SUCCESS;
552+
}
553+
486554
// Methods for Building CGroup Config from InitConfigs.yaml
487555
CGroupConfigInfoBuilder::CGroupConfigInfoBuilder() {
488556
this->mCGroupConfigInfo = new(std::nothrow) CGroupConfigInfo;

resource-tuner/init/Include/RestuneParser.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@
7575
#define INIT_CONFIGS_ELEM_CACHE_INFO_BLK_CNT "NumCacheBlocks"
7676
#define INIT_CONFIGS_ELEM_CACHE_INFO_PRIO_AWARE "PriorityAware"
7777

78+
// IRQ Configs
79+
#define INIT_CONFIGS_IRQ_CONFIGS_LIST "IRQConfigs"
80+
#define INIT_CONFIG_IRQ_AFFINE_ONE "AffineIRQ"
81+
#define INIT_CONFIG_IRQ_AFFINE_TO_CLUSTER "AffineIRQToCluster"
82+
7883
// Properties
7984
#define PROPERTY_CONFIGS_ROOT "PropertyConfigs"
8085
#define PROPERTY_CONFIGS_ELEM_NAME "Name"

resource-tuner/init/RestuneParser.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ static int8_t isKey(const std::string& keyName) {
104104
INIT_CONFIGS_ELEM_CACHE_INFO_TYPE,
105105
INIT_CONFIGS_ELEM_CACHE_INFO_BLK_CNT,
106106
INIT_CONFIGS_ELEM_CACHE_INFO_PRIO_AWARE,
107+
INIT_CONFIGS_IRQ_CONFIGS_LIST,
108+
INIT_CONFIG_IRQ_AFFINE_TO_CLUSTER,
109+
INIT_CONFIG_IRQ_AFFINE_ONE,
107110
SIGNAL_CONFIGS_ROOT,
108111
SIGNAL_CONFIGS_ELEM_SIGID,
109112
SIGNAL_CONFIGS_ELEM_CATEGORY,
@@ -147,6 +150,10 @@ static int8_t isKeyTypeList(const std::string& keyName) {
147150
if(keyName == INIT_CONFIGS_ELEM_MPAM_GROUPS_LIST) return true;
148151
if(keyName == INIT_CONFIGS_ELEM_CACHE_INFO_LIST) return true;
149152

153+
if(keyName == INIT_CONFIGS_IRQ_CONFIGS_LIST) return true;
154+
if(keyName == INIT_CONFIG_IRQ_AFFINE_TO_CLUSTER) return true;
155+
if(keyName == INIT_CONFIG_IRQ_AFFINE_ONE) return true;
156+
150157
if(keyName == RESOURCE_CONFIGS_ELEM_MODES) return true;
151158
if(keyName == RESOURCE_CONFIGS_ELEM_TARGETS_ENABLED) return true;
152159
if(keyName == RESOURCE_CONFIGS_ELEM_TARGETS_DISABLED) return true;
@@ -456,10 +463,13 @@ ErrCode RestuneParser::parseInitConfigYamlNode(const std::string& filePath) {
456463

457464
int8_t parsingDone = false;
458465
int8_t docMarker = false;
466+
int8_t inAffineClusterList = false;
467+
int8_t inAffineOneList = false;
459468

460469
std::string value;
461470
std::string topKey;
462471
std::stack<std::string> keyTracker;
472+
std::vector<std::string> itemArray;
463473

464474
CGroupConfigInfoBuilder* cGroupConfigBuilder = nullptr;
465475
MpamGroupConfigInfoBuilder* mpamGroupConfigBuilder = nullptr;
@@ -475,11 +485,47 @@ ErrCode RestuneParser::parseInitConfigYamlNode(const std::string& filePath) {
475485
parsingDone = true;
476486
break;
477487

488+
case YAML_SEQUENCE_START_EVENT:
489+
if(keyTracker.empty()) {
490+
return RC_YAML_INVALID_SYNTAX;
491+
}
492+
493+
topKey = keyTracker.top();
494+
495+
if(topKey == INIT_CONFIG_IRQ_AFFINE_TO_CLUSTER) {
496+
inAffineClusterList = true;
497+
} else if(topKey == INIT_CONFIG_IRQ_AFFINE_ONE) {
498+
inAffineOneList = true;
499+
}
500+
501+
break;
502+
478503
case YAML_SEQUENCE_END_EVENT:
479504
if(keyTracker.empty()) {
480505
return RC_YAML_INVALID_SYNTAX;
481506
}
482507

508+
if(inAffineClusterList) {
509+
if(RC_IS_OK(rc)) {
510+
rc = TargetRegistry::getInstance()->addIrqAffine(itemArray, true);
511+
if(RC_IS_NOTOK(rc)) {
512+
return RC_YAML_INVALID_SYNTAX;
513+
}
514+
}
515+
itemArray.clear();
516+
inAffineClusterList = !inAffineClusterList;
517+
518+
} else if(inAffineOneList) {
519+
if(RC_IS_OK(rc)) {
520+
rc = TargetRegistry::getInstance()->addIrqAffine(itemArray);
521+
if(RC_IS_NOTOK(rc)) {
522+
return RC_YAML_INVALID_SYNTAX;
523+
}
524+
}
525+
itemArray.clear();
526+
inAffineOneList = !inAffineOneList;
527+
}
528+
483529
keyTracker.pop();
484530
break;
485531

@@ -552,6 +598,7 @@ ErrCode RestuneParser::parseInitConfigYamlNode(const std::string& filePath) {
552598

553599
delete cacheInfoBuilder;
554600
cacheInfoBuilder = nullptr;
601+
555602
}
556603

557604
break;
@@ -588,6 +635,10 @@ ErrCode RestuneParser::parseInitConfigYamlNode(const std::string& filePath) {
588635
ADD_TO_CACHE_INFO_BUILDER(INIT_CONFIGS_ELEM_CACHE_INFO_BLK_CNT, setNumBlocks);
589636
ADD_TO_CACHE_INFO_BUILDER(INIT_CONFIGS_ELEM_CACHE_INFO_PRIO_AWARE, setPriorityAware);
590637

638+
if(topKey == INIT_CONFIG_IRQ_AFFINE_TO_CLUSTER || topKey == INIT_CONFIG_IRQ_AFFINE_ONE) {
639+
itemArray.push_back(value);
640+
}
641+
591642
break;
592643

593644
default:

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if(BUILD_TESTS)
3333
RestuneComponentTests
3434
${CMAKE_CURRENT_SOURCE_DIR}/Component/MemoryPoolTests.cpp
3535
${CMAKE_CURRENT_SOURCE_DIR}/Component/ClientDataManagerTests.cpp
36-
# ${CMAKE_CURRENT_SOURCE_DIR}/Component/ParserTests.cpp
36+
${CMAKE_CURRENT_SOURCE_DIR}/Component/ParserTests.cpp
3737
${CMAKE_CURRENT_SOURCE_DIR}/Component/ExtensionIntfTests.cpp
3838
${CMAKE_CURRENT_SOURCE_DIR}/Component/MiscTests.cpp
3939
${CMAKE_CURRENT_SOURCE_DIR}/Component/RequestQueueTests.cpp

0 commit comments

Comments
 (0)