plugin-api: resourced: Add is_cpu_contention_alleviated 50/298250/2
authorUnsung Lee <unsung.lee@samsung.com>
Wed, 30 Aug 2023 08:09:51 +0000 (17:09 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 4 Sep 2023 08:56:51 +0000 (17:56 +0900)
Add is_cpu_contention_alleviated function to check whether
cpu contention is alleviated or not.

Prototype of new function is like below:
  - bool syscommon_plugin_resourced_is_cpu_contention_alleviated(
               guint timer_id, guint latest_timer_id);
    * After a stall event is monitored, a timer with some interval set.
      If no more stall events between setting timer and timeout,
      timer_id is equal to latest_timer_id.

Change-Id: I0136f445827ae49d002fd8dcb0919cef0ada40b9
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting-interface.h
src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting.h
src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c

index 5e43274..73c0c40 100644 (file)
@@ -52,7 +52,9 @@ typedef struct _syscommon_plugin_backend_resourced_cpu_boosting_funcs {
        int (*cpu_boosting_governor_govern_request) (
                        GHashTable *cpu_boosting_info_table,
                        cpu_boosting_level_e cpu_boosting_level,
-                       GSList **cpu_boosting_controller_action)
+                       GSList **cpu_boosting_controller_action);
+       bool (*is_cpu_contention_alleviated)
+               (guint timer_id, guint latest_timer_id);
 } syscommon_plugin_backend_resourced_cpu_boosting_funcs;
 
 #ifdef __cplusplus
index 1242b73..598ccbd 100644 (file)
@@ -60,6 +60,15 @@ int syscommon_plugin_resourced_cpu_boosting_governor_govern_request(
                cpu_boosting_level_e cpu_boosting_level,
                GSList **cpu_boosting_controller_action);
 
+/**
+ * @brief Check whehter cpu contention is alleviated
+ * @param[in] timer id when handling cpu boosting level
+ * @param[in] timer id when monitoring the latest stall event
+ * @return @c true when cpu contention is alleviated, otherwise false
+ */
+bool syscommon_plugin_resourced_is_cpu_contention_alleviated(
+               guint timer_id, guint latest_timer_id);
+
 #ifdef __cplusplus
 }
 #endif
index 1bd8eea..4d6739b 100644 (file)
@@ -102,3 +102,24 @@ int syscommon_plugin_resourced_cpu_boosting_governor_govern_request(
        return funcs->cpu_boosting_governor_govern_request(cpu_boosting_info_table,
                        cpu_boosting_level, cpu_boosting_controller_action);
 }
+
+EXPORT
+bool syscommon_plugin_resourced_is_cpu_contention_alleviated(
+               guint timer_id, guint latest_timer_id)
+{
+       int ret = 0;
+
+       if (!funcs) {
+               ret = syscommon_plugin_resourced_cpu_boosting_get_backend();
+               if (ret < 0)
+                       return ret;
+       }
+
+       assert(funcs);
+       if (!funcs->is_cpu_contention_alleviated) {
+               _E("No \"is_cpu_contention_alleviated\" function");
+               return -ENOTSUP;
+       }
+
+       return funcs->is_cpu_contention_alleviated(timer_id, latest_timer_id);
+}