diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2023-09-01 08:01:40 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2023-09-01 08:01:40 +0900 |
commit | 56af157d856415e171aa6eb6d73a2fe6cae4b82f (patch) | |
tree | 696785e7bddf79577936e4f13f4ae9615489d7e1 | |
parent | ac1616d6b03f30480842989e25af1463ba300e98 (diff) | |
download | launchpad-56af157d856415e171aa6eb6d73a2fe6cae4b82f.tar.gz launchpad-56af157d856415e171aa6eb6d73a2fe6cae4b82f.tar.bz2 launchpad-56af157d856415e171aa6eb6d73a2fe6cae4b82f.zip |
Set reset on fork flag
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>
-rw-r--r-- | src/launchpad-process-pool/launchpad.cc | 2 | ||||
-rw-r--r-- | src/lib/launchpad-common/cpu_boost_controller.cc | 7 | ||||
-rw-r--r-- | src/lib/launchpad-common/cpu_boost_controller.hh | 3 |
3 files changed, 7 insertions, 5 deletions
diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index 672bc98..c1f0f9b 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -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) { diff --git a/src/lib/launchpad-common/cpu_boost_controller.cc b/src/lib/launchpad-common/cpu_boost_controller.cc index c72d80b..615adbd 100644 --- a/src/lib/launchpad-common/cpu_boost_controller.cc +++ b/src/lib/launchpad-common/cpu_boost_controller.cc @@ -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 diff --git a/src/lib/launchpad-common/cpu_boost_controller.hh b/src/lib/launchpad-common/cpu_boost_controller.hh index ae0df27..715b4bd 100644 --- a/src/lib/launchpad-common/cpu_boost_controller.hh +++ b/src/lib/launchpad-common/cpu_boost_controller.hh @@ -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); }; |