cpu-boosting: Add reason to fail boosting cpu in the log 04/313704/3
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 07:10:03 +0000 (16:10 +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 160fc6c..6996575 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 7622540..de4235b 100644 (file)
@@ -825,7 +825,8 @@ static int cpu_boosting_enqueue_by_conf(void *data,
 
 static gboolean cpu_boosting_timeout(gpointer data)
 {
-       int ret;
+       int fail_cnt = 0;
+       int success_cnt = 0;
        struct syscommon_resourced_cpu_boosting_input *input =
                (struct syscommon_resourced_cpu_boosting_input *)data;
 
@@ -842,6 +843,7 @@ static gboolean cpu_boosting_timeout(gpointer data)
 
                if (tid_list[i] <= 0) {
                        _W("[CPU-BOOSTING] Thread (id = %d) should be larger than 0", tid_list[i]);
+                       fail_cnt++;
                        continue;
                }
 
@@ -870,11 +872,18 @@ static gboolean cpu_boosting_timeout(gpointer data)
                        assert(0);
                }
 
-               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++;
        }
 
+       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);
 
@@ -986,8 +995,6 @@ cpu_boosting_set(struct syscommon_resourced_cpu_boosting_input *input)
                }
 
                if (sched_setattr(tid_list[i], &attr, 0) < 0) {
-                       _W("[CPU-BOOSTING] Failed to boost cpu of (tid = %d) with (level = %d)",
-                                       tid_list[i], cpu_boosting_level);
                        tid_list[i] = 0;
                        fail_cnt++;
                        continue;
@@ -1053,7 +1060,6 @@ static void cpu_boosting_clear(struct syscommon_resourced_cpu_boosting_input *in
                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;
                }