FreeRTOS has a great performance measurement feature built-in: Performance counters. At each context switch, the RTOS can do a bookkeeping of time spent in tasks. With this, it can estimate the runtime distribution between the tasks. A very useful feature to get a feeling what the tasks are doing.
But I noticed that with recent FreeRTOS versions, VS Code extension have issues showing the correct runtime counter values:

VS Code Extensions
The issue exists both for the mcu-debug.rtos-views extension v0.0.7, see above) and for the the NXP extension RTOS view (nxpsemiconductors.mcuxpresso, v25.2.45):

nxpsemiconductors.mcuxpresso)It works fine for the Embedded Tools (ms-vscode.vscode-embedded-tools, v0.8.0) from Microsoft:

There might be other extension affected.
FreeRTOS Multicore Support
After some digging, I discovered that the performance counter display in the extension is broken. This started when FreeRTOS added multicore (SMP) support.
Prior that release, FreeRTOS stored the total runtime counter in a single variable:
PRIVILEGED_DATA static volatile configRUN_TIME_COUNTER_TYPE ulTotalRunTime = 0U; /**< Holds the total amount of execution time as defined by the run time counter clock. */
With SMP support, there needs to be a counter for each core:
PRIVILEGED_DATA static volatile configRUN_TIME_COUNTER_TYPE ulTotalRunTime[ configNUMBER_OF_CORES ] = { 0U }; /**< Holds the total amount of execution time as defined by the run time counter clock. */
The affected VS Code Extensions cannot handle that situation. The variable is now an array and not a single variable.
The Solution
One solution would be to fix the extensions or wait for a new release. But it is unknown when that fix would be implemented and available.
Instead, and easy workaround is to revert that change to an array.
This is a rather easy patch in FreeRTOS, with the use of a configuration macro:
#define USE_RUNTIME_COUNTER_ARRAY (configNUMBER_OF_CORES>1)
For systems with more than one core, it uses an array for the counters. For single core systems it uses a single variable only, which works fine for all the extension I use.
With this, runtime counters are shown again in the view:

Summary
The SMP support in FreeRTOS confuses the runtime information for debug extensions. The reason is that the runtime counter changed from a variable to an array of variables.
A workaround is to patch FreeRTOS revert that change at least for single core systems. You can find the patch for FreeRTOS on GitHub (https://github.com/ErichStyger/McuLib/commit/73b19da5c637039e907d45202be7d5ae9bcff3d9).
Have you noticed that issue too? Are you using performance counters at all? Let me know and share your experience with performance counters.
Happy performing 🙂
Links
- Patch for FreeRTOS: https://github.com/ErichStyger/McuLib/commit/73b19da5c637039e907d45202be7d5ae9bcff3d9
- Ticket for cortex-debug: https://github.com/mcu-debug/rtos-views/pull/57
- FreeRTOS with SMP support: https://mcuoneclipse.com/2023/12/29/multi-core-symmetric-multi-processing-smp-with-freertos/
- Implementing FreeRTOS Performance Counters: https://mcuoneclipse.com/2019/12/31/implementing-freertos-performance-counters-on-arm-cortex-m/
- Performance and Runtime Analysis with FreeRTOS: https://mcuoneclipse.com/2018/02/25/performance-and-runtime-analysis-with-freertos/