From: Unsung Lee Date: Fri, 1 Sep 2023 06:53:09 +0000 (+0900) Subject: resourced-cpu-boosting: Add is_cpu_contention_alleviated() to check cpu contention X-Git-Tag: accepted/tizen/unified/20230906.014628~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64ae5076a570c552cd266fd7e3417dd1128b1973;p=platform%2Fcore%2Fsystem%2Fplugin%2Fresourced-generic.git resourced-cpu-boosting: Add is_cpu_contention_alleviated() to check cpu contention Add is_cpu_contention_alleviated to check whether cpu contention is alleviated for restoring cpu boosting level. Prototype of new function is like below: - bool 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: I709414ff982ee08fb8a5465142e552e8e441fe04 Signed-off-by: Unsung Lee --- diff --git a/src/resourced-cpu-boosting/resourced-cpu-boosting.c b/src/resourced-cpu-boosting/resourced-cpu-boosting.c index bc90a35..3f7c043 100644 --- a/src/resourced-cpu-boosting/resourced-cpu-boosting.c +++ b/src/resourced-cpu-boosting/resourced-cpu-boosting.c @@ -29,6 +29,7 @@ #include #define BOOSTING_LEVEL_DECREASE_CPU_UTIL_THRESHOLD 99.0 +#define BOOSTING_LEVEL_RESTORE_CPU_UTIL_THRESHOLD 90.0 #define EXPORT __attribute__ ((visibility("default"))) @@ -176,6 +177,21 @@ static bool is_system_cpu_busy(double threshold) return true; } +static bool is_cpu_contention_alleviated(guint timer_id, guint latest_timer_id) +{ + /** + * If additional monitor events are not triggered + * for interval, then restore CPU boosting level. + */ + if (timer_id != latest_timer_id) + return false; + + if (is_system_cpu_busy(BOOSTING_LEVEL_RESTORE_CPU_UTIL_THRESHOLD)) + return false; + + return true; +} + static int cpu_boosting_governor_govern_request ( GHashTable *cpu_boosting_info_table, cpu_boosting_level_e cpu_boosting_level, @@ -351,6 +367,7 @@ static int resourced_cpu_boosting_exit(void *data) static syscommon_plugin_backend_resourced_cpu_boosting_funcs g_cpu_boosting_funcs = { .cpu_boosting_governor_govern_request = cpu_boosting_governor_govern_request, + .is_cpu_contention_alleviated = is_cpu_contention_alleviated, }; syscommon_plugin_backend EXPORT system_plugin_backend_resourced_cpu_boosting_data = {