From 0d8bf0d689b2b35a9ec90c4353731f861b770cc2 Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Wed, 14 Aug 2024 16:20:15 +0800 Subject: [PATCH 1/3] qos_manager HILOG level change Signed-off-by: liuyuxiu --- services/src/concurrent_task_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index d1cb67a..b2df054 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -882,7 +882,7 @@ int TaskController::FindRateFromInfo(int uiTid, const Json::Value& payload) { int appRate = 0; if (payload[std::to_string(uiTid)].isNull()) { - CONCUR_LOGI("FindRateFromInfo tid %{public}d is null", uiTid); + CONCUR_LOGD("FindRateFromInfo tid %{public}d is null", uiTid); return appRate; } try { -- Gitee From 5ea7e5579421cb8573f7fe62d8c02ab96e3d9c7e Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Sat, 17 Aug 2024 15:21:48 +0800 Subject: [PATCH 2/3] qos_manager check code Bugfix Signed-off-by: liuyuxiu --- services/include/concurrent_task_controller.h | 2 +- services/src/concurrent_task_controller.cpp | 32 +++++++++++-------- services/src/qos_interface.cpp | 1 + 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 5dadc7a..5315f23 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -82,7 +82,7 @@ private: void SetAppAndRenderServiceRate(int appRate, int rsRate); bool CheckJsonValid(const Json::Value& payload); void SetFrameRate(int rtgId, int rate); - std::list::iterator GetRecordOfPid(int pid); + std::shared_ptr GetRecordOfPid(int pid); void PrintInfo(); bool ParsePayload(const Json::Value& payload, int& uid, int& pid, std::string& bundleName); std::string GetProcessNameByToken(); diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index b2df054..d6dd0b4 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -149,12 +149,12 @@ std::string TaskController::GetProcessNameByToken() void TaskController::QueryUi(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - auto iter = GetRecordOfPid(pid); - if (iter == foregroundApp_.end()) { + std::shared_ptr record = GetRecordOfPid(pid); + if (!record) { CONCUR_LOGD("Query ui with pid %{public}d failed", pid); return; } - int grpId = iter->GetGrpId(); + int grpId = (*record)->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query ui with none grpid", pid); queryRs.rtgId = -1; @@ -167,12 +167,12 @@ void TaskController::QueryUi(int uid, IntervalReply& queryRs) void TaskController::QueryRender(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - auto iter = GetRecordOfPid(pid); - if (iter == foregroundApp_.end()) { + std::shared_ptr record = GetRecordOfPid(pid); + if (!record) { CONCUR_LOGD("Query render with pid %{public}d failed", pid); return; } - int grpId = iter->GetGrpId(); + int grpId = (*record)->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query render with none grpid", pid); queryRs.rtgId = -1; @@ -312,12 +312,12 @@ void TaskController::QueryExecutorStart(int uid, int pid, IntervalReply& queryRs void TaskController::QueryHwc(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - auto iter = GetRecordOfPid(pid); - if (iter == foregroundApp_.end()) { + std::shared_ptr record = GetRecordOfPid(pid); + if (!record) { CONCUR_LOGD("Query ipc thread with pid %{public}d failed", pid); return; } - int grpId = iter->GetGrpId(); + int grpId = (*record)->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query ipc thread with none grpid", pid); queryRs.rtgId = -1; @@ -498,15 +498,18 @@ void TaskController::DealSystemRequest(int requestType, const Json::Value& paylo } } -std::list::iterator TaskController::GetRecordOfPid(int pid) +std::shared_ptr TaskController::GetRecordOfPid(int pid) { std::lock_guard lock(appInfoLock_); for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { if (iter->GetPid() == pid) { - return iter; + std::shared_ptr record = std::make_shared(&*iter); + if (record != nullptr) { + return record; + } } } - return foregroundApp_.end(); + return nullptr; } void TaskController::NewForeground(int uid, int pid) @@ -519,6 +522,7 @@ void TaskController::NewForeground(int uid, int pid) } int ret = AuthGet(pid); if (ret != static_cast(AuthStatus::AUTH_STATUS_FOCUS)) { + CONCUR_LOGI("pid %{public}d change to foreground.", pid); unsigned int pidParam = static_cast(pid); unsigned int uaFlag = AF_RTG_ALL; unsigned int status = static_cast(AuthStatus::AUTH_STATUS_FOREGROUND); @@ -528,7 +532,6 @@ void TaskController::NewForeground(int uid, int pid) } else { CONCUR_LOGE("auth_enable %{public}d fail with ret %{public}d", pid, ret); } - CONCUR_LOGI("pid %{public}d change to foreground.", pid); } else { CONCUR_LOGI("pid %{public}d is already focus", pid); } @@ -542,6 +545,7 @@ void TaskController::NewForeground(int uid, int pid) iter->AddKeyThread(uiTid, PRIO_RT); } iter->BeginScene(); + break; } } if (!found) { @@ -624,7 +628,7 @@ void TaskController::AppKilled(int uid, int pid) std::lock_guard lock(appInfoLock_); for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { if (iter->GetPid() == pid) { - foregroundApp_.erase(iter++); + foregroundApp_.erase(iter); break; } } diff --git a/services/src/qos_interface.cpp b/services/src/qos_interface.cpp index 4bc270e..164def1 100644 --- a/services/src/qos_interface.cpp +++ b/services/src/qos_interface.cpp @@ -204,6 +204,7 @@ int AuthGet(unsigned int pid) ret = ioctl(fd, BASIC_AUTH_CTRL_OPERATION, &data); if (ret < 0) { + close(fd); return ret; } close(fd); -- Gitee From 66e928405afadea86796cc7296f1068461a8bcca Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Mon, 19 Aug 2024 10:54:39 +0800 Subject: [PATCH 3/3] qos_manager code check Bugfix Signed-off-by: liuyuxiu --- services/include/concurrent_task_controller.h | 2 +- services/src/concurrent_task_controller.cpp | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 5315f23..25e211a 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -82,7 +82,7 @@ private: void SetAppAndRenderServiceRate(int appRate, int rsRate); bool CheckJsonValid(const Json::Value& payload); void SetFrameRate(int rtgId, int rate); - std::shared_ptr GetRecordOfPid(int pid); + ForegroundAppRecord* GetRecordOfPid(int pid); void PrintInfo(); bool ParsePayload(const Json::Value& payload, int& uid, int& pid, std::string& bundleName); std::string GetProcessNameByToken(); diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index d6dd0b4..c0d510b 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -149,12 +149,12 @@ std::string TaskController::GetProcessNameByToken() void TaskController::QueryUi(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - std::shared_ptr record = GetRecordOfPid(pid); + ForegroundAppRecord* record = GetRecordOfPid(pid); if (!record) { CONCUR_LOGD("Query ui with pid %{public}d failed", pid); return; } - int grpId = (*record)->GetGrpId(); + int grpId = record->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query ui with none grpid", pid); queryRs.rtgId = -1; @@ -167,12 +167,12 @@ void TaskController::QueryUi(int uid, IntervalReply& queryRs) void TaskController::QueryRender(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - std::shared_ptr record = GetRecordOfPid(pid); + ForegroundAppRecord* record = GetRecordOfPid(pid); if (!record) { CONCUR_LOGD("Query render with pid %{public}d failed", pid); return; } - int grpId = (*record)->GetGrpId(); + int grpId = record->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query render with none grpid", pid); queryRs.rtgId = -1; @@ -312,12 +312,12 @@ void TaskController::QueryExecutorStart(int uid, int pid, IntervalReply& queryRs void TaskController::QueryHwc(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - std::shared_ptr record = GetRecordOfPid(pid); + ForegroundAppRecord* record = GetRecordOfPid(pid); if (!record) { CONCUR_LOGD("Query ipc thread with pid %{public}d failed", pid); return; } - int grpId = (*record)->GetGrpId(); + int grpId = record->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query ipc thread with none grpid", pid); queryRs.rtgId = -1; @@ -498,15 +498,12 @@ void TaskController::DealSystemRequest(int requestType, const Json::Value& paylo } } -std::shared_ptr TaskController::GetRecordOfPid(int pid) +ForegroundAppRecord* TaskController::GetRecordOfPid(int pid) { std::lock_guard lock(appInfoLock_); for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { if (iter->GetPid() == pid) { - std::shared_ptr record = std::make_shared(&*iter); - if (record != nullptr) { - return record; - } + return &*iter; } } return nullptr; -- Gitee