Add highest priority & use it for SecurityModuleCall::PREPARE_APP 14/319214/1
authorTomasz Swierczek <t.swierczek@samsung.com>
Thu, 17 Oct 2024 07:49:52 +0000 (09:49 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 17 Oct 2024 07:49:52 +0000 (09:49 +0200)
So far without its separate thread, just to have separate queues
for the top-priority events.

Change-Id: I6d52e51fd8188a18f6b9650413ee6926139bdcd9

src/client/include/client-request.h
src/common/include/protocols.h

index 2fa397e836314e4ea14ae35cefea39c22a3c7dd8..432fa0da82c8538178c5cc5513b1d69128901a62 100644 (file)
@@ -42,24 +42,29 @@ namespace SecurityManager {
 
 class ClientRequest {
 
-    static Priority getPriority() {
+    static Priority getPriority(SecurityModuleCall action) {
         auto priority = Priority::LOW;
-        resource_pid_t proc_data;
-        cpu_boosting_level_info_t info;
-        proc_data.tid = nullptr;
-        proc_data.pid = 0;  // query for current TID - array tid_level gets allocated
-        if (resource_get_cpu_boosting_level(proc_data, &info) != 0) {
-            LogError("resource_get_cpu_boosting_level failed");
+        if (action == SecurityModuleCall::PREPARE_APP) {
+            // highest priority for app launching
+            priority = Priority::HIGHEST;
         } else {
-            switch (info.tid_level[0]) {
-            case CPU_BOOSTING_LEVEL_STRONG:
-                priority = Priority::HIGH;
-                break;
-            case CPU_BOOSTING_LEVEL_MEDIUM:
-                priority = Priority::MEDIUM;
-                break;
+            resource_pid_t proc_data;
+            cpu_boosting_level_info_t info;
+            proc_data.tid = nullptr;
+            proc_data.pid = 0;  // query for current TID - array tid_level gets allocated
+            if (resource_get_cpu_boosting_level(proc_data, &info) != 0) {
+                LogError("resource_get_cpu_boosting_level failed");
+            } else {
+                switch (info.tid_level[0]) {
+                case CPU_BOOSTING_LEVEL_STRONG:
+                    priority = Priority::HIGH;
+                    break;
+                case CPU_BOOSTING_LEVEL_MEDIUM:
+                    priority = Priority::MEDIUM;
+                    break;
+                }
+                free(info.tid_level);
             }
-            free(info.tid_level);
         }
         return priority;
     }
@@ -67,7 +72,7 @@ public:
     ClientRequest(SecurityModuleCall action)
     {
         m_buffer.InitForStreaming();
-        Serialization::Serialize(m_buffer, underlying(getPriority()));
+        Serialization::Serialize(m_buffer, underlying(getPriority(action)));
         Serialization::Serialize(m_buffer, static_cast<int>(action));
     }
 
index 99604dc391b97a43c5db280fb113997ddcd3248a..b378d4f684bfd59967ba76e4953caf36bf62d46a 100644 (file)
@@ -112,6 +112,7 @@ inline constexpr auto SERVICE_SOCKET = SOCKET_PATH_PREFIX "security-manager.sock
 inline constexpr auto RESOURCE_CPU_DEST_NAME = "SECURITY_MANAGER_DEST";
 
 enum Priority : unsigned char {
+    HIGHEST,
     HIGH,
     MEDIUM,
     LOW,