cpu-boosting: Remove useless overhead caused by governor 54/298254/2
authorUnsung Lee <unsung.lee@samsung.com>
Mon, 4 Sep 2023 07:50:29 +0000 (16:50 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Tue, 5 Sep 2023 00:09:35 +0000 (09:09 +0900)
Remove useless overhead caused by cpu boosting governor.

It removes useless overhead in two cases
  1. If cpu is not busy when stall event is monitored, then
     do not decrease boost thread level
  2. If action list to do is empty and no already decreased thread,
     then do not make an additional timer. This timer is used to check
     whether there is not stall event during interval.

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

index 5d67fd8..4ce18b5 100644 (file)
@@ -307,6 +307,7 @@ static gboolean cpu_boosting_governor_govern_request (gpointer user_data)
        GSource *source;
        GSList *iter;
        GSList *next;
+       bool is_cpu_busy;
        int ret;
 
        /**
@@ -318,15 +319,33 @@ static gboolean cpu_boosting_governor_govern_request (gpointer user_data)
                        cpu_boosting_level < CPU_BOOSTING_LEVEL_END; cpu_boosting_level++) {
                ret = syscommon_plugin_resourced_cpu_boosting_governor_govern_request(
                                g_cpu_boosting_info_table[cpu_boosting_level],
-                               cpu_boosting_level, &action_list);
+                               cpu_boosting_level, &action_list, &is_cpu_busy);
                if (ret < 0)
                        return G_SOURCE_REMOVE;
 
+               if (!is_cpu_busy)
+                       break;
+
                if (action_list != NULL)
                        break;
        }
 
        /**
+        * action_list is NULL when there is not boosted thread to decrease
+        * cpu boosting level.
+        * In addition, g_cpu_contention_handle_data_table size is 0 when
+        * there is no boosted threads yet with decreased cpu boosting level.
+        * (resourced should check whehter no more stall event during
+        * CPU_CONTENTION_HANDLE_TIMEOUT_MSEC.)
+        *
+        * In conclusion, additional timer is useless to set when action_list is
+        * empty and no decreased boosted thread.
+        */
+       if (action_list == NULL &&
+                       g_hash_table_size(g_cpu_contention_handle_data_table) == 0)
+               return G_SOURCE_REMOVE;
+
+       /**
         * Set timer to check whether cpu contention is alleviated or not
         * after CPU_CONTENTION_HANDLE_TIMEOUT_MSEC.
         */
@@ -338,9 +357,6 @@ static gboolean cpu_boosting_governor_govern_request (gpointer user_data)
                g_source_attach(source, cpu_boosting_context);
        g_source_unref(source);
 
-       if (action_list == NULL)
-               return G_SOURCE_REMOVE;
-
        gslist_for_each_safe(action_list, iter, next, input) {
                assert(input);