Skip to content

Commit ae7fc01

Browse files
authored
Documentation and Add irq based resources (#149)
--- Signed-off-by: Kartik Nema <kartnema@qti.qualcomm.com>
1 parent ac3074d commit ae7fc01

9 files changed

Lines changed: 95 additions & 58 deletions

File tree

TODO.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
3. Implementation specific
1414
- Adding irq resources
1515
- Client API requests encoding / decoding support
16-
- Reorder sigId and category in the construction of sigCode (minor change)
17-
- Allow List Addition (ongoing)
1816
- Client CLI improvements, to support all types of requests
1917
- Focused cgroup creation
2018
- Memory Leaks analysis and reduction. Major issues are resolved, still observing some lost blocks.

configs/ResourcesConfig.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,23 @@ ResourceConfigs:
288288
Modes: ["display_on"]
289289
Policy: "lower_is_better"
290290
ApplyType: "cgroup"
291+
292+
- ResType: "0x0b"
293+
ResID: "0x0000"
294+
Name: "RES_IRQ_AFFINE"
295+
Path: "/proc/irq/%d/smp_affinity"
296+
Supported: true
297+
Permissions: "system"
298+
Modes: ["display_on"]
299+
Policy: "pass_through"
300+
ApplyType: "core"
301+
302+
- ResType: "0x0b"
303+
ResID: "0x0001"
304+
Name: "RES_DEF_IRQ_AFFINE"
305+
Path: "/proc/irq/default_smp_affinity"
306+
Supported: true
307+
Permissions: "system"
308+
Modes: ["display_on"]
309+
Policy: "pass_through"
310+
ApplyType: "global"

contextual-classifier/ContextualClassifier.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void ContextualClassifier::ClassifierMain() {
190190
this->mQueueCond.wait(
191191
lock,
192192
[this] {
193-
return !mPendingEv.empty() || this->mNeedExit;
193+
return !this->mPendingEv.empty() || this->mNeedExit;
194194
}
195195
);
196196

@@ -252,10 +252,7 @@ void ContextualClassifier::ClassifierMain() {
252252
this->ApplyActions(sigId, sigType, ev.pid, ev.tgid);
253253
}
254254
} else if (ev.type == CC_APP_CLOSE) {
255-
//Step1: move process to original cgroup
256-
257-
//Step2: remove actions, call untune signal
258-
// RemoveActions(ev.pid, ev.tgid);
255+
// No Action Needed, Pulse Monitor to take care of cleanup
259256
}
260257
}
261258
}
@@ -264,7 +261,7 @@ int ContextualClassifier::HandleProcEv() {
264261
pthread_setname_np(pthread_self(), "urmNetlinkListener");
265262
int32_t rc = 0;
266263

267-
while(!mNeedExit) {
264+
while(!this->mNeedExit) {
268265
ProcEvent ev{};
269266
rc = mNetLinkComm.recvEvent(ev);
270267
if(rc == CC_IGNORE) {
@@ -329,12 +326,6 @@ int32_t ContextualClassifier::ClassifyProcess(pid_t processPid,
329326
(void)ctxDetails;
330327
CC_TYPE context = CC_APP;
331328

332-
if(this->mIgnoredProcesses.count(comm) != 0U) {
333-
LOGD(CLASSIFIER_TAG,
334-
"Skipping inference for ignored process: " + comm);
335-
return CC_IGNORE;
336-
}
337-
338329
// Check if the process is still alive
339330
if(!AuxRoutines::fileExists(COMM(processPid))) {
340331
LOGD(CLASSIFIER_TAG,
@@ -343,7 +334,7 @@ int32_t ContextualClassifier::ClassifyProcess(pid_t processPid,
343334
}
344335

345336
LOGD(CLASSIFIER_TAG,
346-
"Starting classification for PID: "+ std::to_string(processPid));
337+
"Starting classification for PID: " + std::to_string(processPid));
347338
context = mInference->Classify(processPid);
348339
return context;
349340
}

docs/Examples/CoreAPIsExamples.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,19 @@
2626
// The Resource Config for this Resource is as follows (note, Configs are specified via YAML files):
2727

2828
/*
29-
Resource:
30-
- ResType: "0x03"
31-
ResID: "0x0000"
32-
Name: "/proc/sys/kernel/sched_util_clamp_min"
33-
Supported: true
34-
HighThreshold: 1024
35-
LowThreshold: 0
36-
Permissions: "third_party"
37-
Modes: ["display_on", "doze"]
38-
Policy: "higher_is_better"
39-
*/
29+
* ResourceConfigs:
30+
* - ResType: "0x03"
31+
* ResID: "0x0000"
32+
* Name: "RES_SCHED_UTIL_CLAMP_MIN"
33+
* Path: "/proc/sys/kernel/sched_util_clamp_min"
34+
* Supported: true
35+
* HighThreshold: 1024
36+
* LowThreshold: 0
37+
* Permissions: "third_party"
38+
* Modes: ["display_on", "doze"]
39+
* Policy: "lower_is_better"
40+
* ApplyType: "global"
41+
*/
4042
void func1() {
4143
// First Create a List of Resources to be Provisioned as part of this Request
4244
// Note multiple Resources can be part of a single Resource Tuner Request

docs/README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- [4.3.2. Resource Configs](#432-resource-configs)
3838
- [4.3.3. Properties Config](#433-properties-config)
3939
- [4.3.4. Signal Configs](#434-signal-configs)
40+
- [4.3.5. Per-App Configs](#435-per-app-configs)
4041

4142
- [5. Client CLI](#5-client-cli)
4243
- [5.1. Send a Tune Request](#51-send-a-tune-request)
@@ -856,7 +857,36 @@ SignalConfigs:
856857
- {ResCode: "RES_CGRP_LOW_MEMORY", Values: [4, 519430400]}
857858
- {ResCode: "RES_CGRP_MIN_MEMORY", Values: [4, 119430400]}
858859
```
859-
Common resource configs are defined in /etc/urm/common/SignalsConfig.yaml.
860+
Common Signal configs are defined in /etc/urm/common/SignalsConfig.yaml.
861+
862+
### 4.3.5. Per App Configs
863+
The file PerApp.yaml defines the per-app configs.
864+
865+
**Field Descriptions**
866+
| Field | Type | Description | Default Value |
867+
|----------------|------------|-------------|---------------|
868+
| `App` | `String` (Mandatory) | Name of the App, equivalent to process "comm" | Not Applicable |
869+
| `Threads` | `array` (Optional) | List of app threads (identified by their "comm" value as specified in /proc/{pid}/comm) to be considered as in-focus, hence moved to the focused-cgroup when the app (with the above identifier) is launched. | `Empty List` |
870+
| `Configurations` | `array` (optional) | List of Signal Configurations indicating the signals to be acquired when this app is launched. Note: The specified signal opcodes should correspond to actual configurations in the SignalsConfig.yaml file. | `Empty List` |
871+
872+
<div style="page-break-after: always;"></div>
873+
874+
**Example**
875+
```yaml
876+
PerAppConfigs:
877+
- App: "gst-launch-"
878+
Threads:
879+
- {"cam-server": "4"}
880+
- {"gst-launch-": "4"}
881+
882+
- App: "chrome"
883+
Threads:
884+
- {"chrome": "FOCUSED_CGROUP_IDENTIFIER"}
885+
Configurations: ["0x80034aab"]
886+
887+
```
888+
889+
PerApp configs should be defined in /etc/urm/custom/PerApp.yaml.
860890

861891
## 5. Client CLI
862892
URM provides a minimal CLI to interact with the server. This is provided to help with development and debugging purposes.

modula/Common/Include/UrmPlatformAL.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,25 @@ enum Modes {
128128
(int32_t) ((resInfo ^ (EXTRACT_RESOURCE_MPAM_VALUE(resInfo) << 16)) | (newValue << 16)); \
129129
}) \
130130

131-
#define CONSTRUCT_RES_CODE(resType, resCode) ({ \
132-
uint32_t resourceBitmap = 0; \
133-
resourceBitmap |= ((uint32_t)resCode); \
134-
resourceBitmap |= ((uint32_t)resType << 16); \
135-
resourceBitmap; \
136-
}) \
137-
138-
#define CONSTRUCT_SIG_CODE(sigCat, sigID) ({ \
139-
uint32_t signalBitmap = 0; \
140-
signalBitmap |= ((uint32_t)sigID); \
141-
signalBitmap |= ((uint32_t)sigCat << 16); \
142-
signalBitmap; \
143-
}) \
144-
145-
#define CUSTOM(opCode) ({ \
146-
uint32_t opBitmap = opCode; \
147-
opBitmap |= (1 << 31); \
148-
opBitmap; \
149-
}) \
131+
#define CONSTRUCT_RES_CODE(resType, resCode) ({ \
132+
uint32_t resourceBitmap = 0; \
133+
resourceBitmap |= ((uint32_t)resCode); \
134+
resourceBitmap |= ((uint32_t)resType << 16); \
135+
resourceBitmap; \
136+
}) \
137+
138+
#define CONSTRUCT_SIG_CODE(sigCat, sigID) ({ \
139+
uint32_t signalBitmap = 0; \
140+
signalBitmap |= ((uint32_t)sigID); \
141+
signalBitmap |= ((uint32_t)sigCat << 16); \
142+
signalBitmap; \
143+
}) \
144+
145+
#define CUSTOM(opCode) ({ \
146+
uint32_t opBitmap = opCode; \
147+
opBitmap |= (1 << 31); \
148+
opBitmap; \
149+
}) \
150150

151151
// Common ResCode and ResInfo codes
152152
// These enums can be used directly as part of tuneResources API, to uniquely

modula/CoreModules/Include/UrmSettings.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "Utils.h"
1313

1414
#define URM_IDENTIFIER "urm"
15-
#define REQ_BUFFER_SIZE 1024
15+
#define REQ_BUFFER_SIZE 580
1616

1717
// Operational Tunable Parameters for Resource Tuner
1818
typedef struct {
@@ -52,25 +52,21 @@ class UrmSettings {
5252
static const std::string mCustomSignalFilePath;
5353
static const std::string mCommonPropertiesFilePath;
5454
static const std::string mCustomPropertiesFilePath;
55+
static const std::string mCommonInitConfigFilePath;
56+
static const std::string mCustomInitConfigFilePath;
5557

5658
// Only Custom Config is supported for Target and Ext Features Config
5759
static const std::string mCustomTargetFilePath;
5860
static const std::string mCustomExtFeaturesFilePath;
59-
6061
static const std::string mCustomAppConfigFilePath;
6162

62-
// Support both versions: Common and Custom
63-
static const std::string mCommonInitConfigFilePath;
64-
static const std::string mCustomInitConfigFilePath;
65-
66-
static const std::string mExtensionsPluginLibPath;
67-
63+
static const std::string focusedCgroup;
6864
static const std::string mDeviceNamePath;
6965
static const std::string mBaseCGroupPath;
70-
static const std::string focusedCgroup;
71-
7266
static const std::string mPersistenceFile;
67+
static const std::string mExtensionsPluginLibPath;
7368

69+
// Target Information Stores
7470
static MetaConfigs metaConfigs;
7571
static TargetConfigs targetConfigs;
7672

resource-tuner/core/TargetRegistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void TargetRegistry::generatePolicyBasedMapping(std::vector<std::string>& policy
139139
// proceed with determining the Cluster Capcity
140140
int32_t cpuID = cpuList[0];
141141
clusterInfo->mStartCpu = cpuID;
142-
for(int32_t i = 0; i < cpuList.size(); i++) {
142+
for(int32_t i = 0; i < (int32_t)cpuList.size(); i++) {
143143
clusterInfo->mStartCpu = std::min(clusterInfo->mStartCpu, cpuList[i]);
144144
}
145145

resource-tuner/init/RestuneParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ ErrCode RestuneParser::parsePerAppConfigYamlNode(const std::string& filePath) {
951951
}
952952

953953
int32_t listIndex = 0;
954-
for(int32_t i = 0; i < itemArray.size(); i += 2) {
954+
for(int32_t i = 0; i < (int32_t)itemArray.size(); i += 2) {
955955
if(RC_IS_OK(rc)) {
956956
rc = appConfigBuider->addThreadMapping(listIndex, itemArray[i], itemArray[i + 1]);
957957
listIndex++;

0 commit comments

Comments
 (0)