Userspace Resource Manager
Loading...
Searching...
No Matches
Utils.h
Go to the documentation of this file.
1// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2// SPDX-License-Identifier: BSD-3-Clause-Clear
3
8#ifndef UTILS_H
9#define UTILS_H
10
11#include <string>
12
13#include "ErrCodes.h"
14
19enum ModuleID : int8_t {
20 MOD_RESTUNE,
21 MOD_CLASSIFIER,
22};
23
28enum RequestType : int8_t {
29 REQ_RESOURCE_TUNING,
30 REQ_RESOURCE_RETUNING,
31 REQ_RESOURCE_UNTUNING,
32 REQ_PROP_GET,
33 REQ_SIGNAL_TUNING,
34 REQ_SIGNAL_UNTUNING,
35 REQ_SIGNAL_RELAY
36};
37
48
56 SYSTEM_HIGH = 0, // Highest Level of Priority
57 SYSTEM_LOW,
58 THIRD_PARTY_HIGH,
59 THIRD_PARTY_LOW,
60 TOTAL_PRIORITIES
61};
62
77
78enum TranslationUnit {
79 U_NA = 1,
80 U_BYTE = 1,
81 U_KB = 1024,
82 U_MB = 1024 * 1024,
83 U_GB = 1024 * 1024 * 1024,
84 U_Hz = 1,
85 U_KHz = 1000,
86 U_MHz = 1000 * 1000,
87 U_GHz = 1000 * 1000 * 1000,
88};
89
90typedef struct {
91 int8_t mModuleID;
92 int8_t mRequestType;
93 uint64_t mBufferSize;
94 int64_t mHandle;
95 char* mBuffer;
96} MsgForwardInfo;
97
98typedef struct {
99 std::string mPropName;
100 std::string mResult;
101 uint64_t mBufferSize;
102} PropConfig;
103
104// Global Typedefs: Declare Function Pointers as types
105typedef ErrCode (*EventCallback)(void*);
106typedef int8_t (*ServerOnlineCheckCallback)();
107typedef void (*MessageReceivedCallback)(int32_t, MsgForwardInfo*);
108
109#define HIGH_TRANSFER_PRIORITY -1
110#define SERVER_CLEANUP_TRIGGER_PRIORITY -2
111
112// System Properties
113#define MAX_CONCURRENT_REQUESTS "resource_tuner.maximum.concurrent.requests"
114#define MAX_RESOURCES_PER_REQUEST "resource_tuner.maximum.resources.per.request"
115#define THREAD_POOL_DESIRED_CAPACITY "resource_tuner.thread_pool.desired_capacity"
116#define THREAD_POOL_MAX_SCALING_CAPACITY "resource_tuner.thread_pool.max_scaling_capacity"
117#define PULSE_MONITOR_DURATION "resource_tuner.pulse.duration"
118#define GARBAGE_COLLECTOR_DURATION "resource_tuner.garbage_collection.duration"
119#define GARBAGE_COLLECTOR_BATCH_SIZE "resource_tuner.garbage_collection.batch_size"
120#define RATE_LIMITER_DELTA "resource_tuner.rate_limiter.delta"
121#define RATE_LIMITER_PENALTY_FACTOR "resource_tuner.penalty.factor"
122#define RATE_LIMITER_REWARD_FACTOR "resource_tuner.reward.factor"
123#define LOGGER_LOGGING_LEVEL "urm.logging.level"
124#define LOGGER_LOGGING_LEVEL_TYPE "urm.logging.level.exact"
125#define LOGGER_LOGGING_OUTPUT_REDIRECT "urm.logging.redirect_to"
126#define URM_MAX_PLUGIN_COUNT "urm.extensions_lib.count"
127
128#define COMM(pid) ("/proc/" + std::to_string(pid) + "/comm")
129#define COMM_S(pidstr) ("/proc/" + pidstr + "/comm")
130#define STATUS(pid) ("/proc/" + std::to_string(pid) + "/status")
131#define CMDLINE(pid) ("/proc/" + std::to_string(pid) + "/cmdline")
132#define STAT(pid) ("/proc/" + std::to_string(pid) + "/stat")
133
134#define CONCAT_IMPL(a, b) a##b
135#define CONCAT(a, b) CONCAT_IMPL(a, b)
136
137#endif
ErrCode
Custom Error Codes used by Resource Tuner APIs and Internal Functions.
Definition ErrCodes.h:19
PriorityLevel
Resource Tuner Priority Levels.
Definition Utils.h:55
Permissions
Certain resources can be accessed only by system clients and some which have no such restrictions and...
Definition Utils.h:43
@ NUMBER_PERMISSIONS
Total number of permissions currently supported.
Definition Utils.h:46
@ PERMISSION_THIRD_PARTY
Third party clients. Default value.
Definition Utils.h:45
@ PERMISSION_SYSTEM
Special permission level for system clients.
Definition Utils.h:44
RequestType
Enumeration for different types of Resource-Tuner Requests.
Definition Utils.h:28
Policy
Different Resource Policies supported by Resource Tuner.
Definition Utils.h:69
@ HIGHER_BETTER
This policy first applies the request writing the highest value to the node.
Definition Utils.h:71
@ LAZY_APPLY
The requests are applied in a first-in-first-out manner.
Definition Utils.h:73
@ INSTANT_APPLY
This policy is for resources where the latest request needs to be honored.
Definition Utils.h:70
@ PASS_THROUGH_APPEND
Request Ordering is immaterial, however multiple values can co-exist.
Definition Utils.h:75
@ LOWER_BETTER
Self-explanatory. Works exactly opposite of the higher is better policy.
Definition Utils.h:72
@ PASS_THROUGH
Request Ordering is immaterial.
Definition Utils.h:74