From 1fc86f1acdc523b8435a4722a1fa08fca9e6d403 Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Sat, 29 Jun 2024 21:05:24 +0900 Subject: [PATCH] cpu-boosting: Add reason to fail boosting cpu in the log Add reason to fail cpu boosting when printing the error log. Change-Id: I85df82ad7dcb6d1a912bdefb991617eefe4aa89d Signed-off-by: Unsung Lee --- src/common/util.c | 13 ++++++++++++- src/resource-optimizer/cpu/cpu-boosting.c | 20 +++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/common/util.c b/src/common/util.c index 160fc6c..6996575 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -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; } diff --git a/src/resource-optimizer/cpu/cpu-boosting.c b/src/resource-optimizer/cpu/cpu-boosting.c index 7622540..de4235b 100644 --- a/src/resource-optimizer/cpu/cpu-boosting.c +++ b/src/resource-optimizer/cpu/cpu-boosting.c @@ -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; } -- 2.7.4