cpu-boosting: Add reason to fail boosting cpu in the log 74/313674/2
authorUnsung Lee <unsung.lee@samsung.com>
Sat, 29 Jun 2024 12:05:24 +0000 (21:05 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 1 Jul 2024 02:52:19 +0000 (11:52 +0900)
Add reason to fail cpu boosting when printing the error log.

Change-Id: I85df82ad7dcb6d1a912bdefb991617eefe4aa89d
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/common/util.c
src/resource-optimizer/cpu/cpu-boosting.c

index 160fc6cbf9ef5caa55c7fe5a2ecd203bbfed174d..6996575b6cd420b478c5d1bd355f5bd48b4c32cb 100644 (file)
@@ -106,7 +106,18 @@ int sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int flags)
        }
 #endif
        if (error) {
-               _E("[CPU-SCHED] Failed to set policy and priority with error = %m");
+               switch (errno) {
+               case EINVAL:
+                       _E("[CPU-SCHED] Failed to set policy and priority by invalid input");
+                       break;
+               case EPERM:
+                       _E("[CPU-SCHED] Failed to set policy and priority by permission");
+                       break;
+               default:
+                       _E("[CPU-SCHED] Failed to set policy and priority by no pid (%d)", pid);
+                       break;
+               }
+
                return RESOURCED_ERROR_FAIL;
        }
 
index 0588cd2a5c866bf05ea774e2d9b0d824b959d8a9..4ff8766f8fbc8ff12f66b59b5b2a8722eed457d5 100644 (file)
@@ -468,7 +468,8 @@ static int cpu_boosting_enqueue_by_conf(void *data, struct cpu_boosting_input **
 
 static gboolean cpu_boosting_timeout(gpointer data)
 {
-       int ret;
+       int fail_cnt = 0;
+       int success_cnt = 0;
        struct cpu_boosting_input *input = (struct cpu_boosting_input *)data;
 
        if (input == NULL) {
@@ -490,14 +491,21 @@ static gboolean cpu_boosting_timeout(gpointer data)
                                continue;
 
                        g_hash_table_remove(tid_table, &tid_list[i]);
-                       ret = sched_setattr(tid_list[i], &cpu_boosting_attr[CPU_BOOSTING_LEVEL_NONE], 0);
-                       if (ret != RESOURCED_ERROR_NONE)
-                               _E("[CPU-BOOSTING] Failed to clear boost cpu of (tid = %d)", tid_list[i]);
+                       if (sched_setattr(tid_list[i],
+                                               &cpu_boosting_attr[CPU_BOOSTING_LEVEL_NONE], 0) < 0) {
+                               fail_cnt++;
+                               continue;
+                       }
+
+                       success_cnt++;
                }
                else
                        _E("[CPU-BOOSTING] Thread (id = %d) should be larger than 0", tid_list[i]);
        }
 
+       if (fail_cnt > 0)
+               _E("[CPU-BOOSTING] Boosting success ratio = %d/%d", success_cnt, fail_cnt + success_cnt);
+
        if (input->remove_input)
                cpu_boosting_destroy_request(input);
 
@@ -543,8 +551,6 @@ static void cpu_boosting_set(struct cpu_boosting_input *input)
        for (int i = 0; i < tid_count; i++) {
                if (tid_list[i] > 0) {
                        if (sched_setattr(tid_list[i], &attr, 0) < 0) {
-                               _E("[CPU-BOOSTING] Failed to boost cpu of (tid = %d) with (level = %d)",
-                                               tid_list[i], cpu_boosting_level);
                                fail_cnt++;
                                continue;
                        }
@@ -599,7 +605,6 @@ static void cpu_boosting_clear(struct cpu_boosting_input *input)
                        ret = sched_setattr(tid_list[i],
                                        &cpu_boosting_attr[CPU_BOOSTING_LEVEL_NONE], 0);
                        if (ret != RESOURCED_ERROR_NONE) {
-                               _E("[CPU-BOOSTING] Failed to clear boost cpu of (tid = %d)", tid_list[i]);
                                fail_cnt++;
                                continue;
                        }