|
19 | 19 | #include "Extensions.h" |
20 | 20 | #include "AuxRoutines.h" |
21 | 21 | #include "UrmPlatformAL.h" |
| 22 | +#include "SignalInternal.h" |
22 | 23 | #include "SignalRegistry.h" |
23 | 24 | #include "RestuneInternal.h" |
24 | 25 | #include "ContextualClassifier.h" |
@@ -97,67 +98,6 @@ static ResIterable* createMovePidResource(int32_t cGroupdId, pid_t pid) { |
97 | 98 | return resIterable; |
98 | 99 | } |
99 | 100 |
|
100 | | -static Request* createTuneRequestFromSignal(uint32_t sigId, |
101 | | - uint32_t sigType, |
102 | | - pid_t incomingPID, |
103 | | - pid_t incomingTID, |
104 | | - int32_t numArgs, |
105 | | - uint32_t* args) { |
106 | | - try { |
107 | | - std::shared_ptr<SignalRegistry> sigRegistry = SignalRegistry::getInstance(); |
108 | | - |
109 | | - // Check if a Signal with the given ID exists in the Registry |
110 | | - SignalInfo* signalInfo = sigRegistry->getSignalConfigById(sigId, sigType, args); |
111 | | - |
112 | | - if(signalInfo == nullptr) return nullptr; |
113 | | - |
114 | | - Request* request = MPLACED(Request); |
115 | | - |
116 | | - int64_t handleGenerated = AuxRoutines::generateUniqueHandle(); |
117 | | - request->setHandle(handleGenerated); |
118 | | - |
119 | | - request->setRequestType(REQ_RESOURCE_TUNING); |
120 | | - request->setDuration(signalInfo->mTimeout); |
121 | | - request->setProperties(SYSTEM_HIGH); |
122 | | - request->setClientPID(incomingPID); |
123 | | - request->setClientTID(incomingTID); |
124 | | - |
125 | | - std::vector<Resource*>* signalLocks = signalInfo->mSignalResources; |
126 | | - |
127 | | - for(int32_t i = 0; i < (int32_t)signalLocks->size(); i++) { |
128 | | - if((*signalLocks)[i] == nullptr) { |
129 | | - continue; |
130 | | - } |
131 | | - |
132 | | - // Copy |
133 | | - Resource* resource = MPLACEV(Resource, (*((*signalLocks)[i]))); |
134 | | - |
135 | | - // fill placeholders if any |
136 | | - int32_t listIndex = 0; |
137 | | - for(int32_t j = 0; j < resource->getValuesCount(); j++) { |
138 | | - if(resource->getValueAt(j) == -1) { |
139 | | - if(args == nullptr) return nullptr; |
140 | | - if(listIndex >= 0 && listIndex < numArgs) { |
141 | | - resource->setValueAt(j, args[listIndex]); |
142 | | - listIndex++; |
143 | | - } |
144 | | - } |
145 | | - } |
146 | | - |
147 | | - ResIterable* resIterable = MPLACED(ResIterable); |
148 | | - resIterable->mData = resource; |
149 | | - request->addResource(resIterable); |
150 | | - } |
151 | | - |
152 | | - return request; |
153 | | - |
154 | | - } catch(const std::bad_alloc& e) { |
155 | | - return nullptr; |
156 | | - } |
157 | | - |
158 | | - return nullptr; |
159 | | -} |
160 | | - |
161 | 101 | ContextualClassifier::~ContextualClassifier() { |
162 | 102 | this->Terminate(); |
163 | 103 | if(this->mInference) { |
@@ -294,17 +234,15 @@ void ContextualClassifier::ClassifierMain() { |
294 | 234 | .mSigType = sigType, |
295 | 235 | .mNumArgs = numArgs, |
296 | 236 | .mArgs = args, |
| 237 | + .mHandleAcq = -1, |
297 | 238 | }; |
298 | 239 | postCb((void*)&postProcessData); |
299 | 240 |
|
300 | | - sigId = postProcessData.mSigId; |
301 | | - sigType = postProcessData.mSigType; |
302 | | - numArgs = postProcessData.mNumArgs; |
303 | | - args = postProcessData.mArgs; |
| 241 | + // Record any Configurations made |
| 242 | + if(postProcessData.mHandleAcq != - 1) { |
| 243 | + this->mCurrRestuneHandles.push_back(postProcessData.mHandleAcq); |
| 244 | + } |
304 | 245 | } |
305 | | - |
306 | | - // Apply actions, call tuneSignal |
307 | | - this->ApplyActions(sigId, sigType, ev.pid, ev.tgid, numArgs, args); |
308 | 246 | } |
309 | 247 | } else if(ev.type == CC_APP_CLOSE) { |
310 | 248 | // No Action Needed, Pulse Monitor to take care of cleanup |
@@ -405,46 +343,6 @@ int32_t ContextualClassifier::ClassifyProcess(pid_t processPid, |
405 | 343 | return context; |
406 | 344 | } |
407 | 345 |
|
408 | | -void ContextualClassifier::ApplyActions(uint32_t sigId, |
409 | | - uint32_t sigType, |
410 | | - pid_t incomingPID, |
411 | | - pid_t incomingTID, |
412 | | - int32_t numArgs, |
413 | | - uint32_t* args) { |
414 | | - LOGI(CLASSIFIER_TAG, "LogBook: sigId=" + std::to_string(sigId)); |
415 | | - LOGI(CLASSIFIER_TAG, "LogBook: sigType=" + std::to_string(sigType)); |
416 | | - LOGI(CLASSIFIER_TAG, "LogBook: numArgs=" + std::to_string(numArgs)); |
417 | | - |
418 | | - if(numArgs > 0) { |
419 | | - LOGI(CLASSIFIER_TAG, "front: Printing Stats"); |
420 | | - LOGI(CLASSIFIER_TAG, "front: fps=" + std::to_string(args[SIGNAL_EXTRA_ATTR_FPS])); |
421 | | - LOGI(CLASSIFIER_TAG, "front: height=" + std::to_string(args[SIGNAL_EXTRA_ATTR_HEIGHT])); |
422 | | - LOGI(CLASSIFIER_TAG, "front: width=" + std::to_string(args[SIGNAL_EXTRA_ATTR_WIDTH])); |
423 | | - } |
424 | | - |
425 | | - Request* request = |
426 | | - createTuneRequestFromSignal(sigId, sigType, incomingPID, incomingTID, numArgs, args); |
427 | | - if(request != nullptr) { |
428 | | - if(request->getResourcesCount() > 0) { |
429 | | - // Record: |
430 | | - this->mCurrRestuneHandles.push_back(request->getHandle()); |
431 | | - |
432 | | - // fast path to Request Queue |
433 | | - submitResProvisionRequest(request, false); |
434 | | - |
435 | | - } else { |
436 | | - Request::cleanUpRequest(request); |
437 | | - } |
438 | | - } |
439 | | -} |
440 | | - |
441 | | -void ContextualClassifier::RemoveActions(pid_t processPid, pid_t processTgid) { |
442 | | - (void)processPid; |
443 | | - (void)processTgid; |
444 | | - |
445 | | - return; |
446 | | -} |
447 | | - |
448 | 346 | uint32_t ContextualClassifier::GetSignalIDForWorkload(int32_t contextType) { |
449 | 347 | switch(contextType) { |
450 | 348 | case CC_MULTIMEDIA: |
@@ -584,36 +482,24 @@ void ContextualClassifier::MoveAppThreadsToCGroup(pid_t incomingPID, |
584 | 482 | void ContextualClassifier::configureAppSignals(pid_t incomingPID, |
585 | 483 | pid_t incomingTID, |
586 | 484 | const std::string& comm) { |
587 | | - try { |
588 | | - // Configure any associated signal |
589 | | - AppConfig* appConfig = AppConfigs::getInstance()->getAppConfig(comm); |
590 | | - if(appConfig != nullptr && appConfig->mSignalCodes != nullptr) { |
591 | | - int32_t numSignals = appConfig->mNumSignals; |
592 | | - // Go over the list of proc names (comm) and get their pids |
593 | | - for(int32_t i = 0; i < numSignals; i++) { |
594 | | - Request* request = createTuneRequestFromSignal( |
595 | | - appConfig->mSignalCodes[i], |
596 | | - 0, |
597 | | - incomingPID, |
598 | | - incomingTID, |
599 | | - 0, |
600 | | - nullptr); |
601 | | - |
602 | | - if(request != nullptr) { |
603 | | - if(request->getResourcesCount() > 0) { |
604 | | - // fast path to Request Queue |
605 | | - this->mCurrRestuneHandles.push_back(request->getHandle()); |
606 | | - submitResProvisionRequest(request, false); |
607 | | - |
608 | | - } else { |
609 | | - Request::cleanUpRequest(request); |
610 | | - } |
611 | | - } |
| 485 | + // Configure any associated signal |
| 486 | + AppConfig* appConfig = AppConfigs::getInstance()->getAppConfig(comm); |
| 487 | + if(appConfig != nullptr && appConfig->mSignalCodes != nullptr) { |
| 488 | + // Go over the list of proc names (comm) and get their pids |
| 489 | + for(int32_t i = 0; i < appConfig->mNumSignals; i++) { |
| 490 | + int64_t handle = acquireSignal( |
| 491 | + appConfig->mSignalCodes[i], |
| 492 | + 0, |
| 493 | + incomingPID, |
| 494 | + incomingTID, |
| 495 | + 0, |
| 496 | + nullptr |
| 497 | + ); |
| 498 | + |
| 499 | + if(handle != -1) { |
| 500 | + this->mCurrRestuneHandles.push_back(handle); |
612 | 501 | } |
613 | 502 | } |
614 | | - } catch(const std::exception& e) { |
615 | | - LOGE(CLASSIFIER_TAG, |
616 | | - "Failed to acquire per-app config signal, Error: " + std::string(e.what())); |
617 | 503 | } |
618 | 504 | } |
619 | 505 |
|
|
0 commit comments