未验证 提交 d376efbe 编写于 作者: O openharmony_ci 提交者: Gitee

!815 feat: 优化shell 命令

Merge pull request !815 from zhushengle/shell
...@@ -55,8 +55,8 @@ extern "C" { ...@@ -55,8 +55,8 @@ extern "C" {
#define HWI_IS_REGISTED(num) ((&g_hwiForm[num])->pstNext != NULL) #define HWI_IS_REGISTED(num) ((&g_hwiForm[num])->pstNext != NULL)
#endif #endif
extern VOID OsHwiInit(VOID); extern VOID OsHwiInit(VOID);
extern VOID OsIncHwiFormCnt(UINT32 index); extern VOID OsIncHwiFormCnt(UINT16 cpuId, UINT32 index);
extern UINT32 OsGetHwiFormCnt(UINT32 index); extern UINT32 OsGetHwiFormCnt(UINT16 cpuId, UINT32 index);
extern CHAR *OsGetHwiFormName(UINT32 index); extern CHAR *OsGetHwiFormName(UINT32 index);
extern VOID OsInterrupt(UINT32 intNum); extern VOID OsInterrupt(UINT32 intNum);
extern VOID OsSyscallHandleInit(VOID); extern VOID OsSyscallHandleInit(VOID);
......
...@@ -46,16 +46,11 @@ LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_hwiSpin); ...@@ -46,16 +46,11 @@ LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_hwiSpin);
size_t g_intCount[LOSCFG_KERNEL_CORE_NUM] = {0}; size_t g_intCount[LOSCFG_KERNEL_CORE_NUM] = {0};
HwiHandleForm g_hwiForm[OS_HWI_MAX_NUM]; HwiHandleForm g_hwiForm[OS_HWI_MAX_NUM];
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0}; STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0}; STATIC UINT32 g_hwiFormCnt[LOSCFG_KERNEL_CORE_NUM][OS_HWI_MAX_NUM] = {0};
VOID OsIncHwiFormCnt(UINT32 index) UINT32 OsGetHwiFormCnt(UINT16 cpuId, UINT32 index)
{ {
g_hwiFormCnt[index]++; return g_hwiFormCnt[cpuId][index];
}
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
} }
CHAR *OsGetHwiFormName(UINT32 index) CHAR *OsGetHwiFormName(UINT32 index)
...@@ -74,16 +69,17 @@ VOID OsInterrupt(UINT32 intNum) ...@@ -74,16 +69,17 @@ VOID OsInterrupt(UINT32 intNum)
{ {
HwiHandleForm *hwiForm = NULL; HwiHandleForm *hwiForm = NULL;
UINT32 *intCnt = NULL; UINT32 *intCnt = NULL;
UINT16 cpuId = ArchCurrCpuid();
/* Must keep the operation at the beginning of the interface */ /* Must keep the operation at the beginning of the interface */
intCnt = &g_intCount[ArchCurrCpuid()]; intCnt = &g_intCount[cpuId];
*intCnt = *intCnt + 1; *intCnt = *intCnt + 1;
OsSchedIrqStartTime();
#ifdef LOSCFG_CPUP_INCLUDE_IRQ #ifdef LOSCFG_CPUP_INCLUDE_IRQ
OsCpupIrqStart(); OsCpupIrqStart(cpuId);
#endif #endif
OsSchedIrqStartTime();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, intNum); OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, intNum);
hwiForm = (&g_hwiForm[intNum]); hwiForm = (&g_hwiForm[intNum]);
#ifndef LOSCFG_NO_SHARED_IRQ #ifndef LOSCFG_NO_SHARED_IRQ
...@@ -105,14 +101,14 @@ VOID OsInterrupt(UINT32 intNum) ...@@ -105,14 +101,14 @@ VOID OsInterrupt(UINT32 intNum)
#ifndef LOSCFG_NO_SHARED_IRQ #ifndef LOSCFG_NO_SHARED_IRQ
} }
#endif #endif
++g_hwiFormCnt[intNum]; ++g_hwiFormCnt[cpuId][intNum];
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, intNum); OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, intNum);
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
OsCpupIrqEnd(intNum);
#endif
OsSchedIrqUpdateUsedTime(); OsSchedIrqUpdateUsedTime();
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
OsCpupIrqEnd(cpuId, intNum);
#endif
/* Must keep the operation at the end of the interface */ /* Must keep the operation at the end of the interface */
*intCnt = *intCnt - 1; *intCnt = *intCnt - 1;
} }
......
...@@ -52,6 +52,132 @@ LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_swtmrSpin); ...@@ -52,6 +52,132 @@ LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_swtmrSpin);
#define SWTMR_LOCK(state) LOS_SpinLockSave(&g_swtmrSpin, &(state)) #define SWTMR_LOCK(state) LOS_SpinLockSave(&g_swtmrSpin, &(state))
#define SWTMR_UNLOCK(state) LOS_SpinUnlockRestore(&g_swtmrSpin, (state)) #define SWTMR_UNLOCK(state) LOS_SpinUnlockRestore(&g_swtmrSpin, (state))
#ifdef LOSCFG_SWTMR_DEBUG
#define OS_SWTMR_PERIOD_TO_CYCLE(period) (((UINT64)(period) * OS_NS_PER_TICK) / OS_NS_PER_CYCLE)
STATIC SwtmrDebugData *g_swtmrDebugData = NULL;
BOOL OsSwtmrDebugDataUsed(UINT32 swtmrID)
{
if (swtmrID > LOSCFG_BASE_CORE_SWTMR_LIMIT) {
return FALSE;
}
return g_swtmrDebugData[swtmrID].swtmrUsed;
}
UINT32 OsSwtmrDebugDataGet(UINT32 swtmrID, SwtmrDebugData *data, UINT32 len, UINT8 *mode)
{
UINT32 intSave;
errno_t ret;
if ((swtmrID > LOSCFG_BASE_CORE_SWTMR_LIMIT) || (data == NULL) ||
(mode == NULL) || (len < sizeof(SwtmrDebugData))) {
return LOS_NOK;
}
SWTMR_CTRL_S *swtmr = &g_swtmrCBArray[swtmrID];
SWTMR_LOCK(intSave);
ret = memcpy_s(data, len, &g_swtmrDebugData[swtmrID], sizeof(SwtmrDebugData));
*mode = swtmr->ucMode;
SWTMR_UNLOCK(intSave);
if (ret != EOK) {
return LOS_NOK;
}
return LOS_OK;
}
#endif
STATIC VOID SwtmrDebugDataInit(VOID)
{
#ifdef LOSCFG_SWTMR_DEBUG
UINT32 size = sizeof(SwtmrDebugData) * LOSCFG_BASE_CORE_SWTMR_LIMIT;
g_swtmrDebugData = (SwtmrDebugData *)LOS_MemAlloc(m_aucSysMem1, size);
if (g_swtmrDebugData == NULL) {
PRINT_ERR("SwtmrDebugDataInit malloc failed!\n");
return;
}
(VOID)memset_s(g_swtmrDebugData, size, 0, size);
#endif
}
STATIC INLINE VOID SwtmrDebugDataUpdate(SWTMR_CTRL_S *swtmr, UINT32 ticks)
{
#ifdef LOSCFG_SWTMR_DEBUG
SwtmrDebugData *data = &g_swtmrDebugData[swtmr->usTimerID];
data->startTime = swtmr->startTime;
if (data->period != ticks) {
data->waitCount = 0;
data->runCount = 0;
data->waitTime = 0;
data->waitTimeMax = 0;
data->runTime = 0;
data->runTimeMax = 0;
data->readyTime = 0;
data->readyTimeMax = 0;
data->period = ticks;
}
#endif
}
STATIC INLINE VOID SwtmrDebugDataStart(SWTMR_CTRL_S *swtmr, UINT16 cpuId)
{
#ifdef LOSCFG_SWTMR_DEBUG
SwtmrDebugData *data = &g_swtmrDebugData[swtmr->usTimerID];
data->swtmrUsed = TRUE;
data->handler = swtmr->pfnHandler;
data->cpuId = cpuId;
#endif
}
STATIC INLINE VOID SwtmrDebugWaitTimeCalculate(UINT32 timerId, SwtmrHandlerItemPtr swtmrHandler)
{
#ifdef LOSCFG_SWTMR_DEBUG
SwtmrDebugData *data = &g_swtmrDebugData[timerId];
swtmrHandler->swtmrId = timerId;
UINT64 currTime = OsGetCurrSchedTimeCycle();
UINT64 waitTime = currTime - data->startTime;
data->waitTime += waitTime;
if (waitTime > data->waitTimeMax) {
data->waitTimeMax = waitTime;
}
data->readyStartTime = currTime;
LOS_ASSERT(waitTime >= OS_SWTMR_PERIOD_TO_CYCLE(data->period));
data->waitCount++;
#endif
}
STATIC INLINE VOID SwtmrDebugDataClear(UINT32 timerId)
{
#ifdef LOSCFG_SWTMR_DEBUG
(VOID)memset_s(&g_swtmrDebugData[timerId], sizeof(SwtmrDebugData), 0, sizeof(SwtmrDebugData));
#endif
}
STATIC INLINE VOID SwtmrHandler(SwtmrHandlerItemPtr swtmrHandle)
{
#ifdef LOSCFG_SWTMR_DEBUG
UINT32 intSave;
SwtmrDebugData *data = &g_swtmrDebugData[swtmrHandle->swtmrId];
UINT64 startTime = OsGetCurrSchedTimeCycle();
#endif
swtmrHandle->handler(swtmrHandle->arg);
#ifdef LOSCFG_SWTMR_DEBUG
UINT64 runTime = OsGetCurrSchedTimeCycle() - startTime;
SWTMR_LOCK(intSave);
data->runTime += runTime;
if (runTime > data->runTimeMax) {
data->runTimeMax = runTime;
}
runTime = startTime - data->readyStartTime;
data->readyTime += runTime;
if (runTime > data->readyTimeMax) {
data->readyTimeMax = runTime;
}
data->runCount++;
SWTMR_UNLOCK(intSave);
#endif
}
STATIC VOID SwtmrTask(VOID) STATIC VOID SwtmrTask(VOID)
{ {
SwtmrHandlerItemPtr swtmrHandlePtr = NULL; SwtmrHandlerItemPtr swtmrHandlePtr = NULL;
...@@ -62,12 +188,9 @@ STATIC VOID SwtmrTask(VOID) ...@@ -62,12 +188,9 @@ STATIC VOID SwtmrTask(VOID)
for (;;) { for (;;) {
ret = LOS_QueueRead(swtmrHandlerQueue, &swtmrHandlePtr, sizeof(CHAR *), LOS_WAIT_FOREVER); ret = LOS_QueueRead(swtmrHandlerQueue, &swtmrHandlePtr, sizeof(CHAR *), LOS_WAIT_FOREVER);
if ((ret == LOS_OK) && (swtmrHandlePtr != NULL)) { if ((ret == LOS_OK) && (swtmrHandlePtr != NULL)) {
swtmrHandle.handler = swtmrHandlePtr->handler; (VOID)memcpy_s(&swtmrHandle, sizeof(SwtmrHandlerItem), swtmrHandlePtr, sizeof(SwtmrHandlerItem));
swtmrHandle.arg = swtmrHandlePtr->arg;
(VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandlePtr); (VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandlePtr);
if (swtmrHandle.handler != NULL) { SwtmrHandler(&swtmrHandle);
swtmrHandle.handler(swtmrHandle.arg);
}
} }
} }
} }
...@@ -150,6 +273,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID) ...@@ -150,6 +273,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
ret = LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM; ret = LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM;
goto ERROR; goto ERROR;
} }
SwtmrDebugDataInit();
} }
ret = LOS_QueueCreate(NULL, OS_SWTMR_HANDLE_QUEUE_SIZE, &swtmrHandlerQueue, 0, sizeof(CHAR *)); ret = LOS_QueueCreate(NULL, OS_SWTMR_HANDLE_QUEUE_SIZE, &swtmrHandlerQueue, 0, sizeof(CHAR *));
...@@ -190,6 +315,7 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStart(SWTMR_CTRL_S *swtmr) ...@@ -190,6 +315,7 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStart(SWTMR_CTRL_S *swtmr)
swtmr->ucState = OS_SWTMR_STATUS_TICKING; swtmr->ucState = OS_SWTMR_STATUS_TICKING;
OsSchedAddSwtmr2TimeList(&swtmr->stSortList, swtmr->startTime, ticks); OsSchedAddSwtmr2TimeList(&swtmr->stSortList, swtmr->startTime, ticks);
SwtmrDebugDataUpdate(swtmr, ticks);
OsSchedUpdateExpireTime(); OsSchedUpdateExpireTime();
return; return;
} }
...@@ -204,6 +330,8 @@ STATIC INLINE VOID OsSwtmrDelete(SWTMR_CTRL_S *swtmr) ...@@ -204,6 +330,8 @@ STATIC INLINE VOID OsSwtmrDelete(SWTMR_CTRL_S *swtmr)
LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode); LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);
swtmr->ucState = OS_SWTMR_STATUS_UNUSED; swtmr->ucState = OS_SWTMR_STATUS_UNUSED;
swtmr->uwOwnerPid = 0; swtmr->uwOwnerPid = 0;
SwtmrDebugDataClear(swtmr->usTimerID);
} }
VOID OsSwtmrWake(SchedRunQue *rq, UINT64 startTime, SortLinkList *sortList) VOID OsSwtmrWake(SchedRunQue *rq, UINT64 startTime, SortLinkList *sortList)
...@@ -216,6 +344,7 @@ VOID OsSwtmrWake(SchedRunQue *rq, UINT64 startTime, SortLinkList *sortList) ...@@ -216,6 +344,7 @@ VOID OsSwtmrWake(SchedRunQue *rq, UINT64 startTime, SortLinkList *sortList)
if (swtmrHandler != NULL) { if (swtmrHandler != NULL) {
swtmrHandler->handler = swtmr->pfnHandler; swtmrHandler->handler = swtmr->pfnHandler;
swtmrHandler->arg = swtmr->uwArg; swtmrHandler->arg = swtmr->uwArg;
SwtmrDebugWaitTimeCalculate(swtmr->usTimerID, swtmrHandler);
if (LOS_QueueWrite(rq->swtmrHandlerQueue, swtmrHandler, sizeof(CHAR *), LOS_NO_WAIT)) { if (LOS_QueueWrite(rq->swtmrHandlerQueue, swtmrHandler, sizeof(CHAR *), LOS_NO_WAIT)) {
(VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandler); (VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandler);
...@@ -389,6 +518,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrID) ...@@ -389,6 +518,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrID)
/* fall-through */ /* fall-through */
case OS_SWTMR_STATUS_CREATED: case OS_SWTMR_STATUS_CREATED:
swtmr->startTime = OsGetCurrSchedTimeCycle(); swtmr->startTime = OsGetCurrSchedTimeCycle();
SwtmrDebugDataStart(swtmr, ArchCurrCpuid());
OsSwtmrStart(swtmr); OsSwtmrStart(swtmr);
break; break;
default: default:
......
...@@ -66,6 +66,9 @@ typedef struct { ...@@ -66,6 +66,9 @@ typedef struct {
SWTMR_PROC_FUNC handler; /**< Callback function that handles software timer timeout */ SWTMR_PROC_FUNC handler; /**< Callback function that handles software timer timeout */
UINTPTR arg; /**< Parameter passed in when the callback function UINTPTR arg; /**< Parameter passed in when the callback function
that handles software timer timeout is called */ that handles software timer timeout is called */
#ifdef LOSCFG_SWTMR_DEBUG
UINT32 swtmrId;
#endif
} SwtmrHandlerItem; } SwtmrHandlerItem;
/** /**
...@@ -107,6 +110,29 @@ extern UINT32 OsSwtmrInit(VOID); ...@@ -107,6 +110,29 @@ extern UINT32 OsSwtmrInit(VOID);
extern VOID OsSwtmrRecycle(UINT32 processID); extern VOID OsSwtmrRecycle(UINT32 processID);
extern BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg); extern BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg);
extern SPIN_LOCK_S g_swtmrSpin; extern SPIN_LOCK_S g_swtmrSpin;
#ifdef LOSCFG_SWTMR_DEBUG
typedef struct {
UINT64 startTime;
UINT64 waitTimeMax;
UINT64 waitTime;
UINT64 waitCount;
UINT64 readyStartTime;
UINT64 readyTime;
UINT64 readyTimeMax;
UINT64 runTime;
UINT64 runTimeMax;
UINT64 runCount;
SWTMR_PROC_FUNC handler;
UINT32 period;
UINT32 cpuId;
BOOL swtmrUsed;
} SwtmrDebugData;
extern BOOL OsSwtmrDebugDataUsed(UINT32 swtmrID);
extern UINT32 OsSwtmrDebugDataGet(UINT32 swtmrID, SwtmrDebugData *data, UINT32 len, UINT8 *mode);
#endif
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }
......
...@@ -59,9 +59,9 @@ extern "C" { ...@@ -59,9 +59,9 @@ extern "C" {
const CHAR *OsGetRegionNameOrFilePath(LosVmMapRegion *region); const CHAR *OsGetRegionNameOrFilePath(LosVmMapRegion *region);
INT32 OsRegionOverlapCheckUnlock(LosVmSpace *space, LosVmMapRegion *region); INT32 OsRegionOverlapCheckUnlock(LosVmSpace *space, LosVmMapRegion *region);
UINT32 OsShellCmdProcessVmUsage(LosVmSpace *space); UINT32 OsShellCmdProcessVmUsage(LosVmSpace *space);
VOID OsShellCmdProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm); UINT32 OsShellCmdProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
VOID OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm); UINT32 OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
VOID OsKProcessPmUsage(LosVmSpace *kAspace, UINT32 *actualPm); UINT32 OsKProcessPmUsage(LosVmSpace *kAspace, UINT32 *actualPm);
VOID OsDumpAspace(LosVmSpace *space); VOID OsDumpAspace(LosVmSpace *space);
UINT32 OsCountRegionPages(LosVmSpace *space, LosVmMapRegion *region, UINT32 *pssPages); UINT32 OsCountRegionPages(LosVmSpace *space, LosVmMapRegion *region, UINT32 *pssPages);
UINT32 OsCountAspacePages(LosVmSpace *space); UINT32 OsCountAspacePages(LosVmSpace *space);
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "shcmd.h" #include "shcmd.h"
#include "shell.h" #include "shell.h"
#define OS_ALL_SWTMR_MASK 0xffffffff
#define SWTMR_STRLEN 12 #define SWTMR_STRLEN 12
LITE_OS_SEC_DATA_MINOR STATIC CHAR g_shellSwtmrMode[][SWTMR_STRLEN] = { LITE_OS_SEC_DATA_MINOR STATIC CHAR g_shellSwtmrMode[][SWTMR_STRLEN] = {
...@@ -57,13 +57,7 @@ STATIC VOID OsPrintSwtmrMsg(const SWTMR_CTRL_S *swtmr) ...@@ -57,13 +57,7 @@ STATIC VOID OsPrintSwtmrMsg(const SWTMR_CTRL_S *swtmr)
UINT32 ticks = 0; UINT32 ticks = 0;
(VOID)LOS_SwtmrTimeGet(swtmr->usTimerID, &ticks); (VOID)LOS_SwtmrTimeGet(swtmr->usTimerID, &ticks);
PRINTK("0x%08x " PRINTK("%7u%10s%8s%12u%7u%#12x%#12x\n",
"%-7s "
"%-6s "
"%-6u "
"%-6u "
"0x%08x "
"%p\n",
swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT, swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT,
g_shellSwtmrStatus[swtmr->ucState], g_shellSwtmrStatus[swtmr->ucState],
g_shellSwtmrMode[swtmr->ucMode], g_shellSwtmrMode[swtmr->ucMode],
...@@ -75,34 +69,15 @@ STATIC VOID OsPrintSwtmrMsg(const SWTMR_CTRL_S *swtmr) ...@@ -75,34 +69,15 @@ STATIC VOID OsPrintSwtmrMsg(const SWTMR_CTRL_S *swtmr)
STATIC INLINE VOID OsPrintSwtmrMsgHead(VOID) STATIC INLINE VOID OsPrintSwtmrMsgHead(VOID)
{ {
PRINTK("\r\nSwTmrID State Mode Interval Count Arg handlerAddr\n"); PRINTK("\r\nSwTmrID State Mode Interval Count Arg handlerAddr\n");
PRINTK("---------- ------- ------- --------- ------- ---------- --------\n");
} }
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSwtmrInfoGet(INT32 argc, const UINT8 **argv) STATIC UINT32 SwtmrBaseInfoGet(UINT32 timerID)
{ {
#define OS_ALL_SWTMR_MASK 0xffffffff
SWTMR_CTRL_S *swtmr = g_swtmrCBArray; SWTMR_CTRL_S *swtmr = g_swtmrCBArray;
SWTMR_CTRL_S *swtmr1 = g_swtmrCBArray; SWTMR_CTRL_S *swtmr1 = g_swtmrCBArray;
UINT16 index; UINT16 index;
size_t timerID;
UINT16 num = 0; UINT16 num = 0;
CHAR *endPtr = NULL;
if (argc > 1) {
PRINTK("\nUsage: swtmr [ID]\n");
return OS_ERROR;
}
if (argc == 0) {
timerID = OS_ALL_SWTMR_MASK;
} else {
timerID = strtoul((CHAR *)argv[0], &endPtr, 0);
if ((endPtr == NULL) || (*endPtr != 0) || (timerID > LOSCFG_BASE_CORE_SWTMR_LIMIT)) {
PRINTK("\nswtmr ID can't access %s.\n", argv[0]);
return OS_ERROR;
}
}
for (index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr1++) { for (index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr1++) {
if (swtmr1->ucState == 0) { if (swtmr1->ucState == 0) {
...@@ -112,13 +87,13 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSwtmrInfoGet(INT32 argc, const UINT8 **a ...@@ -112,13 +87,13 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSwtmrInfoGet(INT32 argc, const UINT8 **a
if (num == LOSCFG_BASE_CORE_SWTMR_LIMIT) { if (num == LOSCFG_BASE_CORE_SWTMR_LIMIT) {
PRINTK("\r\nThere is no swtmr was created!\n"); PRINTK("\r\nThere is no swtmr was created!\n");
return OS_ERROR; return LOS_NOK;
} }
if (timerID == OS_ALL_SWTMR_MASK) { if (timerID == OS_ALL_SWTMR_MASK) {
OsPrintSwtmrMsgHead();
for (index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr++) { for (index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr++) {
if (swtmr->ucState != 0) { if (swtmr->ucState != 0) {
OsPrintSwtmrMsgHead();
OsPrintSwtmrMsg(swtmr); OsPrintSwtmrMsg(swtmr);
} }
} }
...@@ -135,6 +110,69 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSwtmrInfoGet(INT32 argc, const UINT8 **a ...@@ -135,6 +110,69 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSwtmrInfoGet(INT32 argc, const UINT8 **a
return LOS_OK; return LOS_OK;
} }
#ifdef LOSCFG_SWTMR_DEBUG
STATIC VOID OsSwtmrTimeInfoShow(VOID)
{
UINT8 mode;
SwtmrDebugData data;
PRINTK("SwtmrID CpuId Mode Period(us) WaitTime(us) WaitMax(us) RTime(us) RTimeMax(us) ReTime(us)"
" ReTimeMax(us) RunCount Handler\n");
for (UINT32 index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++) {
if (!OsSwtmrDebugDataUsed(index)) {
continue;
}
UINT32 ret = OsSwtmrDebugDataGet(index, &data, sizeof(SwtmrDebugData), &mode);
if (ret != LOS_OK) {
break;
}
UINT64 waitTime = ((data.waitTime / data.waitCount) * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US;
UINT64 waitTimeMax = (data.waitTimeMax * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US;
UINT64 runTime = ((data.runTime / data.runCount) * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US;
UINT64 runTimeMax = (data.runTimeMax * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US;
UINT64 readyTime = ((data.readyTime / data.runCount) * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US;
UINT64 readyTimeMax = (data.readyTimeMax * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US;
PRINTK("%4u%10u%7s%14u%13llu%12llu%10llu%13llu%10llu%14llu%15llu%#12x\n",
index, data.cpuId, g_shellSwtmrMode[mode], data.period * OS_US_PER_TICK, waitTime, waitTimeMax,
runTime, runTimeMax, readyTime, readyTimeMax, data.runCount, data.handler);
}
}
#endif
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSwtmrInfoGet(INT32 argc, const CHAR **argv)
{
UINT32 timerID;
CHAR *endPtr = NULL;
if (argc > 1) {
goto SWTMR_HELP;
}
if (argc == 0) {
timerID = OS_ALL_SWTMR_MASK;
#ifdef LOSCFG_SWTMR_DEBUG
} else if (strcmp("-t", argv[0]) == 0) {
OsSwtmrTimeInfoShow();
return LOS_OK;
#endif
} else {
timerID = strtoul(argv[0], &endPtr, 0);
if ((endPtr == NULL) || (*endPtr != 0) || (timerID > LOSCFG_BASE_CORE_SWTMR_LIMIT)) {
PRINTK("\nswtmr ID can't access %s.\n", argv[0]);
return LOS_NOK;
}
}
return SwtmrBaseInfoGet(timerID);
SWTMR_HELP:
PRINTK("Usage:\n");
PRINTK(" swtmr --- Information about all created software timers.\n");
PRINTK(" swtmr ID --- Specifies information about a software timer.\n");
return LOS_OK;
}
SHELLCMD_ENTRY(swtmr_shellcmd, CMD_TYPE_EX, "swtmr", 1, (CmdCallBackFunc)OsShellCmdSwtmrInfoGet); SHELLCMD_ENTRY(swtmr_shellcmd, CMD_TYPE_EX, "swtmr", 1, (CmdCallBackFunc)OsShellCmdSwtmrInfoGet);
#endif /* LOSCFG_SHELL */ #endif /* LOSCFG_SHELL */
此差异已折叠。
...@@ -121,17 +121,22 @@ UINT32 OsShellCmdProcessVmUsage(LosVmSpace *space) ...@@ -121,17 +121,22 @@ UINT32 OsShellCmdProcessVmUsage(LosVmSpace *space)
if (space == LOS_GetKVmSpace()) { if (space == LOS_GetKVmSpace()) {
OsShellCmdProcessPmUsage(space, NULL, &used); OsShellCmdProcessPmUsage(space, NULL, &used);
} else { return used;
RB_SCAN_SAFE(&space->regionRbTree, pstRbNode, pstRbNodeNext) }
region = (LosVmMapRegion *)pstRbNode; UINT32 ret = LOS_MuxAcquire(&space->regionMux);
used += region->range.size; if (ret != 0) {
RB_SCAN_SAFE_END(&space->regionRbTree, pstRbNode, pstRbNodeNext) return 0;
} }
RB_SCAN_SAFE(&space->regionRbTree, pstRbNode, pstRbNodeNext)
region = (LosVmMapRegion *)pstRbNode;
used += region->range.size;
RB_SCAN_SAFE_END(&space->regionRbTree, pstRbNode, pstRbNodeNext)
(VOID)LOS_MuxRelease(&space->regionMux);
return used; return used;
} }
VOID OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm) UINT32 OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
{ {
UINT32 memUsed; UINT32 memUsed;
UINT32 totalMem; UINT32 totalMem;
...@@ -144,7 +149,7 @@ VOID OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm) ...@@ -144,7 +149,7 @@ VOID OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
UINT32 pmTmp; UINT32 pmTmp;
if (actualPm == NULL) { if (actualPm == NULL) {
return; return 0;
} }
memUsed = LOS_MemTotalUsedGet(m_aucSysMem1); memUsed = LOS_MemTotalUsedGet(m_aucSysMem1);
...@@ -156,13 +161,16 @@ VOID OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm) ...@@ -156,13 +161,16 @@ VOID OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
memUsed = SYS_MEM_SIZE_DEFAULT - (totalCount << PAGE_SHIFT); memUsed = SYS_MEM_SIZE_DEFAULT - (totalCount << PAGE_SHIFT);
spaceList = LOS_GetVmSpaceList(); spaceList = LOS_GetVmSpaceList();
LosMux *vmSpaceListMux = OsGVmSpaceMuxGet();
(VOID)LOS_MuxAcquire(vmSpaceListMux);
LOS_DL_LIST_FOR_EACH_ENTRY(space, spaceList, LosVmSpace, node) { LOS_DL_LIST_FOR_EACH_ENTRY(space, spaceList, LosVmSpace, node) {
if (space == LOS_GetKVmSpace()) { if (space == LOS_GetKVmSpace()) {
continue; continue;
} }
OsUProcessPmUsage(space, NULL, &pmTmp); (VOID)OsUProcessPmUsage(space, NULL, &pmTmp);
UProcessUsed += pmTmp; UProcessUsed += pmTmp;
} }
(VOID)LOS_MuxRelease(vmSpaceListMux);
/* Kernel dynamic memory, include extended heap memory */ /* Kernel dynamic memory, include extended heap memory */
memUsed += ((usedCount << PAGE_SHIFT) - UProcessUsed); memUsed += ((usedCount << PAGE_SHIFT) - UProcessUsed);
...@@ -170,26 +178,26 @@ VOID OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm) ...@@ -170,26 +178,26 @@ VOID OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
memUsed -= freeMem; memUsed -= freeMem;
*actualPm = memUsed; *actualPm = memUsed;
return memUsed;
} }
VOID OsShellCmdProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm) UINT32 OsShellCmdProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm)
{ {
if (space == NULL) { if (space == NULL) {
return; return 0;
} }
if ((sharePm == NULL) && (actualPm == NULL)) { if ((sharePm == NULL) && (actualPm == NULL)) {
return; return 0;
} }
if (space == LOS_GetKVmSpace()) { if (space == LOS_GetKVmSpace()) {
OsKProcessPmUsage(space, actualPm); return OsKProcessPmUsage(space, actualPm);
} else {
OsUProcessPmUsage(space, sharePm, actualPm);
} }
return OsUProcessPmUsage(space, sharePm, actualPm);
} }
VOID OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm) UINT32 OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm)
{ {
LosVmMapRegion *region = NULL; LosVmMapRegion *region = NULL;
LosRbNode *pstRbNode = NULL; LosRbNode *pstRbNode = NULL;
...@@ -209,6 +217,10 @@ VOID OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm) ...@@ -209,6 +217,10 @@ VOID OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm)
*actualPm = 0; *actualPm = 0;
} }
ret = LOS_MuxAcquire(&space->regionMux);
if (ret != 0) {
return 0;
}
RB_SCAN_SAFE(&space->regionRbTree, pstRbNode, pstRbNodeNext) RB_SCAN_SAFE(&space->regionRbTree, pstRbNode, pstRbNodeNext)
region = (LosVmMapRegion *)pstRbNode; region = (LosVmMapRegion *)pstRbNode;
vaddr = region->range.base; vaddr = region->range.base;
...@@ -238,6 +250,9 @@ VOID OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm) ...@@ -238,6 +250,9 @@ VOID OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm)
} }
} }
RB_SCAN_SAFE_END(&oldVmSpace->regionRbTree, pstRbNode, pstRbNodeNext) RB_SCAN_SAFE_END(&oldVmSpace->regionRbTree, pstRbNode, pstRbNodeNext)
(VOID)LOS_MuxRelease(&space->regionMux);
return *actualPm;
} }
LosProcessCB *OsGetPIDByAspace(LosVmSpace *space) LosProcessCB *OsGetPIDByAspace(LosVmSpace *space)
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
LITE_OS_SEC_BSS STATIC UINT16 cpupSwtmrID; LITE_OS_SEC_BSS STATIC UINT16 cpupSwtmrID;
LITE_OS_SEC_BSS STATIC UINT16 cpupInitFlg = 0; LITE_OS_SEC_BSS STATIC UINT16 cpupInitFlg = 0;
LITE_OS_SEC_BSS OsIrqCpupCB *g_irqCpup = NULL; LITE_OS_SEC_BSS OsIrqCpupCB *g_irqCpup = NULL;
LITE_OS_SEC_BSS STATIC UINT16 cpupMaxNum; LITE_OS_SEC_BSS STATIC UINT32 cpupMaxNum;
LITE_OS_SEC_BSS STATIC UINT16 cpupHisPos = 0; /* current Sampling point of historyTime */ LITE_OS_SEC_BSS STATIC UINT16 cpupHisPos = 0; /* current Sampling point of historyTime */
LITE_OS_SEC_BSS STATIC UINT64 cpuHistoryTime[OS_CPUP_HISTORY_RECORD_NUM + 1]; LITE_OS_SEC_BSS STATIC UINT64 cpuHistoryTime[OS_CPUP_HISTORY_RECORD_NUM + 1];
LITE_OS_SEC_BSS STATIC UINT32 runningTasks[LOSCFG_KERNEL_CORE_NUM]; LITE_OS_SEC_BSS STATIC UINT32 runningTasks[LOSCFG_KERNEL_CORE_NUM];
...@@ -100,6 +100,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsCpupGuard(VOID) ...@@ -100,6 +100,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsCpupGuard(VOID)
#ifdef LOSCFG_CPUP_INCLUDE_IRQ #ifdef LOSCFG_CPUP_INCLUDE_IRQ
for (loop = 0; loop < cpupMaxNum; loop++) { for (loop = 0; loop < cpupMaxNum; loop++) {
if (g_irqCpup[loop].status == OS_CPUP_UNUSED) {
continue;
}
g_irqCpup[loop].cpup.historyTime[prevPos] = g_irqCpup[loop].cpup.allTime; g_irqCpup[loop].cpup.historyTime[prevPos] = g_irqCpup[loop].cpup.allTime;
} }
#endif #endif
...@@ -160,7 +163,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit(VOID) ...@@ -160,7 +163,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit(VOID)
#ifdef LOSCFG_CPUP_INCLUDE_IRQ #ifdef LOSCFG_CPUP_INCLUDE_IRQ
UINT32 size; UINT32 size;
cpupMaxNum = OS_HWI_MAX_NUM; cpupMaxNum = OS_HWI_MAX_NUM * LOSCFG_KERNEL_CORE_NUM;
/* every process has only one record, and it won't operated at the same time */ /* every process has only one record, and it won't operated at the same time */
size = cpupMaxNum * sizeof(OsIrqCpupCB); size = cpupMaxNum * sizeof(OsIrqCpupCB);
...@@ -227,6 +230,7 @@ LITE_OS_SEC_TEXT_INIT VOID LOS_CpupReset(VOID) ...@@ -227,6 +230,7 @@ LITE_OS_SEC_TEXT_INIT VOID LOS_CpupReset(VOID)
if (g_irqCpup != NULL) { if (g_irqCpup != NULL) {
for (index = 0; index < cpupMaxNum; index++) { for (index = 0; index < cpupMaxNum; index++) {
OsResetCpup(&g_irqCpup[index].cpup, cycle); OsResetCpup(&g_irqCpup[index].cpup, cycle);
g_irqCpup[index].timeMax = 0;
} }
for (index = 0; index < LOSCFG_KERNEL_CORE_NUM; index++) { for (index = 0; index < LOSCFG_KERNEL_CORE_NUM; index++) {
...@@ -520,31 +524,41 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllProcessAndTaskCpuUsageUnsafe(UINT16 mode, ...@@ -520,31 +524,41 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllProcessAndTaskCpuUsageUnsafe(UINT16 mode,
} }
#ifdef LOSCFG_CPUP_INCLUDE_IRQ #ifdef LOSCFG_CPUP_INCLUDE_IRQ
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(VOID) LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT16 cpuId)
{ {
UINT32 high; UINT32 high;
UINT32 low; UINT32 low;
LOS_GetCpuCycle(&high, &low); LOS_GetCpuCycle(&high, &low);
cpupIntTimeStart[ArchCurrCpuid()] = ((UINT64)high << HIGH_BITS) + low; cpupIntTimeStart[cpuId] = ((UINT64)high << HIGH_BITS) + low;
return; return;
} }
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum) LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT16 cpuId, UINT32 intNum)
{ {
UINT32 high; UINT32 high;
UINT32 low; UINT32 low;
UINT64 intTimeEnd; UINT64 intTimeEnd;
UINT32 cpuID = ArchCurrCpuid(); UINT64 usedTime;
LOS_GetCpuCycle(&high, &low); LOS_GetCpuCycle(&high, &low);
intTimeEnd = ((UINT64)high << HIGH_BITS) + low; intTimeEnd = ((UINT64)high << HIGH_BITS) + low;
OsIrqCpupCB *irqCb = &g_irqCpup[(intNum * LOSCFG_KERNEL_CORE_NUM) + cpuId];
g_irqCpup[intNum].id = intNum; irqCb->id = intNum;
g_irqCpup[intNum].status = OS_CPUP_USED; irqCb->status = OS_CPUP_USED;
timeInIrqSwitch[cpuID] += (intTimeEnd - cpupIntTimeStart[cpuID]); usedTime = intTimeEnd - cpupIntTimeStart[cpuId];
g_irqCpup[intNum].cpup.allTime += (intTimeEnd - cpupIntTimeStart[cpuID]); timeInIrqSwitch[cpuId] += usedTime;
irqCb->cpup.allTime += usedTime;
if (irqCb->count <= 100) { /* Take 100 samples */
irqCb->allTime += usedTime;
irqCb->count++;
} else {
irqCb->allTime = 0;
irqCb->count = 0;
}
if (usedTime > irqCb->timeMax) {
irqCb->timeMax = usedTime;
}
return; return;
} }
......
...@@ -59,6 +59,9 @@ typedef struct { ...@@ -59,6 +59,9 @@ typedef struct {
typedef struct { typedef struct {
UINT32 id; /**< irq ID */ UINT32 id; /**< irq ID */
UINT16 status; /**< irq status */ UINT16 status; /**< irq status */
UINT64 allTime;
UINT64 timeMax;
UINT64 count;
OsCpupBase cpup; /**< irq cpup base */ OsCpupBase cpup; /**< irq cpup base */
} OsIrqCpupCB; } OsIrqCpupCB;
...@@ -70,8 +73,8 @@ extern UINT32 OsGetAllProcessCpuUsageUnsafe(UINT16 mode, CPUP_INFO_S *cpupInfo, ...@@ -70,8 +73,8 @@ extern UINT32 OsGetAllProcessCpuUsageUnsafe(UINT16 mode, CPUP_INFO_S *cpupInfo,
extern UINT32 OsGetAllProcessAndTaskCpuUsageUnsafe(UINT16 mode, CPUP_INFO_S *cpupInfo, UINT32 len); extern UINT32 OsGetAllProcessAndTaskCpuUsageUnsafe(UINT16 mode, CPUP_INFO_S *cpupInfo, UINT32 len);
#ifdef LOSCFG_CPUP_INCLUDE_IRQ #ifdef LOSCFG_CPUP_INCLUDE_IRQ
extern UINT32 OsGetAllIrqCpuUsageUnsafe(UINT16 mode, CPUP_INFO_S *cpupInfo, UINT32 len); extern UINT32 OsGetAllIrqCpuUsageUnsafe(UINT16 mode, CPUP_INFO_S *cpupInfo, UINT32 len);
extern VOID OsCpupIrqStart(VOID); extern VOID OsCpupIrqStart(UINT16);
extern VOID OsCpupIrqEnd(UINT32); extern VOID OsCpupIrqEnd(UINT16, UINT32);
extern OsIrqCpupCB *OsGetIrqCpupArrayBase(VOID); extern OsIrqCpupCB *OsGetIrqCpupArrayBase(VOID);
#endif #endif
......
...@@ -40,15 +40,54 @@ ...@@ -40,15 +40,54 @@
#ifdef LOSCFG_CPUP_INCLUDE_IRQ #ifdef LOSCFG_CPUP_INCLUDE_IRQ
STATIC CPUP_INFO_S hwiCpupAll[OS_HWI_MAX_NUM]; #define IRQ_CPUP_INFO_SIZE (sizeof(CPUP_INFO_S) * OS_HWI_MAX_NUM * LOSCFG_KERNEL_CORE_NUM)
STATIC CPUP_INFO_S hwiCpup10s[OS_HWI_MAX_NUM]; #define IRQ_CPUP_ALL_INFO_SIZE (3 * IRQ_CPUP_INFO_SIZE)
STATIC CPUP_INFO_S hwiCpup1s[OS_HWI_MAX_NUM]; #define IRQ_DATA_SZIE (sizeof(OsIrqCpupCB) * LOSCFG_KERNEL_CORE_NUM)
#define CPUP_PRECISION_MULT LOS_CPUP_PRECISION_MULT
STATIC VOID ShellCmdHwiInfoShow(OsIrqCpupCB *irqData, CPUP_INFO_S *hwiCpup1s,
CPUP_INFO_S *hwiCpup10s, CPUP_INFO_S *hwiCpupAll)
{
UINT32 intSave;
OsIrqCpupCB *irqDataBase = OsGetIrqCpupArrayBase();
for (UINT32 i = OS_HWI_FORM_EXC_NUM; i < OS_HWI_MAX_NUM + OS_HWI_FORM_EXC_NUM; i++) {
if (!HWI_IS_REGISTED(i)) {
continue;
}
intSave = LOS_IntLock();
(VOID)memcpy_s(irqData, IRQ_DATA_SZIE, &irqDataBase[i * LOSCFG_KERNEL_CORE_NUM], IRQ_DATA_SZIE);
LOS_IntRestore(intSave);
for (UINT32 cpu = 0; cpu < LOSCFG_KERNEL_CORE_NUM; cpu++) {
UINT64 cycles = 0;
UINT64 timeMax = 0;
OsIrqCpupCB *data = &irqData[cpu];
if (data->status == 0) {
continue;
}
UINT32 count = OsGetHwiFormCnt(cpu, i);
if (count != 0) {
if (data->count != 0) {
cycles = (data->allTime * OS_NS_PER_CYCLE) / (data->count * OS_SYS_NS_PER_US);
}
timeMax = (data->timeMax * OS_NS_PER_CYCLE) / 1000;
}
CHAR *irqName = OsGetHwiFormName(i);
UINT32 index = (i * LOSCFG_KERNEL_CORE_NUM) + cpu;
PRINTK(" %10d:%5u%11u%11llu%10llu%6u.%-2u%8u.%-2u%7u.%-2u%7s %-12s\n", i, cpu, count, cycles, timeMax,
hwiCpupAll[index].usage / CPUP_PRECISION_MULT, hwiCpupAll[index].usage % CPUP_PRECISION_MULT,
hwiCpup10s[index].usage / CPUP_PRECISION_MULT, hwiCpup10s[index].usage % CPUP_PRECISION_MULT,
hwiCpup1s[index].usage / CPUP_PRECISION_MULT, hwiCpup1s[index].usage % CPUP_PRECISION_MULT,
(g_hwiForm[index].uwParam == IRQF_SHARED) ? "shared" : "normal", (irqName != NULL) ? irqName : "");
}
}
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdHwi(INT32 argc, const CHAR **argv) LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdHwi(INT32 argc, const CHAR **argv)
{ {
UINT32 i; UINT32 size;
UINT64 cycles;
size_t size = sizeof(CPUP_INFO_S) * OS_HWI_MAX_NUM;
OsIrqCpupCB *irqCpup = OsGetIrqCpupArrayBase();
(VOID)argv; (VOID)argv;
if (argc > 0) { if (argc > 0) {
...@@ -56,38 +95,24 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdHwi(INT32 argc, const CHAR **argv) ...@@ -56,38 +95,24 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdHwi(INT32 argc, const CHAR **argv)
return OS_ERROR; return OS_ERROR;
} }
size = IRQ_CPUP_ALL_INFO_SIZE + IRQ_DATA_SZIE;
CHAR *irqCpup = LOS_MemAlloc(m_aucSysMem0, size);
if (irqCpup == NULL) { if (irqCpup == NULL) {
return OS_ERROR; return OS_ERROR;
} }
(VOID)LOS_GetAllIrqCpuUsage(CPUP_ALL_TIME, hwiCpupAll, size); CPUP_INFO_S *hwiCpupAll = (CPUP_INFO_S *)irqCpup;
(VOID)LOS_GetAllIrqCpuUsage(CPUP_LAST_TEN_SECONDS, hwiCpup10s, size); CPUP_INFO_S *hwiCpup10s = (CPUP_INFO_S *)(irqCpup + IRQ_CPUP_INFO_SIZE);
(VOID)LOS_GetAllIrqCpuUsage(CPUP_LAST_ONE_SECONDS, hwiCpup1s, size); CPUP_INFO_S *hwiCpup1s = (CPUP_INFO_S *)(irqCpup + 2 * IRQ_CPUP_INFO_SIZE); /* 2: offset */
OsIrqCpupCB *irqData = (OsIrqCpupCB *)(irqCpup + IRQ_CPUP_ALL_INFO_SIZE);
PRINTK(" InterruptNo Count ATime(us) CPUUSE CPUUSE10s CPUUSE1s Mode Name\n"); (VOID)LOS_GetAllIrqCpuUsage(CPUP_ALL_TIME, hwiCpupAll, IRQ_CPUP_INFO_SIZE);
for (i = OS_HWI_FORM_EXC_NUM; i < OS_HWI_MAX_NUM + OS_HWI_FORM_EXC_NUM; i++) { (VOID)LOS_GetAllIrqCpuUsage(CPUP_LAST_TEN_SECONDS, hwiCpup10s, IRQ_CPUP_INFO_SIZE);
UINT32 count = OsGetHwiFormCnt(i); (VOID)LOS_GetAllIrqCpuUsage(CPUP_LAST_ONE_SECONDS, hwiCpup1s, IRQ_CPUP_INFO_SIZE);
if (count) {
cycles = (((OsIrqCpupCB *)(&irqCpup[i]))->cpup.allTime * OS_NS_PER_CYCLE) / (count * OS_SYS_NS_PER_US); PRINTK(" InterruptNo cpu Count ATime(us) MTime(us) CPUUSE CPUUSE10s CPUUSE1s Mode Name\n");
} else { ShellCmdHwiInfoShow(irqData, hwiCpup1s, hwiCpup10s, hwiCpupAll);
cycles = 0; (VOID)LOS_MemFree(m_aucSysMem0, irqCpup);
}
/* Different cores has different hwi form implementation */
if (HWI_IS_REGISTED(i)) {
PRINTK(" %10d:%11u%11llu", i, count, cycles);
} else {
continue;
}
PRINTK("%6u.%-2u%8u.%-2u%7u.%-2u%7s %-12s\n",
hwiCpupAll[i].usage / LOS_CPUP_PRECISION_MULT,
hwiCpupAll[i].usage % LOS_CPUP_PRECISION_MULT,
hwiCpup10s[i].usage / LOS_CPUP_PRECISION_MULT,
hwiCpup10s[i].usage % LOS_CPUP_PRECISION_MULT,
hwiCpup1s[i].usage / LOS_CPUP_PRECISION_MULT,
hwiCpup1s[i].usage % LOS_CPUP_PRECISION_MULT,
(g_hwiForm[i].uwParam == IRQF_SHARED) ? "shared" : "normal",
(OsGetHwiFormName(i) != NULL) ? OsGetHwiFormName(i) : "");
}
return 0; return 0;
} }
#else #else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册