cpu-boosting-monitor: Notify cpu boosting module when monitoring cpu PSIs 25/297125/5
authorUnsung Lee <unsung.lee@samsung.com>
Wed, 9 Aug 2023 07:27:06 +0000 (16:27 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 28 Aug 2023 01:49:13 +0000 (10:49 +0900)
Notify cpu boosting module when cpu PSIs are triggered.
When monitoring cpu PSIs, the monitor needs to wake up cpu boosting main thread.
This is because cpu boosting monitor just catches cpu PSIs and need to
wait for next PSI events.

Thread running cpu boosting monitor should wake up main cpu boosting thread
running g_main_loop_run() function. When main cpu boosting is idle,
the thread is woken up immediately.

Change-Id: I7f89265f4e7394c07c86cb0f3e40edc785eb922c
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/resource-optimizer/cpu/cpu-boosting-monitor-psi.c
src/resource-optimizer/cpu/cpu-boosting.c
src/resource-optimizer/cpu/cpu-boosting.h [new file with mode: 0644]

index e3115a8..7cefb6a 100644 (file)
@@ -28,6 +28,7 @@
 #include <sys/eventfd.h>
 #include <pthread.h>
 
+#include "cpu-boosting.h"
 #include "procfs.h"
 #include "trace.h"
 #include "module.h"
@@ -203,6 +204,8 @@ static void raise_cpu_contention_event(void)
        default:
                return;
        }
+
+       cpu_boosting_wakeup_cpu_boosting_thread();
 }
 
 static void *psi_monitor_thread_worker(void *data)
index 169fe2f..f68eb7b 100644 (file)
@@ -79,6 +79,22 @@ static void find_cpu_boosting_info_in_tables(
        }
 }
 
+static gboolean cpu_boosting_governor_govern_request (gpointer user_data)
+{
+       return FALSE;
+}
+
+void cpu_boosting_wakeup_cpu_boosting_thread(void)
+{
+       /**
+        * This function is called by a monitor thread,
+        * so, the monitor should wakeup the cpu boosting main thread
+        * to call governor.
+        */
+       g_main_context_invoke(cpu_boosting_context,
+                       cpu_boosting_governor_govern_request, NULL);
+}
+
 static cpu_boosting_level_e cpu_boosting_level_search(struct sched_attr attr)
 {
        attr.sched_policy = attr.sched_policy & ~SCHED_RESET_ON_FORK;
diff --git a/src/resource-optimizer/cpu/cpu-boosting.h b/src/resource-optimizer/cpu/cpu-boosting.h
new file mode 100644 (file)
index 0000000..8223d6c
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * resourced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file cpu-boosting.h
+ * @desc cpu boosting handler.
+ **/
+
+#ifndef __CPU_BOOSTING_H__
+#define __CPU_BOOSTING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void cpu_boosting_wakeup_cpu_boosting_thread(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /*__CPU_BOOSTING_H__*/
+