From 0cca1e86dbafb19b60d3d0a0a6cd325240e79c1a Mon Sep 17 00:00:00 2001 From: edwardcaoyue Date: Wed, 18 Oct 2023 15:22:09 +0800 Subject: [PATCH] remove qos_manager component Signed-off-by: edwardcaoyue Change-Id: I772754d5eb57f33ccab112161ee2e9696fbd84b8 --- bundle.json | 12 +- interfaces/inner_api/qos.h | 58 -------- qos_manager/BUILD.gn | 36 ----- qos_manager/include/qos_common.h | 50 ------- qos_manager/src/qos_common.cpp | 74 ---------- qos_manager/src/qos_manager.cpp | 179 ----------------------- test/BUILD.gn | 21 --- test/unittest/phone/qos_manager_test.cpp | 100 ------------- 8 files changed, 1 insertion(+), 529 deletions(-) delete mode 100644 interfaces/inner_api/qos.h delete mode 100644 qos_manager/BUILD.gn delete mode 100644 qos_manager/src/qos_manager.cpp delete mode 100644 test/unittest/phone/qos_manager_test.cpp diff --git a/bundle.json b/bundle.json index 52b507b..e8be692 100644 --- a/bundle.json +++ b/bundle.json @@ -40,8 +40,7 @@ "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf:frame_msg_intf", "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf:frame_trace_intf", "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf:rtg_interface", - "//foundation/resourceschedule/frame_aware_sched/profiles:frame_aware_sched_config", - "//foundation/resourceschedule/frame_aware_sched/qos_manager:qos_manager" + "//foundation/resourceschedule/frame_aware_sched/profiles:frame_aware_sched_config" ], "inner_kits": [ { @@ -71,15 +70,6 @@ }, "name": "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf:frame_trace_intf" }, - { - "header": { - "header_base": "//foundation/resourceschedule/frame_aware_sched/interfaces/inner_api/", - "header_files": [ - "qos.h" - ] - }, - "name": "//foundation/resourceschedule/frame_aware_sched/qos_manager:qos_manager" - }, { "header": { "header_base": "//foundation/resourceschedule/frame_aware_sched/common/include", diff --git a/interfaces/inner_api/qos.h b/interfaces/inner_api/qos.h deleted file mode 100644 index 28553f7..0000000 --- a/interfaces/inner_api/qos.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * 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. - */ - -#ifndef QOS_MANAGER_H -#define QOS_MANAGER_H - -namespace OHOS { -namespace QOS { -enum class QosLevel { - qos_background = 1, - qos_utility, - qos_default, - qos_user_initiated, - qos_deadline_request, - qos_user_interactive, -}; - -class QosController { -public: - static QosController& GetInstance(); - - int SetThreadQosForOtherThread(enum QosLevel level, int tid); - int ResetThreadQosForOtherThread(int tid); - -private: - QosController() = default; - ~QosController() = default; - - QosController(const QosController&) = delete; - QosController& operator=(const QosController&) = delete; - QosController(QosController&&) = delete; - QosController& operator=(const QosController&&) = delete; - - int SetPolicy(); - bool policyStatus_ = false; -}; - -int SetThreadQos(enum QosLevel level); -int SetQosForOtherThread(enum QosLevel level, int tid); -int ResetThreadQos(); -int ResetQosForOtherThread(int tid); - -} // namespace QOS -} // namespace OHOS - -#endif // QOS_MANAGER_H \ No newline at end of file diff --git a/qos_manager/BUILD.gn b/qos_manager/BUILD.gn deleted file mode 100644 index 95c1686..0000000 --- a/qos_manager/BUILD.gn +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2023 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") - -config("qos_manager_config") { - visibility = [ ":*" ] - include_dirs = [ - "include/", - "../common/include/", - "../interfaces/inner_api/", - ] -} - -ohos_shared_library("qos_manager") { - public_configs = [ ":qos_manager_config" ] - sources = [ - "src/qos_common.cpp", - "src/qos_manager.cpp", - ] - - external_deps = [ "hilog:libhilog" ] - - subsystem_name = "resourceschedule" - part_name = "frame_aware_sched" -} diff --git a/qos_manager/include/qos_common.h b/qos_manager/include/qos_common.h index b54a5aa..671bf5c 100644 --- a/qos_manager/include/qos_common.h +++ b/qos_manager/include/qos_common.h @@ -18,16 +18,7 @@ namespace OHOS { namespace QosCommon { -constexpr int NR_QOS = 6; -constexpr int QOS_NICE_FLAG = 0x01; -constexpr int QOS_LATENCY_NICE_FLAG = 0x02; -constexpr int QOS_UCLAMP_FLAG = 0x04; -constexpr int QOS_RT_FLAG = 0x08; -constexpr int QOS_ALL_FLAG = (QOS_NICE_FLAG | QOS_LATENCY_NICE_FLAG | \ - QOS_UCLAMP_FLAG | QOS_RT_FLAG); - constexpr int AF_RTG_ALL = 0x1fff; -constexpr int AF_RTG_DELEGATED = 0x1fff; struct AuthCtrlData { int uid; @@ -37,26 +28,6 @@ struct AuthCtrlData { unsigned int status; }; -struct QosCtrlData { - int pid; - unsigned int type; - int level; -}; - -struct QosPolicyData { - int nice; - int latencyNice; - int uclampMin; - int uclampMax; - int rtSchedPriority; -}; - -struct QosPolicyDatas { - int policyType; - unsigned int policyFlag; - struct QosPolicyData policys[NR_QOS + 1]; -}; - enum AuthOperationType { AUTH_ENABLE = 1, AUTH_DELETE, @@ -65,20 +36,6 @@ enum AuthOperationType { AUTH_MAX_NR, }; -enum QosOperationType { - QOS_APPLY = 1, - QOS_LEAVE, - QOS_MAX_NR, -}; - -enum QosPolicyType { - QOS_POLICY_DEFAULT = 1, - QOS_POLICY_SYSTEM_SERVER = 2, - QOS_POLICY_FRONT = 3, - QOS_POLICY_BACK = 4, - QOS_POLICY_MAX_NR, -}; - enum AuthStatus { AUTH_STATUS_DISABLED = 1, AUTH_STATUS_SYSTEM_SERVER = 2, @@ -87,19 +44,12 @@ enum AuthStatus { AUTH_STATUS_DEAD, }; -#define QOS_CTRL_BASIC_OPERATION \ - _IOWR(0xCC, 1, struct QosCtrlData) -#define QOS_CTRL_POLICY_OPERATION \ - _IOWR(0xCC, 2, struct QosPolicyDatas) #define BASIC_AUTH_CTRL_OPERATION \ _IOWR(0xCD, 1, struct AuthCtrlData) int AuthEnable(int uid, unsigned int flag, unsigned int status); int AuthPause(int uid); int AuthDelete(int uid); -int QosApplyForThread(int level, int tid); -int QosLeaveForThread(int tid); -int QosPolicy(struct QosPolicyDatas *policyDatas); } // namespace QosCommon } // namespace OHOS diff --git a/qos_manager/src/qos_common.cpp b/qos_manager/src/qos_common.cpp index c648dcc..4d8f616 100644 --- a/qos_manager/src/qos_common.cpp +++ b/qos_manager/src/qos_common.cpp @@ -27,13 +27,6 @@ namespace QosCommon { DEFINE_RMELOG_INTELLISENSE("qos_manager"); -static int TrivalOpenQosCtrlNode(void) -{ - char fileName[] = "/proc/thread-self/sched_qos_ctrl"; - int fd = open(fileName, O_RDWR); - return fd; -} - static int TrivalOpenAuthCtrlNode(void) { char fileName[] = "/dev/auth_ctrl"; @@ -116,72 +109,5 @@ int AuthDelete(int uid) return ret; } -int QosApplyForThread(int level, int tid) -{ - struct QosCtrlData data; - int fd; - - int ret; - - fd = TrivalOpenQosCtrlNode(); - if (fd < 0) { - RME_LOGE("thread %{public}d belong to user %{public}d open qos node failed\n", gettid(), getuid()); - return fd; - } - - data.level = level; - data.type = QOS_APPLY; - data.pid = tid; - - ret = ioctl(fd, QOS_CTRL_BASIC_OPERATION, &data); - if (ret < 0) { - RME_LOGE("qos apply failed for thread %{public}d\n", tid); - } - close(fd); - return ret; -} - -int QosLeaveForThread(int tid) -{ - struct QosCtrlData data; - int fd; - int ret; - - fd = TrivalOpenQosCtrlNode(); - if (fd < 0) { - RME_LOGE("thread %{public}d belong to user %{public}d open qos node failed\n", gettid(), getuid()); - return fd; - } - - data.type = QOS_LEAVE; - data.pid = tid; - - ret = ioctl(fd, QOS_CTRL_BASIC_OPERATION, &data); - if (ret < 0) { - RME_LOGE("qos leave failed for thread %{public}d\n", tid); - } - close(fd); - return ret; -} - -int QosPolicy(struct QosPolicyDatas *policyDatas) -{ - int fd; - int ret; - - fd = TrivalOpenQosCtrlNode(); - if (fd < 0) { - RME_LOGE("thread %{public}d belong to user %{public}d open qos node failed\n", gettid(), getuid()); - return fd; - } - - ret = ioctl(fd, QOS_CTRL_POLICY_OPERATION, policyDatas); - if (ret < 0) { - RME_LOGE("set qos policy failed for thread %{public}d\n", gettid()); - } - close(fd); - return ret; -} - } // namespace QosCommon } // namespace OHOS \ No newline at end of file diff --git a/qos_manager/src/qos_manager.cpp b/qos_manager/src/qos_manager.cpp deleted file mode 100644 index 22ede23..0000000 --- a/qos_manager/src/qos_manager.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * 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. - */ - -#include "qos.h" -#include -#include -#include "qos_common.h" -#include "rme_log_domain.h" - -constexpr int ERROR_NUM = -1; - -namespace OHOS { -namespace QOS { -using namespace QosCommon; -DEFINE_RMELOG_INTELLISENSE("qos_manager"); - -static struct QosPolicyDatas g_defaultPolicy = { - .policyType = QOS_POLICY_DEFAULT, - .policyFlag = QOS_ALL_FLAG, - .policys = { - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - } -}; - -static struct QosPolicyDatas g_systemServerPolicy = { - .policyType = QOS_POLICY_SYSTEM_SERVER, - .policyFlag = QOS_ALL_FLAG, - .policys = { - {0, 0, 0, 1024, 0}, - {10, 0, 0, 1024, 0}, - {5, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - } -}; - -static struct QosPolicyDatas g_foregroundPolicy = { - .policyType = QOS_POLICY_FRONT, - .policyFlag = QOS_ALL_FLAG, - .policys = { - {0, 0, 0, 1024, 0}, - {10, 0, 0, 1024, 0}, - {5, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - } -}; - -static struct QosPolicyDatas g_backgroundPolicy = { - .policyType = QOS_POLICY_BACK, - .policyFlag = QOS_ALL_FLAG & ~QOS_RT_FLAG, - .policys = { - {0, 0, 0, 1024, 0}, - {15, 0, 0, 1024, 0}, - {10, 0, 0, 1024, 0}, - {5, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - {0, 0, 0, 1024, 0}, - } -}; - -QosController& QosController::GetInstance() -{ - static QosController instance; - if (!instance.policyStatus_) { - int ret = instance.SetPolicy(); - if (ret == 0) { - instance.policyStatus_ = true; - RME_LOGI("set qos policy success"); - } - } - return instance; -} - -int QosController::SetPolicy() -{ - int ret; - - ret = QosPolicy(&g_defaultPolicy); - if (ret) { - RME_LOGE("set g_defaultPolicy failed"); - return ret; - } - - ret = QosPolicy(&g_foregroundPolicy); - if (ret) { - RME_LOGE("set g_foregroundPolicy failed"); - return ret; - } - - ret = QosPolicy(&g_backgroundPolicy); - if (ret) { - RME_LOGE("set g_backgroundPolicy failed"); - return ret; - } - - ret = QosPolicy(&g_systemServerPolicy); - if (ret) { - RME_LOGE("set g_systemServerPolicy failed"); - } - return ret; -} - -int QosController::SetThreadQosForOtherThread(enum QosLevel level, int tid) -{ - int qos = static_cast(level); - if (level < QosLevel::qos_background || level > QosLevel::qos_user_interactive) { - RME_LOGE("invalid qos level %{public}d", qos); - return ERROR_NUM; - } - int ret = QosApplyForThread(qos, tid); - if (ret == 0) { - RME_LOGD("qoslevel %{public}d apply for tid %{public}d success", qos, tid); - } else { - RME_LOGE("qoslevel %{public}d apply for tid %{public}d failure", qos, tid); - } - - return ret; -} - -int QosController::ResetThreadQosForOtherThread(int tid) -{ - int ret = QosLeaveForThread(tid); - if (ret == 0) { - RME_LOGD("qoslevel reset for tid %{public}d success", tid); - } else { - RME_LOGE("qoslevel reset for tid %{public}d failure", tid); - } - - return ret; -} - -int SetThreadQos(enum QosLevel level) -{ - int tid = gettid(); - return QosController::GetInstance().SetThreadQosForOtherThread(level, tid); -} - -int SetQosForOtherThread(enum QosLevel level, int tid) -{ - return QosController::GetInstance().SetThreadQosForOtherThread(level, tid); -} - -int ResetThreadQos() -{ - int tid = gettid(); - return QosController::GetInstance().ResetThreadQosForOtherThread(tid); -} - -int ResetQosForOtherThread(int tid) -{ - return QosController::GetInstance().ResetThreadQosForOtherThread(tid); -} - -} // namespace QOS -} // namespace OHOS diff --git a/test/BUILD.gn b/test/BUILD.gn index 2de4d12..eded3f2 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -75,33 +75,12 @@ ohos_unittest("rtg_interface_test") { subsystem_name = "resourceschedule" } -ohos_unittest("qos_manager_test") { - module_out_path = module_output_path - - sources = [ "unittest/phone/qos_manager_test.cpp" ] - - include_dirs = [ - "../interfaces/inner_api", - "../qos_manager/include", - ] - - deps = [ "../qos_manager:qos_manager" ] - - if (is_standard_system) { - public_deps = frame_aware_sched_public_deps - } - - part_name = "frame_aware_sched" - subsystem_name = "resourceschedule" -} - group("frame_unittest") { testonly = true deps = [] if (!is_asan) { deps += [ ":frame_msg_intf_test", - ":qos_manager_test", ":rtg_interface_test", ] } diff --git a/test/unittest/phone/qos_manager_test.cpp b/test/unittest/phone/qos_manager_test.cpp deleted file mode 100644 index b0e7e1b..0000000 --- a/test/unittest/phone/qos_manager_test.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -#include "gtest/gtest.h" -#include "qos.h" -#include -#include - -using namespace testing; -using namespace testing::ext; -using namespace OHOS::QOS; - -class QosManagerTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); -}; - -void QosManagerTest::SetUpTestCase() -{ -} - -void QosManagerTest::TearDownTestCase() -{ -} - -void QosManagerTest::SetUp() -{ -} - -void QosManagerTest::TearDown() -{ -} - -/** - * @tc.name: QosManagerTest - * @tc.desc: Verify the CreateAndDestroy function. - * @tc.type: FUNC - */ -HWTEST_F(QosManagerTest, SetThreadQosTest1, TestSize.Level1) -{ - int ret = SetThreadQos(QosLevel::qos_user_initiated); - EXPECT_EQ(ret, 0); - ret = SetThreadQos(QosLevel::qos_default); - EXPECT_EQ(ret, 0); - ret = SetThreadQos(QosLevel::qos_utility); - EXPECT_EQ(ret, 0); - ret = SetThreadQos(QosLevel::qos_background); - EXPECT_EQ(ret, 0); - ret = SetThreadQos(QosLevel::qos_deadline_request); - EXPECT_EQ(ret, 0); - ret = SetThreadQos(QosLevel::qos_user_interactive); - EXPECT_EQ(ret, 0); -} - -HWTEST_F(QosManagerTest, SetThreadQosTest3, TestSize.Level1) -{ - int ret = SetQosForOtherThread(QosLevel::qos_user_initiated, gettid()); - EXPECT_EQ(ret, 0); - ret = SetQosForOtherThread(QosLevel::qos_default, gettid()); - EXPECT_EQ(ret, 0); - ret = SetQosForOtherThread(QosLevel::qos_utility, gettid()); - EXPECT_EQ(ret, 0); - ret = SetQosForOtherThread(QosLevel::qos_background, gettid()); - EXPECT_EQ(ret, 0); - ret = SetQosForOtherThread(QosLevel::qos_deadline_request, gettid()); - EXPECT_EQ(ret, 0); - ret = SetQosForOtherThread(QosLevel::qos_user_interactive, gettid()); - EXPECT_EQ(ret, 0); -} - -HWTEST_F(QosManagerTest, ResetThreadQosTest1, TestSize.Level1) -{ - int ret = SetThreadQos(QosLevel::qos_user_initiated); - EXPECT_EQ(ret, 0); - ret = ResetThreadQos(); - EXPECT_EQ(ret, 0); -} - -HWTEST_F(QosManagerTest, ResetThreadQosTest2, TestSize.Level1) -{ - int ret = SetQosForOtherThread(QosLevel::qos_user_initiated, gettid()); - EXPECT_EQ(ret, 0); - ret = ResetQosForOtherThread(gettid()); - EXPECT_EQ(ret, 0); -} \ No newline at end of file -- Gitee