已合并
[PROFILING]adapt drv flush buff #369
wangzixuan创建于 2月5日
[PROFILING]adapt drv flush buff #369
已合并
wangzixuan创建于 2月5日
9 个文件变更+47-34
@@ -950,26 +950,20 @@ int32_t DrvProfFlush(uint32_t deviceId, uint32_t channelId, uint32_t &bufSize)
950#if (defined(linux) || defined(__linux__))950#if (defined(linux) || defined(__linux__))
951 MSPROF_LOGI("Begin to flush drv buff. deviceId=%u, channelId=%u", deviceId, channelId);951 MSPROF_LOGI("Begin to flush drv buff. deviceId=%u, channelId=%u", deviceId, channelId);
952 int32_t ret = halProfDataFlush(deviceId, channelId, &bufSize);952 int32_t ret = halProfDataFlush(deviceId, channelId, &bufSize);
953- if (ret == PROF_OK) {953+ // The ret value should be consistent with the interface return of halProfDataFlush.
954+ if (ret == DRV_ERROR_NONE) {
954 MSPROF_LOGI("End to flush drv buff. deviceId=%u, channelId=%u, bufSize=%ubytes", deviceId, channelId, bufSize);955 MSPROF_LOGI("End to flush drv buff. deviceId=%u, channelId=%u, bufSize=%ubytes", deviceId, channelId, bufSize);
955 return PROFILING_SUCCESS;956 return PROFILING_SUCCESS;
956- }957+ } else if (ret != DRV_ERROR_NOT_SUPPORT) {
957- if (ret == PROF_STOPPED_ALREADY) {
958- MSPROF_LOGE("Failed to halProfDataFlush, channel already closed.deviceId=%u, channelId=%u", deviceId,
959- channelId);
960- MSPROF_CALL_ERROR("EK9999", "Failed to halProfDataFlush, channel already closed.deviceId=%u, channelId=%u",
961- deviceId, channelId);
962- return PROFILING_FAILED;
963- } else {
964 MSPROF_LOGE("Failed to halProfDataFlush.deviceId=%u, channelId=%u, ret=%d", deviceId, channelId, ret);958 MSPROF_LOGE("Failed to halProfDataFlush.deviceId=%u, channelId=%u, ret=%d", deviceId, channelId, ret);
965 MSPROF_CALL_ERROR("EK9999", "Failed to halProfDataFlush.deviceId=%u, channelId=%u, ret=%d", deviceId, channelId,959 MSPROF_CALL_ERROR("EK9999", "Failed to halProfDataFlush.deviceId=%u, channelId=%u, ret=%d", deviceId, channelId,
966 ret);960 ret);
967 return PROFILING_FAILED;961 return PROFILING_FAILED;
968 }962 }
969-#else
970- MSPROF_LOGW("Function halProfDataFlush not supported, deviceId=%u, channelId=%u", deviceId, channelId);
971- return PROFILING_FAILED;
972#endif963#endif
964+ // If ret is DRV_ERROR_NOT_SUPPORT, should record warning logs, return success
965+ MSPROF_LOGW("Function halProfDataFlush not supported, deviceId=%u, channelId=%u", deviceId, channelId);
966+ return PROFILING_SUCCESS;
973}967}
974} // namespace driver968} // namespace driver
975} // namespace dvvp969} // namespace dvvp
Msrc/dfx/msprof/collector/dvvp/msprof/engine/src/prof_acl_mgr.cpp+2-0文件内容审核中,请稍后刷新重试
@@ -11,6 +11,7 @@
11#include <functional>11#include <functional>
12#include <new>12#include <new>
13#include <string>13#include <string>
14+#include <set>
14#include "config/config.h"15#include "config/config.h"
15#include "errno/error_code.h"16#include "errno/error_code.h"
16#include "msprof_dlog.h"17#include "msprof_dlog.h"
@@ -32,6 +33,14 @@ using namespace analysis::dvvp::common::config;
32using namespace Analysis::Dvvp::MsprofErrMgr;33using namespace Analysis::Dvvp::MsprofErrMgr;
33using namespace Msprofiler::Parser;34using namespace Msprofiler::Parser;
34 35 
36+namespace {
37+const std::set<AI_DRV_CHANNEL> SUPPORT_FLUSH_CHANNEL_SET = {
38+ PROF_CHANNEL_AI_CORE, PROF_CHANNEL_HWTS_LOG, PROF_CHANNEL_TS_FW, PROF_CHANNEL_L2_CACHE,
39+ PROF_CHANNEL_STARS_SOC_LOG, PROF_CHANNEL_FFTS_PROFILE_TASK, PROF_CHANNEL_NPU_APP_MEM, PROF_CHANNEL_NPU_MEM,
40+ PROF_CHANNEL_AISTACK_MEM, PROF_CHANNEL_AICPU, PROF_CHANNEL_CUS_AICPU, PROF_CHANNEL_ADPROF
41+};
42+}
43+ 
35ChannelReader::ChannelReader(int32_t deviceId, analysis::dvvp::driver::AI_DRV_CHANNEL channelId,44ChannelReader::ChannelReader(int32_t deviceId, analysis::dvvp::driver::AI_DRV_CHANNEL channelId,
36 const std::string &relativeFileName,45 const std::string &relativeFileName,
37 SHARED_PTR_ALIA<analysis::dvvp::message::JobContext> jobCtx)46 SHARED_PTR_ALIA<analysis::dvvp::message::JobContext> jobCtx)
@@ -223,9 +232,14 @@ void ChannelReader::FlushBuffToUpload()
223 UploadData();232 UploadData();
224}233}
225 234 
235+bool ChannelReader::IsSupportFlushDrvBuff()
236+{
237+ return SUPPORT_FLUSH_CHANNEL_SET.find(channelId_) != SUPPORT_FLUSH_CHANNEL_SET.end();
238+}
239+ 
226void ChannelReader::FlushDrvBuff()240void ChannelReader::FlushDrvBuff()
227{241{
228- if ((channelId_ != PROF_CHANNEL_HWTS_LOG) && (channelId_ != PROF_CHANNEL_TS_FW)) {242+ if (!IsSupportFlushDrvBuff()) {
229 return;243 return;
230 }244 }
231 // 1. query flush size245 // 1. query flush size
@@ -255,7 +269,7 @@ void ChannelReader::FlushDrvBuff()
255 269 
256void ChannelReader::CheckIfSendFlush(const size_t curLen)270void ChannelReader::CheckIfSendFlush(const size_t curLen)
257{271{
258- if ((channelId_ != PROF_CHANNEL_HWTS_LOG) && (channelId_ != PROF_CHANNEL_TS_FW)) {272+ if (!IsSupportFlushDrvBuff()) {
259 return;273 return;
260 }274 }
261 if (needWait_) {275 if (needWait_) {
Msrc/dfx/msprof/collector/dvvp/transport/prof_channel.h+3-0文件内容审核中,请稍后刷新重试
@@ -476,11 +476,11 @@ TEST_F(DRIVER_AI_DRV_API_TEST, DrvProfFlush) {
476 476 
477 MOCKER(halProfDataFlush)477 MOCKER(halProfDataFlush)
478 .stubs()478 .stubs()
479- .will(returnValue(PROF_ERROR))479+ .will(returnValue(DRV_ERROR_NONE))
480- .then(returnValue(PROF_STOPPED_ALREADY))480+ .then(returnValue(DRV_ERROR_NO_DEVICE))
481- .then(returnValue(PROF_OK));481+ .then(returnValue(DRV_ERROR_NOT_SUPPORT));
482 unsigned int bufSize = 0;482 unsigned int bufSize = 0;
483- EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(483+ EXPECT_EQ(PROFILING_SUCCESS, analysis::dvvp::driver::DrvProfFlush(
484 0, 0, bufSize));484 0, 0, bufSize));
485 485 
486 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(486 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(
@@ -316,11 +316,11 @@ TEST_F(DRV_DEV_API_STEST, DrvProfFlush) {
316 316 
317 MOCKER(halProfDataFlush)317 MOCKER(halProfDataFlush)
318 .stubs()318 .stubs()
319- .will(returnValue(PROF_ERROR))319+ .will(returnValue(DRV_ERROR_NONE))
320- .then(returnValue(PROF_STOPPED_ALREADY))320+ .then(returnValue(DRV_ERROR_NO_DEVICE))
321- .then(returnValue(PROF_OK));321+ .then(returnValue(DRV_ERROR_NOT_SUPPORT));
322 unsigned int bufSize = 0;322 unsigned int bufSize = 0;
323- EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(323+ EXPECT_EQ(PROFILING_SUCCESS, analysis::dvvp::driver::DrvProfFlush(
324 0, 0, bufSize));324 0, 0, bufSize));
325 325 
326 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(326 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(
@@ -316,11 +316,11 @@ TEST_F(DRV_DEV_API_OPEN_STEST, DrvProfFlush) {
316 316 
317 MOCKER(halProfDataFlush)317 MOCKER(halProfDataFlush)
318 .stubs()318 .stubs()
319- .will(returnValue(PROF_ERROR))319+ .will(returnValue(DRV_ERROR_NONE))
320- .then(returnValue(PROF_STOPPED_ALREADY))320+ .then(returnValue(DRV_ERROR_NO_DEVICE))
321- .then(returnValue(PROF_OK));321+ .then(returnValue(DRV_ERROR_NOT_SUPPORT));
322 unsigned int bufSize = 0;322 unsigned int bufSize = 0;
323- EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(323+ EXPECT_EQ(PROFILING_SUCCESS, analysis::dvvp::driver::DrvProfFlush(
324 0, 0, bufSize));324 0, 0, bufSize));
325 325 
326 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(326 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(
@@ -476,11 +476,11 @@ TEST_F(DRIVER_AI_DRV_API_TEST, DrvProfFlush) {
476 476 
477 MOCKER(halProfDataFlush)477 MOCKER(halProfDataFlush)
478 .stubs()478 .stubs()
479- .will(returnValue(PROF_ERROR))479+ .will(returnValue(DRV_ERROR_NONE))
480- .then(returnValue(PROF_STOPPED_ALREADY))480+ .then(returnValue(DRV_ERROR_NO_DEVICE))
481- .then(returnValue(PROF_OK));481+ .then(returnValue(DRV_ERROR_NOT_SUPPORT));
482 unsigned int bufSize = 0;482 unsigned int bufSize = 0;
483- EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(483+ EXPECT_EQ(PROFILING_SUCCESS, analysis::dvvp::driver::DrvProfFlush(
484 0, 0, bufSize));484 0, 0, bufSize));
485 485 
486 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(486 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(
@@ -476,11 +476,11 @@ TEST_F(DRIVER_AI_DRV_API_OPEN_TEST, DrvProfFlush) {
476 476 
477 MOCKER(halProfDataFlush)477 MOCKER(halProfDataFlush)
478 .stubs()478 .stubs()
479- .will(returnValue(PROF_ERROR))479+ .will(returnValue(DRV_ERROR_NONE))
480- .then(returnValue(PROF_STOPPED_ALREADY))480+ .then(returnValue(DRV_ERROR_NO_DEVICE))
481- .then(returnValue(PROF_OK));481+ .then(returnValue(DRV_ERROR_NOT_SUPPORT));
482 unsigned int bufSize = 0;482 unsigned int bufSize = 0;
483- EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(483+ EXPECT_EQ(PROFILING_SUCCESS, analysis::dvvp::driver::DrvProfFlush(
484 0, 0, bufSize));484 0, 0, bufSize));
485 485 
486 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(486 EXPECT_EQ(PROFILING_FAILED, analysis::dvvp::driver::DrvProfFlush(