From e66b173e3d3654a6c3f4db0c040fba146d46c789 Mon Sep 17 00:00:00 2001 From: Zhao-PengFei35 Date: Thu, 19 Oct 2023 09:43:57 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zhao-PengFei35 --- .../sched_controller/cgroup_adjuster.cpp | 5 +- .../sched_controller/cgroup_event_handler.cpp | 85 +++++++++++++++++++ .../include/cgroup_adjuster.h | 3 + .../include/cgroup_event_handler.h | 3 + .../sched_controller/include/supervisor.h | 16 +++- .../sched_controller/sched_controller.cpp | 8 ++ .../framework/sched_controller/supervisor.cpp | 12 +++ 7 files changed, 130 insertions(+), 2 deletions(-) diff --git a/cgroup_sched/framework/sched_controller/cgroup_adjuster.cpp b/cgroup_sched/framework/sched_controller/cgroup_adjuster.cpp index 9ccf8e01..31ad9a98 100644 --- a/cgroup_sched/framework/sched_controller/cgroup_adjuster.cpp +++ b/cgroup_sched/framework/sched_controller/cgroup_adjuster.cpp @@ -76,8 +76,11 @@ void CgroupAdjuster::AdjustProcessGroup(Application &app, ProcessRecord &pr, Adj for (const auto &iter : app.GetPidsMap()) { const auto &procRecord = iter.second; if (procRecord && procRecord->isRenderProcess_) { - CGS_LOGI("%{public}s for %{public}d, source : %{public}d", __func__, procRecord->GetPid(), source); + CGS_LOGD("%{public}s for %{public}d, source : %{public}d for render process", + __func__, procRecord->GetPid(), source); procRecord->setSchedGroup_ = mainProcRecord->curSchedGroup_; + ResSchedUtils::GetInstance().ReportArbitrationResult(app, *(procRecord.get()), + AdjustSource::ADJS_SELF_RENDER_THREAD); ApplyProcessGroup(app, *procRecord); } } diff --git a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp index 8647331c..ebd48ae2 100644 --- a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp +++ b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp @@ -34,6 +34,7 @@ namespace { constexpr uint32_t EVENT_ID_REG_BGTASK_OBSERVER = 2; constexpr uint32_t DELAYED_RETRY_REGISTER_DURATION = 100; constexpr uint32_t MAX_RETRY_TIMES = 100; + constexpr uint32_t MAX_SPAN_SERIAL = 99; const std::string MMI_SERVICE_NAME = "mmi_service"; } @@ -422,6 +423,7 @@ void CgroupEventHandler::HandleUnfocusedWindow(uint32_t windowId, uintptr_t abil win->displayId_ = displayId; win->ability_ = abi; + app->focusedWindowId_ = -1; if (app->focusedProcess_ == procRecord) { app->focusedProcess_ = nullptr; } @@ -520,6 +522,79 @@ void CgroupEventHandler::HandleReportRenderThread(uint32_t resType, int64_t valu AdjustSource::ADJS_REPORT_RENDER_THREAD); } +void CgroupEventHandler::HandleReportKeyThread(uint32_t resType, int64_t value, const nlohmann::json& payload) +{ + int32_t uid = 0; + int32_t pid = 0; + int32_t keyTid = 0; + int32_t role = 0; + + if (!ParseValue(uid, "uid", payload) || !ParseValue(pid, "pid", payload) || + !ParseValue(keyTid, "tid", payload) || !ParseValue(role, "role", payload)) { + return; + } + + if (uid <= 0 || pid <= 0) { + return; + } + + auto app = supervisor_->GetAppRecordNonNull(uid); + auto procRecord = app->GetProcessRecordNonNull(pid); + if (value == ResType::ReportChangeStatus::CREATE) { + procRecord->keyThreadRoleMap_.emplace(keyTid, role); + } else { + procRecord->keyThreadRoleMap_.erase(keyTid); + } + + // if role of thread is important display, adjust it + auto mainProcRecord = app->GetMainProcessRecord(); + CgroupAdjuster::GetInstance().AdjustProcessGroup(*(app.get()), *(mainProcRecord.get()), + AdjustSource::ADJS_REPORT_IMPORTANT_DISPLAY_THREAD); +} + +void CgroupEventHandler::HandleReportWindowState(uint32_t resType, int64_t value, const nlohmann::json& payload) +{ + int32_t uid = 0; + int32_t pid = 0; + int32_t windowId = -1; + int32_t state = -1; + int32_t nowSerialNum = -1; + + if (!supervisor_) { + CGS_LOGE("%{public}s : supervisor nullptr!", __func__); + return; + } + + CGS_LOGD("%{public}s : render process name: %{public}s, uid: %{public}d, pid: %{public}d, state: %{public}d", + __func__, app->GetName().c_str(), uid, pid, state); + if (!ParseValue(uid, "uid", payload) || !ParseValue(pid, "pid", payload) || + !ParseValue(windowId, "windowId", payload) || !ParseValue(state, "state", payload) || + !ParseValue(nowSerialNum, "serialNum", payload)) { + return; + } + if (uid <= 0 || pid <= 0) { + return; + } + + auto app = supervisor_->GetAppRecordNonNull(uid); + auto procRecord = app->GetProcessRecordNonNull(pid); + if (nowSerialNum <= procRecord->serialNum_ && (procRecord->serialNum_ - nowSerialNum <= MAX_SPAN_SERIAL)) { + return; + } + procRecord->serialNum_ = nowSerialNum; + + if (state == ResType::WindowStates::ACTIVE) { + procRecord->linkedWindowId_ = windowId; + procRecord->SetIsWindowActive(true); + } else { + procRecord->linkedWindowId_ = -1; + procRecord->SetIsWindowActive(false); + } + auto mainProcRecord = app->GetMainProcessRecord(); + CgroupAdjuster::GetInstance().AdjustProcessGroup(*(app.get()), *(mainProcRecord.get()), + AdjustSource::ADJS_REPORT_WINDOW_STATE_CHANGED); +} + bool CgroupEventHandler::ParsePayload(int32_t& uid, int32_t& pid, int32_t& tid, int64_t value, const nlohmann::json& payload) { @@ -533,5 +608,15 @@ bool CgroupEventHandler::ParsePayload(int32_t& uid, int32_t& pid, int32_t& tid, tid = static_cast(value); return true; } + +bool CgroupEventHandler::ParseValue(int32_t& value, const char* name, + const nlohmann::json& payload) +{ + if (payload.contains(name) && payload.at(name).is_string()) { + value = atoi(payload[name].get().c_str()); + return true; + } + return false; +} } // namespace ResourceSchedule } // namespace OHOS diff --git a/cgroup_sched/framework/sched_controller/include/cgroup_adjuster.h b/cgroup_sched/framework/sched_controller/include/cgroup_adjuster.h index 08901dfd..fb84d0f5 100644 --- a/cgroup_sched/framework/sched_controller/include/cgroup_adjuster.h +++ b/cgroup_sched/framework/sched_controller/include/cgroup_adjuster.h @@ -37,6 +37,9 @@ enum class AdjustSource { ADJS_WINDOW_VISIBILITY_CHANGED, ADJS_REPORT_RENDER_THREAD, ADJS_REPORT_MMI_SERVICE_THREAD, + ADJS_REPORT_IMPORTANT_DISPLAY_THREAD, + ADJS_SELF_RENDER_THREAD, + ADJS_REPORT_WINDOW_STATE_CHANGED, ADJS_END }; diff --git a/cgroup_sched/framework/sched_controller/include/cgroup_event_handler.h b/cgroup_sched/framework/sched_controller/include/cgroup_event_handler.h index 4e9f8435..b6ce8581 100644 --- a/cgroup_sched/framework/sched_controller/include/cgroup_event_handler.h +++ b/cgroup_sched/framework/sched_controller/include/cgroup_event_handler.h @@ -56,9 +56,12 @@ public: WindowType windowType, int32_t pid, int32_t uid); void HandleReportMMIProcess(uint32_t resType, int64_t value, const nlohmann::json& payload); void HandleReportRenderThread(uint32_t resType, int64_t value, const nlohmann::json& payload); + void HandleReportKeyThread(uint32_t resType, int64_t value, const nlohmann::json& payload); + void HandleReportWindowState(uint32_t resType, int64_t value, const nlohmann::json& payload); private: bool ParsePayload(int32_t& uid, int32_t& pid, int32_t& tid, int64_t value, const nlohmann::json& payload); + bool ParseValue(int32_t& value, const char* name, const nlohmann::json& payload); std::shared_ptr supervisor_; }; } // namespace ResourceSchedule diff --git a/cgroup_sched/framework/sched_controller/include/supervisor.h b/cgroup_sched/framework/sched_controller/include/supervisor.h index 3cdf20f4..bd890841 100644 --- a/cgroup_sched/framework/sched_controller/include/supervisor.h +++ b/cgroup_sched/framework/sched_controller/include/supervisor.h @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "sched_policy.h" @@ -79,6 +81,15 @@ public: bool HasAbility(uintptr_t token) const; bool HasServiceExtension() const; bool IsVisible() const; + std::set GetKeyTidSetByRole(int64_t role); + + inline void SetIsWindowActive(bool isActive) { + isActive_ = isActive; + } + + inline bool IsWindowActive(bool isActive) { + return isActive_; + } inline pid_t GetPid() const { @@ -102,6 +113,10 @@ public: std::vector> abilities_; std::vector> windows_; + std::map keyThreadRoleMap_ {}; + bool isActive_ {false}; + int32_t linkedWindowId_ {-1}; + int32_t serialNum_ {-1}; private: uid_t uid_; pid_t pid_; @@ -146,7 +161,6 @@ public: SchedPolicy lastSchedGroup_ = SP_UPPER_LIMIT; SchedPolicy curSchedGroup_ = SP_UPPER_LIMIT; SchedPolicy setSchedGroup_ = SP_UPPER_LIMIT; - private: uid_t uid_; std::string name_; diff --git a/cgroup_sched/framework/sched_controller/sched_controller.cpp b/cgroup_sched/framework/sched_controller/sched_controller.cpp index 9652e3fd..90515c8a 100644 --- a/cgroup_sched/framework/sched_controller/sched_controller.cpp +++ b/cgroup_sched/framework/sched_controller/sched_controller.cpp @@ -131,6 +131,14 @@ void SchedController::DispatchResource(uint32_t resType, int64_t value, const nl handler->HandleReportRenderThread(resType, value, payload); break; } + case ResType::RES_TYPE_REPORT_KEY_THREAD: { + handler->HandleReportKeyThread(resType, value, payload); + break; + } + case ResType::RES_TYPE_REPORT_WINDOW_STATE: { + handler->HandleReportWindowState(resType, value, payload); + break; + } default: { break; } diff --git a/cgroup_sched/framework/sched_controller/supervisor.cpp b/cgroup_sched/framework/sched_controller/supervisor.cpp index 17999894..f4273659 100644 --- a/cgroup_sched/framework/sched_controller/supervisor.cpp +++ b/cgroup_sched/framework/sched_controller/supervisor.cpp @@ -91,6 +91,18 @@ bool ProcessRecord::IsVisible() const }); } +std::set ProcessRecord::GetKeyTidSetByRole(int64_t role) +{ + std::set tids; + for (const auto [tid, tidRole] : keyThreadRoleMap_) { + if (tidRole != role) { + continue; + } + tids.insert(tid); + } + return tids; +} + std::shared_ptr Application::AddProcessRecord(std::shared_ptr pr) { if (pr) { -- Gitee From 03af5474527476aa244335fc0c4a22f24fd68365 Mon Sep 17 00:00:00 2001 From: Zhao-PengFei35 Date: Thu, 19 Oct 2023 22:32:57 +0800 Subject: [PATCH 2/5] modify code as review comments and add tdd Signed-off-by: Zhao-PengFei35 --- .../sched_controller/cgroup_adjuster.cpp | 2 +- .../sched_controller/cgroup_event_handler.cpp | 14 +++++--- .../sched_controller/include/supervisor.h | 9 ++--- .../framework/sched_controller/supervisor.cpp | 2 +- .../test/unittest/src/res_sched_mgr_test.cpp | 34 ++++++++++++++++++- 5 files changed, 49 insertions(+), 12 deletions(-) diff --git a/cgroup_sched/framework/sched_controller/cgroup_adjuster.cpp b/cgroup_sched/framework/sched_controller/cgroup_adjuster.cpp index 31ad9a98..ce39fa89 100644 --- a/cgroup_sched/framework/sched_controller/cgroup_adjuster.cpp +++ b/cgroup_sched/framework/sched_controller/cgroup_adjuster.cpp @@ -76,7 +76,7 @@ void CgroupAdjuster::AdjustProcessGroup(Application &app, ProcessRecord &pr, Adj for (const auto &iter : app.GetPidsMap()) { const auto &procRecord = iter.second; if (procRecord && procRecord->isRenderProcess_) { - CGS_LOGD("%{public}s for %{public}d, source : %{public}d for render process", + CGS_LOGI("%{public}s for %{public}d, source : %{public}d for render process", __func__, procRecord->GetPid(), source); procRecord->setSchedGroup_ = mainProcRecord->curSchedGroup_; ResSchedUtils::GetInstance().ReportArbitrationResult(app, *(procRecord.get()), diff --git a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp index ebd48ae2..6488099f 100644 --- a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp +++ b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp @@ -423,7 +423,6 @@ void CgroupEventHandler::HandleUnfocusedWindow(uint32_t windowId, uintptr_t abil win->displayId_ = displayId; win->ability_ = abi; - app->focusedWindowId_ = -1; if (app->focusedProcess_ == procRecord) { app->focusedProcess_ = nullptr; } @@ -529,6 +528,11 @@ void CgroupEventHandler::HandleReportKeyThread(uint32_t resType, int64_t value, int32_t keyTid = 0; int32_t role = 0; + if (!supervisor_) { + CGS_LOGE("%{public}s : supervisor nullptr!", __func__); + return; + } + if (!ParseValue(uid, "uid", payload) || !ParseValue(pid, "pid", payload) || !ParseValue(keyTid, "tid", payload) || !ParseValue(role, "role", payload)) { return; @@ -557,7 +561,7 @@ void CgroupEventHandler::HandleReportWindowState(uint32_t resType, int64_t value int32_t uid = 0; int32_t pid = 0; int32_t windowId = -1; - int32_t state = -1; + int32_t state = 0; int32_t nowSerialNum = -1; if (!supervisor_) { @@ -565,19 +569,19 @@ void CgroupEventHandler::HandleReportWindowState(uint32_t resType, int64_t value return; } - CGS_LOGD("%{public}s : render process name: %{public}s, uid: %{public}d, pid: %{public}d, state: %{public}d", - __func__, app->GetName().c_str(), uid, pid, state); if (!ParseValue(uid, "uid", payload) || !ParseValue(pid, "pid", payload) || !ParseValue(windowId, "windowId", payload) || !ParseValue(state, "state", payload) || !ParseValue(nowSerialNum, "serialNum", payload)) { return; } - if (uid <= 0 || pid <= 0) { + if (uid <= 0 || pid <= 0) { return; } auto app = supervisor_->GetAppRecordNonNull(uid); auto procRecord = app->GetProcessRecordNonNull(pid); + CGS_LOGD("%{public}s : render process name: %{public}s, uid: %{public}d, pid: %{public}d, state: %{public}d", + __func__, app->GetName().c_str(), uid, pid, state); if (nowSerialNum <= procRecord->serialNum_ && (procRecord->serialNum_ - nowSerialNum <= MAX_SPAN_SERIAL)) { return; } diff --git a/cgroup_sched/framework/sched_controller/include/supervisor.h b/cgroup_sched/framework/sched_controller/include/supervisor.h index bd890841..32bacaae 100644 --- a/cgroup_sched/framework/sched_controller/include/supervisor.h +++ b/cgroup_sched/framework/sched_controller/include/supervisor.h @@ -106,17 +106,17 @@ public: SchedPolicy setSchedGroup_ = SP_UPPER_LIMIT; bool isRenderProcess_ = false; bool runningTransientTask_ = false; + bool isActive_ {false}; uint32_t continuousTaskFlag_ = 0; int32_t renderTid_ = 0; int32_t maliTid_ = 0; + int32_t linkedWindowId_ {-1}; + int32_t serialNum_ {-1}; std::vector> abilities_; std::vector> windows_; - std::map keyThreadRoleMap_ {}; - bool isActive_ {false}; - int32_t linkedWindowId_ {-1}; - int32_t serialNum_ {-1}; + std::map keyThreadRoleMap_ {}; // items in keyThreadMap_ is (tid, role) private: uid_t uid_; pid_t pid_; @@ -161,6 +161,7 @@ public: SchedPolicy lastSchedGroup_ = SP_UPPER_LIMIT; SchedPolicy curSchedGroup_ = SP_UPPER_LIMIT; SchedPolicy setSchedGroup_ = SP_UPPER_LIMIT; + private: uid_t uid_; std::string name_; diff --git a/cgroup_sched/framework/sched_controller/supervisor.cpp b/cgroup_sched/framework/sched_controller/supervisor.cpp index f4273659..7dcb9e5a 100644 --- a/cgroup_sched/framework/sched_controller/supervisor.cpp +++ b/cgroup_sched/framework/sched_controller/supervisor.cpp @@ -93,7 +93,7 @@ bool ProcessRecord::IsVisible() const std::set ProcessRecord::GetKeyTidSetByRole(int64_t role) { - std::set tids; + std::set tids {}; for (const auto [tid, tidRole] : keyThreadRoleMap_) { if (tidRole != role) { continue; diff --git a/ressched/test/unittest/src/res_sched_mgr_test.cpp b/ressched/test/unittest/src/res_sched_mgr_test.cpp index 1200218b..b483b209 100644 --- a/ressched/test/unittest/src/res_sched_mgr_test.cpp +++ b/ressched/test/unittest/src/res_sched_mgr_test.cpp @@ -57,10 +57,42 @@ HWTEST_F(ResSchedMgrTest, ReportData001, TestSize.Level1) nlohmann::json payload; ResSchedMgr::GetInstance().ReportData(0, 0, payload); EXPECT_TRUE(ResSchedMgr::GetInstance().killProcess_ != nullptr); - + ResSchedMgr::GetInstance().DispatchResourceInner(0, 0, payload); } +/** + * @tc.name: Init ressched ReportData 003 + * @tc.desc: Verify if ReportData is success + * @tc.type: FUNC + * @tc.require: issueI5WWV3 + * @tc.author:lice + */ +HWTEST_F(ResSchedMgrTest, ReportData001, TestSize.Level1) +{ + nlohmann::json payload; + ResSchedMgr::GetInstance().ReportData(ResType::RES_TYPE_REPORT_KEY_THREAD, 0, payload); + EXPECT_TRUE(ResSchedMgr::GetInstance().killProcess_ != nullptr); + + ResSchedMgr::GetInstance().DispatchResourceInner(ResType::RES_TYPE_REPORT_KEY_THREAD, 0, payload); +} + +/** + * @tc.name: Init ressched ReportData 004 + * @tc.desc: Verify if ReportData is success + * @tc.type: FUNC + * @tc.require: issueI5WWV3 + * @tc.author:lice + */ +HWTEST_F(ResSchedMgrTest, ReportData001, TestSize.Level1) +{ + nlohmann::json payload; + ResSchedMgr::GetInstance().ReportData(ResType::RES_TYPE_REPORT_WINDOW_STATE, 0, payload); + EXPECT_TRUE(ResSchedMgr::GetInstance().killProcess_ != nullptr); + + ResSchedMgr::GetInstance().DispatchResourceInner(ResType::RES_TYPE_REPORT_WINDOW_STATE, 0, payload); +} + /** * @tc.name: Init ressched KillProcess 001 * @tc.desc: Verify if killProcess is success -- Gitee From 8cf587cf72cd920e39f773ca00de1216bcc67462 Mon Sep 17 00:00:00 2001 From: Zhao-PengFei35 Date: Sat, 21 Oct 2023 15:47:26 +0800 Subject: [PATCH 3/5] fix bug of tdd Signed-off-by: Zhao-PengFei35 --- .../sched_controller/cgroup_event_handler.cpp | 4 ++-- .../sched_controller/include/supervisor.h | 4 ++-- .../test/unittest/src/res_sched_mgr_test.cpp | 16 +++++++--------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp index 6488099f..3e20c4e1 100644 --- a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp +++ b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp @@ -589,10 +589,10 @@ void CgroupEventHandler::HandleReportWindowState(uint32_t resType, int64_t value if (state == ResType::WindowStates::ACTIVE) { procRecord->linkedWindowId_ = windowId; - procRecord->SetIsWindowActive(true); + procRecord->SetActive(true); } else { procRecord->linkedWindowId_ = -1; - procRecord->SetIsWindowActive(false); + procRecord->SetActive(false); } auto mainProcRecord = app->GetMainProcessRecord(); CgroupAdjuster::GetInstance().AdjustProcessGroup(*(app.get()), *(mainProcRecord.get()), diff --git a/cgroup_sched/framework/sched_controller/include/supervisor.h b/cgroup_sched/framework/sched_controller/include/supervisor.h index 32bacaae..96ca279a 100644 --- a/cgroup_sched/framework/sched_controller/include/supervisor.h +++ b/cgroup_sched/framework/sched_controller/include/supervisor.h @@ -83,11 +83,11 @@ public: bool IsVisible() const; std::set GetKeyTidSetByRole(int64_t role); - inline void SetIsWindowActive(bool isActive) { + inline void SetActive(bool isActive) { isActive_ = isActive; } - inline bool IsWindowActive(bool isActive) { + inline bool IsActive() { return isActive_; } diff --git a/ressched/test/unittest/src/res_sched_mgr_test.cpp b/ressched/test/unittest/src/res_sched_mgr_test.cpp index b483b209..44f1b941 100644 --- a/ressched/test/unittest/src/res_sched_mgr_test.cpp +++ b/ressched/test/unittest/src/res_sched_mgr_test.cpp @@ -46,7 +46,7 @@ HWTEST_F(ResSchedMgrTest, Init001, TestSize.Level1) } /** - * @tc.name: Init ressched ReportData 002 + * @tc.name: Init ressched ReportData 001 * @tc.desc: Verify if ReportData is success * @tc.type: FUNC * @tc.require: issueI5WWV3 @@ -62,13 +62,12 @@ HWTEST_F(ResSchedMgrTest, ReportData001, TestSize.Level1) } /** - * @tc.name: Init ressched ReportData 003 + * @tc.name: Init ressched ReportData 002 * @tc.desc: Verify if ReportData is success * @tc.type: FUNC - * @tc.require: issueI5WWV3 - * @tc.author:lice + * @tc.require: issueI897BM */ -HWTEST_F(ResSchedMgrTest, ReportData001, TestSize.Level1) +HWTEST_F(ResSchedMgrTest, ReportData002, TestSize.Level1) { nlohmann::json payload; ResSchedMgr::GetInstance().ReportData(ResType::RES_TYPE_REPORT_KEY_THREAD, 0, payload); @@ -78,13 +77,12 @@ HWTEST_F(ResSchedMgrTest, ReportData001, TestSize.Level1) } /** - * @tc.name: Init ressched ReportData 004 + * @tc.name: Init ressched ReportData 003 * @tc.desc: Verify if ReportData is success * @tc.type: FUNC - * @tc.require: issueI5WWV3 - * @tc.author:lice + * @tc.require: issueI897BM */ -HWTEST_F(ResSchedMgrTest, ReportData001, TestSize.Level1) +HWTEST_F(ResSchedMgrTest, ReportData003, TestSize.Level1) { nlohmann::json payload; ResSchedMgr::GetInstance().ReportData(ResType::RES_TYPE_REPORT_WINDOW_STATE, 0, payload); -- Gitee From e4d5da1b863ee44f71cd3dc2fbf9d0b75cbf19d3 Mon Sep 17 00:00:00 2001 From: Zhao-PengFei35 Date: Mon, 23 Oct 2023 14:12:00 +0800 Subject: [PATCH 4/5] modify as review comment Signed-off-by: Zhao-PengFei35 --- .../framework/sched_controller/cgroup_event_handler.cpp | 4 ++-- .../framework/sched_controller/include/supervisor.h | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp index 3e20c4e1..9424a504 100644 --- a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp +++ b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp @@ -589,10 +589,10 @@ void CgroupEventHandler::HandleReportWindowState(uint32_t resType, int64_t value if (state == ResType::WindowStates::ACTIVE) { procRecord->linkedWindowId_ = windowId; - procRecord->SetActive(true); + procRecord->isActive_ = true; } else { procRecord->linkedWindowId_ = -1; - procRecord->SetActive(false); + procRecord->isActive_ = false;; } auto mainProcRecord = app->GetMainProcessRecord(); CgroupAdjuster::GetInstance().AdjustProcessGroup(*(app.get()), *(mainProcRecord.get()), diff --git a/cgroup_sched/framework/sched_controller/include/supervisor.h b/cgroup_sched/framework/sched_controller/include/supervisor.h index 96ca279a..b7598943 100644 --- a/cgroup_sched/framework/sched_controller/include/supervisor.h +++ b/cgroup_sched/framework/sched_controller/include/supervisor.h @@ -83,14 +83,6 @@ public: bool IsVisible() const; std::set GetKeyTidSetByRole(int64_t role); - inline void SetActive(bool isActive) { - isActive_ = isActive; - } - - inline bool IsActive() { - return isActive_; - } - inline pid_t GetPid() const { return pid_; -- Gitee From c9a37ed1d4d1c7b2e9a1dc37812ff46241ea1f5d Mon Sep 17 00:00:00 2001 From: Zhao-PengFei35 Date: Tue, 24 Oct 2023 16:01:40 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zhao-PengFei35 --- .../framework/sched_controller/cgroup_event_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp index 9424a504..e1cb3cf0 100644 --- a/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp +++ b/cgroup_sched/framework/sched_controller/cgroup_event_handler.cpp @@ -592,7 +592,7 @@ void CgroupEventHandler::HandleReportWindowState(uint32_t resType, int64_t value procRecord->isActive_ = true; } else { procRecord->linkedWindowId_ = -1; - procRecord->isActive_ = false;; + procRecord->isActive_ = false; } auto mainProcRecord = app->GetMainProcessRecord(); CgroupAdjuster::GetInstance().AdjustProcessGroup(*(app.get()), *(mainProcRecord.get()), -- Gitee