Set reset on fork flag 08/298108/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 31 Aug 2023 23:01:40 +0000 (08:01 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 31 Aug 2023 23:01:40 +0000 (08:01 +0900)
The CPU_BOOSTING_RESET_ON_FORK flag is required in order not to
unintentionally inherit the CPU boosting to child processes.

Change-Id: Ie0573b18d1e595f7d59e0cc3e76c8784fbceffd4
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/launchpad.cc
src/lib/launchpad-common/cpu_boost_controller.cc
src/lib/launchpad-common/cpu_boost_controller.hh

index 672bc98..c1f0f9b 100644 (file)
@@ -208,7 +208,7 @@ Launchpad::Launchpad(int argc, char** argv)
       level == CPUBoostController::Level::None ||
       level == CPUBoostController::Level::Weak) {
     CPUBoostController::DoBoost(getpid(), CPUBoostController::Level::Strong,
-        -1);
+        -1, true);
   }
 
   g_timeout_add(1000, [](gpointer data) {
index c72d80b..615adbd 100644 (file)
@@ -24,7 +24,8 @@
 
 namespace launchpad {
 
-void CPUBoostController::DoBoost(pid_t pid, Level level, int timeout_msec) {
+void CPUBoostController::DoBoost(pid_t pid, Level level, int timeout_msec,
+    bool reset_on_fork) {
   if (pid < 1)
     return;
 
@@ -33,10 +34,10 @@ void CPUBoostController::DoBoost(pid_t pid, Level level, int timeout_msec) {
       .tid = &pid,
       .tid_count = 1,
   };
-
+  int flag = reset_on_fork ? CPU_BOOSTING_RESET_ON_FORK : 0;
   int ret = resource_set_cpu_boosting(res_pid,
       static_cast<cpu_boosting_level_e>(level),
-      static_cast<cpu_boosting_flag_e>(0), timeout_msec);
+      static_cast<cpu_boosting_flag_e>(flag), timeout_msec);
   if (ret != 0)
     _E("resource_set_cpu_boosting() is failed. error: %d", ret);
   else
index ae0df27..715b4bd 100644 (file)
@@ -33,7 +33,8 @@ class EXPORT_API CPUBoostController {
     Weak,
   };
 
-  static void DoBoost(pid_t pid, Level level, int timeout_msec);
+  static void DoBoost(pid_t pid, Level level, int timeout_msec,
+      bool reset_on_fork = false);
   static void Clear(pid_t pid);
   static int GetBoostLevel(pid_t pid, Level* level);
 };