From b1e09d725217b32726d19483bcecac2e797c5e2a Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Wed, 30 Aug 2023 17:09:51 +0900 Subject: [PATCH] plugin-api: resourced: Add is_cpu_contention_alleviated 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 --- ...common-plugin-resourced-cpu-boosting-interface.h | 4 +++- .../syscommon-plugin-resourced-cpu-boosting.h | 9 +++++++++ .../src/syscommon-plugin-resourced-cpu-boosting.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting-interface.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting-interface.h index 5e43274..73c0c40 100644 --- a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting-interface.h +++ b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting-interface.h @@ -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 diff --git a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting.h index 1242b73..598ccbd 100644 --- a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting.h +++ b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting.h @@ -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 diff --git a/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c b/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c index 1bd8eea..4d6739b 100644 --- a/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c +++ b/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c @@ -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); +} -- 2.7.4