remove qos_manager component

Signed-off-by: edwardcaoyue <caoyue24@huawei.com>
Change-Id: I772754d5eb57f33ccab112161ee2e9696fbd84b8
This commit is contained in:
edwardcaoyue
2023-10-18 15:22:09 +08:00
parent dbe2f4b57b
commit 38e1bfc8d9
8 changed files with 1 additions and 529 deletions
+1 -11
View File
@@ -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",
-58
View File
@@ -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
-36
View File
@@ -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"
}
-50
View File
@@ -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
-74
View File
@@ -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
-179
View File
@@ -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 <cstdlib>
#include <unistd.h>
#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<int>(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
-21
View File
@@ -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",
]
}
-100
View File
@@ -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 <cstdio>
#include <unistd.h>
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);
}