1 /* ---------------------------------------------------------------------------- 2 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2022. All rights reserved. 3 * Description: Schedule statistics Private HeadFile 4 * Author: Huawei LiteOS Team 5 * Create: 2018-11-16 6 * Redistribution and use in source and binary forms, with or without modification, 7 * are permitted provided that the following conditions are met: 8 * 1. Redistributions of source code must retain the above copyright notice, this list of 9 * conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 * of conditions and the following disclaimer in the documentation and/or other materials 12 * provided with the distribution. 13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 14 * to endorse or promote products derived from this software without specific prior written 15 * permission. 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * --------------------------------------------------------------------------- */ 28 29 #ifndef _LOS_SCHED_DEBUG_PRI_H 30 #define _LOS_SCHED_DEBUG_PRI_H 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif /* __cplusplus */ 35 36 typedef struct { 37 UINT64 runtime; 38 UINT32 contextSwitch; 39 #ifdef LOSCFG_KERNEL_SMP 40 UINT32 migrationIn; 41 #endif 42 } SchedPercpu; 43 44 typedef struct { 45 UINT64 startRuntime; 46 UINT64 allRuntime; 47 UINT32 allContextSwitch; 48 #ifdef LOSCFG_KERNEL_SMP 49 UINT32 allMigration; 50 #endif 51 SchedPercpu schedPercpu[LOSCFG_KERNEL_CORE_NUM]; 52 } SchedStat; 53 54 typedef struct { 55 DOUBLE passTime; 56 DOUBLE idleTaskTimePercent; /* Percentage of running duration of idle task */ 57 UINT32 taskSwiNum; 58 UINT32 hwiNum; 59 DOUBLE noIdleTaskSwiAvgPri; 60 DOUBLE hiTaskTimePercent; /* Percentage of running duration of high-priority tasks */ 61 UINT32 hiTaskSwiNum; 62 DOUBLE hiTaskAvgRunTime; 63 #ifdef LOSCFG_KERNEL_SMP 64 UINT32 smpHwiNum; 65 UINT32 smpMigrationNum; 66 #endif 67 } SchedStatCpuInfo; 68 69 typedef struct { 70 UINT32 cpuId; 71 DOUBLE cpuRunTime; 72 UINT32 cpuTaskSwiNum; 73 #ifdef LOSCFG_KERNEL_SMP 74 UINT32 cpuSmpMigrationNum; 75 #endif 76 } SchedStatTaskCpuInfo; 77 78 typedef struct { 79 CHAR *taskName; 80 DOUBLE passTime; 81 DOUBLE allRuntime; 82 UINT32 allTaskSwiNum; 83 #ifdef LOSCFG_KERNEL_SMP 84 UINT32 allSmpMigrationNum; 85 #endif 86 UINT32 taskUseCpuNum; 87 SchedStatTaskCpuInfo cpuInfo[LOSCFG_KERNEL_CORE_NUM]; 88 } SchedStatTaskInfo; 89 90 extern VOID OsSchedStatHwi(size_t intNum); 91 92 /* This API is used for Scheduling statistics output */ 93 extern UINT32 OsSchedStatCpuInfoGet(SchedStatCpuInfo *info, UINT32 cpuId); 94 extern UINT32 OsSchedStatTaskInfoGet(SchedStatTaskInfo *info, UINT32 taskId); 95 96 /* This API is used for temporary pause and resume task sched statistics */ 97 extern VOID OsSchedStatPause(VOID); 98 extern VOID OsSchedStatResume(VOID); 99 100 /* This API is used for shell command execution function */ 101 extern VOID OsSchedStatStart(VOID); 102 extern VOID OsSchedStatStop(VOID); 103 extern VOID OsSchedStatInfo(VOID); 104 105 #ifdef __cplusplus 106 } 107 #endif /* __cplusplus */ 108 109 #endif /* _LOS_SCHED_DEBUG_PRI_H */ 110