]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/pdk.git/commitdiff
Fix: PDK-12437: UDMA UT prints CPU load as 100%
authorLohith Kumar <l-kumar@ti.com>
Mon, 23 Jan 2023 09:38:56 +0000 (15:08 +0530)
committerLohith Kumar <l-kumar@ti.com>
Mon, 23 Jan 2023 09:41:55 +0000 (15:11 +0530)
- UDMA UT was using baremetal calculation instead of
  using freeRTOS API's to profile CPU usage and
  always prints 100% cpu usage. This commit uses freeRTOS
  API's to profile UDMA UT.

Signed-off-by: Lohith Kumar <l-kumar@ti.com>
packages/ti/drv/udma/unit_test/udma_ut/makefile
packages/ti/drv/udma/unit_test/udma_ut/src/utils_prf.c
packages/ti/drv/udma/unit_test/udma_ut/src/utils_prf.h

index 90a0806142b27ee2591a35a03986866f87838dee..d3582d37e49755f7783036183399264bf72a1a9b 100755 (executable)
@@ -17,33 +17,18 @@ BUILD_OS_TYPE=baremetal
 endif
 
 #
-# This file is common makefile for building UDMA unit test app for both TI-RTOS/baremetal
+# This file is common makefile for building UDMA unit test app for RTOS
 #
-SRCDIR = . ./src ./src/soc/$(SOC) ./rtos ./baremetal
-INCDIR = . ./src ./src/soc/$(SOC) ./rtos ./baremetal
+SRCDIR = . ./src ./src/soc/$(SOC) ./rtos
+INCDIR = . ./src ./src/soc/$(SOC) ./rtos
 
 # List all the external components/interfaces, whose interface header files
 #  need to be included for this component
 INCLUDE_EXTERNAL_INTERFACES = pdk
 
-ifeq ($(BUILD_OS_TYPE), baremetal)
-  COMP_LIST_COMMON = $(PDK_COMMON_BAREMETAL_COMP)
-  SRCS_COMMON = main_baremetal.c
-  ifeq ($(ISA),$(filter $(ISA), a53 a72))
-    LNKFLAGS_LOCAL_$(CORE) += --entry Entry
-  endif
-endif
-ifeq ($(BUILD_OS_TYPE), tirtos)
-  INCLUDE_EXTERNAL_INTERFACES += xdc bios
-  COMP_LIST_COMMON = $(PDK_COMMON_TIRTOS_COMP)
-  SRCS_COMMON = main_rtos.c
-  XDC_CFG_FILE_$(CORE) = $(PDK_INSTALL_PATH)/ti/build/$(SOC)/sysbios_$(ISA).cfg
-endif
-ifeq ($(BUILD_OS_TYPE), freertos)
-  COMP_LIST_COMMON = $(PDK_COMMON_FREERTOS_COMP)
-  INCLUDE_EXTERNAL_INTERFACES += freertos
-  SRCS_COMMON = main_rtos.c
-endif
+COMP_LIST_COMMON = $(PDK_COMMON_FREERTOS_COMP)
+INCLUDE_EXTERNAL_INTERFACES += freertos
+SRCS_COMMON = main_rtos.c
 
 ifeq ($(BUILD_OS_TYPE), safertos)
   CFLAGS_OS_DEFINES = -DSAFERTOS
@@ -64,21 +49,8 @@ SRCS_COMMON += udma_test_ring.c udma_test_ch.c
 SRCS_COMMON += udma_test_event.c udma_test_flow.c
 SRCS_COMMON += udma_test_bug.c udma_test_misc.c
 SRCS_COMMON += udma_test_soc.c
-ifneq ($(SOC),$(filter $(SOC), am64x))
-  SRCS_COMMON += udma_test_proxy.c udma_test_ring_monitor.c
-endif
 SRCS_COMMON += utils_trace.c
-ifneq ($(BUILD_OS_TYPE), baremetal)
-  SRCS_COMMON += utils_mem.c
-  # Use baremetal utils_perf for FreeRTOS until Load OSAL is implemented 
-  ifeq ($(BUILD_OS_TYPE), tirtos)
-    SRCS_COMMON += utils_prf.c
-  else 
-    SRCS_COMMON += utils_prf_baremetal.c
-  endif
-else
-  SRCS_COMMON += utils_prf_baremetal.c utils_mem_baremetal.c
-endif
+SRCS_COMMON += utils_mem.c utils_prf.c
 
 CFLAGS_LOCAL_COMMON = $(PDK_CFLAGS) $(UDMA_CFLAGS) $(UDMAUT_CFLAGS) $(CFLAGS_OS_DEFINES)
 ifeq ($(UDMA_UT_MANUAL_ENTRY), yes)
@@ -90,16 +62,6 @@ endif
 ifeq ($(UDMA_UT_DYNAMIC_ANALYSIS), yes)
   CFLAGS_LOCAL_COMMON += -DUDMA_UT_DYNAMIC_ANALYSIS -DUDMA_UT_BAREMETAL
 endif
-ifeq ($(BUILD_OS_TYPE), baremetal)
-  ifeq ($(ISA), c66)
-    EXTERNAL_LNKCMD_FILE_LOCAL = baremetal/$(SOC)/linker_$(ISA).cmd
-  else
-    EXTERNAL_LNKCMD_FILE_LOCAL = baremetal/$(SOC)/linker_$(ISA).lds
-  endif
-endif
-ifeq ($(BUILD_OS_TYPE), tirtos)
-  EXTERNAL_LNKCMD_FILE_LOCAL = rtos/$(SOC)/linker_$(CORE).lds
-endif
 ifeq ($(BUILD_OS_TYPE), freertos)
   ifeq ($(SOC),$(filter $(SOC), j721s2))
     APPEND_LNKCMD_FILE = rtos/j721s2/linker_append_$(ISA).cmd
index c3f8beed09ef4476798fa840b2ec60b6d693191b..550dc6fffad6ab20b8be6f901f4fbbd1315d9067 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) Texas Instruments Incorporated 2018
+ *  Copyright (c) Texas Instruments Incorporated 2018-2023
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
 /* ========================================================================== */
 
 #include <string.h>
-#include <xdc/runtime/System.h>
-#include <xdc/runtime/Types.h>
-#include <xdc/runtime/Timestamp.h>
-#include <ti/sysbios/hal/Hwi.h>
-#include <ti/sysbios/utils/Load.h>
-#include <ti/sysbios/knl/Task.h>
-
+#include "ti/osal/osal.h"
+#include "ti/osal/TaskP.h"
+#include "ti/osal/LoadP.h"
 #include "udma_test.h"
 
 /* ========================================================================== */
@@ -94,33 +90,18 @@ typedef struct
 /* ========================================================================== */
 
 static Utils_PrfObj        gUtils_prfObj;
-static Utils_AccPrfLoadObj gUtils_accPrfLoadObj;
-static uint32_t               gUtils_startLoadCalc = 0;
 
 /* ========================================================================== */
 /*                          Function Definitions                              */
 /* ========================================================================== */
 
-int32_t Utils_prfInit(void)
-{
-    memset(&gUtils_prfObj, 0, sizeof (gUtils_prfObj));
-    memset(&gUtils_accPrfLoadObj, 0, sizeof (Utils_AccPrfLoadObj));
-
-    return (0);
-}
-
-int32_t Utils_prfDeInit(void)
-{
-    return (0);
-}
-
 Utils_PrfTsHndl *Utils_prfTsCreate(const char *name)
 {
     uint32_t        hndlId;
     uint32_t        cookie;
     Utils_PrfTsHndl *pHndl = NULL;
 
-    cookie = Hwi_disable();
+    cookie = HwiP_disable();
 
     for (hndlId = 0; hndlId < UTILS_PRF_MAX_HNDL; hndlId++)
     {
@@ -137,7 +118,7 @@ Utils_PrfTsHndl *Utils_prfTsCreate(const char *name)
         }
     }
 
-    Hwi_restore(cookie);
+    HwiP_restore(cookie);
 
     return (pHndl);
 }
@@ -169,13 +150,13 @@ uint64_t Utils_prfTsDelta(Utils_PrfTsHndl *pHndl,
 
     endTs = Utils_prfTsGet64();
 
-    cookie = Hwi_disable();
+    cookie = HwiP_disable();
 
     pHndl->totalTs += (endTs - pHndl->startTs);
     pHndl->count++;
     pHndl->numFrames += numFrames;
 
-    Hwi_restore(cookie);
+    HwiP_restore(cookie);
 
     return (endTs);
 }
@@ -184,40 +165,29 @@ int32_t Utils_prfTsReset(Utils_PrfTsHndl *pHndl)
 {
     uint32_t cookie;
 
-    cookie = Hwi_disable();
+    cookie = HwiP_disable();
 
     pHndl->totalTs   = 0;
     pHndl->count     = 0;
     pHndl->numFrames = 0;
 
-    Hwi_restore(cookie);
+    HwiP_restore(cookie);
 
     return (0);
 }
 
 uint64_t Utils_prfTsGet64(void)
 {
-    uint64_t curTs;
-    Types_Timestamp64 ts64;
-
-    Timestamp_get64(&ts64);
-
-    curTs = ((uint64_t) ts64.hi << 32) | ts64.lo;
-
+    uint64_t curTs = (uint64_t) AppUtils_getCurTimeInMsec();
     return (curTs);
 }
 
 int32_t Utils_prfTsPrint(Utils_PrfTsHndl *pHndl, uint32_t resetAfterPrint, uint32_t trace)
 {
-    uint32_t       cpuKhz;
     uint32_t       timeMs, fps, fpc;
-    Types_FreqHz cpuHz;
 
-    Timestamp_getFreq(&cpuHz);
 
-    cpuKhz = cpuHz.lo / (uint32_t) 1000U; /* convert to Khz */
-
-    timeMs = pHndl->totalTs / cpuKhz;
+    timeMs = pHndl->totalTs;
 
     if(0U == timeMs)
     {
@@ -285,7 +255,7 @@ int32_t Utils_prfLoadRegister(TaskP_Handle pTsk, const char *name)
     int32_t             status = CSL_EFAIL;
     Utils_PrfLoadObj   *pHndl;
 
-    cookie = Hwi_disable();
+    cookie = HwiP_disable();
 
     for (hndlId = 0; hndlId < UTILS_PRF_MAX_HNDL; hndlId++)
     {
@@ -303,7 +273,7 @@ int32_t Utils_prfLoadRegister(TaskP_Handle pTsk, const char *name)
         }
     }
 
-    Hwi_restore(cookie);
+    HwiP_restore(cookie);
 
     return (status);
 }
@@ -315,7 +285,7 @@ int32_t Utils_prfLoadUnRegister(TaskP_Handle pTsk)
     int32_t             status = CSL_EFAIL;
     Utils_PrfLoadObj   *pHndl;
 
-    cookie = Hwi_disable();
+    cookie = HwiP_disable();
 
     for (hndlId = 0; hndlId < UTILS_PRF_MAX_HNDL; hndlId++)
     {
@@ -329,32 +299,27 @@ int32_t Utils_prfLoadUnRegister(TaskP_Handle pTsk)
         }
     }
 
-    Hwi_restore(cookie);
+    HwiP_restore(cookie);
 
     return (status);
 }
 
 int32_t Utils_prfLoadPrintAll(uint32_t printTskLoad, uint32_t trace)
 {
-    uint32_t            hwiLoad, swiLoad, tskLoad, hndlId, cpuLoad;
+    uint32_t            tskLoad, hndlId, cpuLoad;
     Utils_PrfLoadObj   *pHndl;
 
-    hwiLoad = (uint32_t) ((gUtils_accPrfLoadObj.totalHwiThreadTime *
-                         (uint64_t) 100U) / gUtils_accPrfLoadObj.totalTime);
-    swiLoad = (uint32_t) ((gUtils_accPrfLoadObj.totalSwiThreadTime *
-                         (uint64_t) 100U) / gUtils_accPrfLoadObj.totalTime);
-    cpuLoad = (uint32_t) 100U -
-              (uint32_t) ((gUtils_accPrfLoadObj.totalIdlTskTime *
-                         (uint64_t) 100U) /
-                        gUtils_accPrfLoadObj.totalTime);
+    LoadP_Status status = LoadP_OK;
+    LoadP_Stats loadStatsTask;
+
+    /* Query CPU Load */
+    cpuLoad = LoadP_getCPULoad();
 
     GT_0trace(trace, GT_INFO, "\r\n");
-    GT_4trace(trace, GT_INFO,
-              " %d: LOAD: CPU: %d%%, HWI: %d%%, SWI:%d%% \r\n",
+    GT_2trace(trace, GT_INFO,
+              " %d: LOAD: CPU: %d%% \r\n",
               AppUtils_getCurTimeInMsec(),
-              cpuLoad,
-              hwiLoad,
-              swiLoad);
+              cpuLoad);
 
     if(((uint32_t) TRUE) == printTskLoad)
     {
@@ -364,9 +329,8 @@ int32_t Utils_prfLoadPrintAll(uint32_t printTskLoad, uint32_t trace)
 
             if(TRUE == pHndl->isAlloc)
             {
-                tskLoad = (uint32_t) ((pHndl->totalTskThreadTime *
-                                     (uint64_t) 100U) /
-                                    gUtils_accPrfLoadObj.totalTime);
+                status += LoadP_getTaskLoad(pHndl->pTsk, &loadStatsTask);
+                tskLoad = loadStatsTask.percentLoad;
 
                 GT_3trace(trace, GT_INFO,
                           " %d: LOAD: TSK: %s: %d%% \r\n",
@@ -384,23 +348,14 @@ int32_t Utils_prfLoadPrintAll(uint32_t printTskLoad, uint32_t trace)
 
 void Utils_prfLoadCalcStart(void)
 {
-    uint32_t cookie;
-
-    cookie = Hwi_disable();
-    gUtils_startLoadCalc = (uint32_t) TRUE;
-    Hwi_restore(cookie);
+    
+    LoadP_reset();
 
     return;
 }
 
 void Utils_prfLoadCalcStop(void)
 {
-    uint32_t cookie;
-
-    cookie = Hwi_disable();
-    gUtils_startLoadCalc = FALSE;
-    Hwi_restore(cookie);
-
     return;
 }
 
@@ -409,11 +364,6 @@ void Utils_prfLoadCalcReset(void)
     uint32_t            hndlId;
     Utils_PrfLoadObj   *pHndl;
 
-    gUtils_accPrfLoadObj.totalHwiThreadTime = 0;
-    gUtils_accPrfLoadObj.totalSwiThreadTime = 0;
-    gUtils_accPrfLoadObj.totalTime          = 0;
-    gUtils_accPrfLoadObj.totalIdlTskTime    = 0;
-
     /* Reset the performace loads accumulator */
     for (hndlId = 0; hndlId < UTILS_PRF_MAX_HNDL; hndlId++)
     {
@@ -432,39 +382,5 @@ void Utils_prfLoadCalcReset(void)
 /* Function called by Loadupdate for each update cycle */
 void Utils_prfLoadUpdate(void)
 {
-    uint32_t            hndlId;
-    Load_Stat           hwiLoadStat, swiLoadStat, tskLoadStat, idlTskLoadStat;
-    TaskP_Handle        idlTskHndl = NULL;
-    Utils_PrfLoadObj   *pHndl;
-
-    if(((uint32_t) TRUE) == (uint32_t) gUtils_startLoadCalc)
-    {
-        idlTskHndl = Task_getIdleTask();
-
-        /* Get the all loads first */
-        Load_getGlobalHwiLoad(&hwiLoadStat);
-        Load_getGlobalSwiLoad(&swiLoadStat);
-        Load_getTaskLoad(idlTskHndl, &idlTskLoadStat);
-
-        gUtils_accPrfLoadObj.totalHwiThreadTime += hwiLoadStat.threadTime;
-        gUtils_accPrfLoadObj.totalSwiThreadTime += swiLoadStat.threadTime;
-        gUtils_accPrfLoadObj.totalTime          += hwiLoadStat.totalTime;
-        gUtils_accPrfLoadObj.totalIdlTskTime    += idlTskLoadStat.threadTime;
-
-        /* Call the load updated function of each registered task one by one
-         * along with the swiLoad, hwiLoad, and Task's own load */
-        for (hndlId = 0; hndlId < UTILS_PRF_MAX_HNDL; hndlId++)
-        {
-            pHndl = &gUtils_prfObj.loadObj[hndlId];
-
-            if(((uint32_t) TRUE == pHndl->isAlloc) &&
-                (pHndl->pTsk != NULL))
-            {
-                Load_getTaskLoad(pHndl->pTsk, &tskLoadStat);
-                pHndl->totalTskThreadTime += tskLoadStat.threadTime;
-            }
-        }
-    }
-
     return;
 }
index ce8c6bd5b605f68fce037d9399d044e679bb5eaf..6c722476644ebf59b533eb49b7ca34e721314ede 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) Texas Instruments Incorporated 2018
+ *  Copyright (c) Texas Instruments Incorporated 2018-2023
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
@@ -113,21 +113,6 @@ typedef struct
 /*                          Function Declarations                             */
 /* ========================================================================== */
 
-/**
- *  \brief Initializes the profiling utility.
- *
- *  This function must be called before using any peformance or Timestamp utils
- *
- *  \return 0 on success, else failure
- */
-int32_t Utils_prfInit(void);
-
-/**
- *  \brief De-initializes the profiling utility.
- *
- *  \return 0 on success, else failure
- */
-int32_t Utils_prfDeInit(void);
 
 /**
  *  \brief Creates the handle for the time stamp taking.