From 77b94422d684903b622d454b2f06fad7354354b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sat, 5 Jul 2025 15:15:02 +0800 Subject: [PATCH] add priority MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- bundle.json | 3 ++- interfaces/kits/hyperaio/BUILD.gn | 5 ++++- interfaces/kits/hyperaio/src/hyperaio.cpp | 13 ++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bundle.json b/bundle.json index b0c965533..cedfa33a0 100644 --- a/bundle.json +++ b/bundle.json @@ -52,7 +52,8 @@ "os_account", "runtime_core", "rust_libc", - "samgr" + "samgr", + "qos_manager" ], "third_party": [] }, diff --git a/interfaces/kits/hyperaio/BUILD.gn b/interfaces/kits/hyperaio/BUILD.gn index 93b6f3c96..517e4afc2 100644 --- a/interfaces/kits/hyperaio/BUILD.gn +++ b/interfaces/kits/hyperaio/BUILD.gn @@ -61,7 +61,10 @@ ohos_shared_library("HyperAio") { "hitrace:hitrace_meter", ] if (file_api_feature_hyperaio) { - external_deps += [ "liburing:liburing" ] + external_deps += [ + "liburing:liburing", + "qos_manager:qos" + ] } install_images = [ "system" ] part_name = "file_api" diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index 1f5dc006d..b4679698f 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -23,6 +23,7 @@ #include "ipc_skeleton.h" #ifdef HYPERAIO_USE_LIBURING #include "liburing.h" +#include "qos.h" #endif namespace OHOS { namespace HyperAio { @@ -55,7 +56,7 @@ static bool HasAccessIouringPermission() static bool ValidateReqNum(uint32_t reqNum) { - return reqNum > 0 && reqNum <= URING_QUEUE_SIZE - 1; + return reqNum > 0 && reqNum <= URING_QUEUE_SIZE; } uint32_t HyperAio::SupportIouring() @@ -99,7 +100,10 @@ int32_t HyperAio::CtxInit(ProcessIoResultCallBack *callBack) if (pImpl_ == nullptr) { pImpl_ = std::make_shared(); } - + int32_t ret = OHOS::QOS::SetThreaQos(OHOS::QOS::QosLevel::QOS_USER_INTERACTIVE); + if (ret < 0) { + HILOGE("Harvest SetThreadQos failed ret = %{public}d", ret); + } int32_t ret = io_uring_queue_init(URING_QUEUE_SIZE, &pImpl_->uring_, 0); if (ret < 0) { HILOGE("init io_uring failed, ret = %{public}d", ret); @@ -259,7 +263,10 @@ void HyperAio::HarvestRes() HILOGI("pImpl is null"); return; } - + int32_t ret = OHOS::QOS::SetThreaQos(OHOS::QOS::QosLevel::QOS_USER_INTERACTIVE); + if (ret < 0) { + HILOGE("Harvest SetThreadQos failed ret = %{public}d", ret); + } while (!stopThread_.load()) { struct io_uring_cqe *cqe; int32_t ret = io_uring_wait_cqe(&pImpl_->uring_, &cqe); -- Gitee