invalid kernel stats
Posted: Fri Dec 03, 2021 3:57 pm
Hi,
I noticed that the kernel statistics are broken somehow - let me try to explain.
Note: I used the RT-STM32F103RB-NUCLEO64 demo of the stable_21.11.x version to investigate the issue in-depth. However, I could reproduce the same issue with other demos as well.
When I read chVTGetSystemTimeX() right after system initialization, I get a correct value of 0. When I read currcore->kernel_stats.m_crit_thd.worst right after, I get an arbitrary value. At first glance, the values seemed random, but when resetting the board, the value would increase every time. Actually, there seems to be some correlation to time, as I found that the value would increment at ~16 MHz (every ~1 second the value increases by 0x01000000). When reading currcore->kernel_stats.m_crit_thd.worst multiple times within a loop afterwards, the value would not change, though. It is "updated" only by reset (and probably whenever the last measurement would exceed it).
Interestingly, the issue does not affect any of the other statistics. Neither the other members of m_crit_thd are affected, nor any member of m_crit_isr. All of those seem to be correct.
I had a glimpse at the code, but I did not find any issues there. I also wonder what kind of error would result in such odd behaviour. Looks like some addresses are VERY off.
Maybe the issue is actually related to the compiler, but I tested with GCC 10.3.1 as well as GCC 9.3.1 with no effect.
I am sorry that I can only (rather vaguely) describe the issue and can not provide any sort of fix.
Regards,
Thomas
I noticed that the kernel statistics are broken somehow - let me try to explain.
Note: I used the RT-STM32F103RB-NUCLEO64 demo of the stable_21.11.x version to investigate the issue in-depth. However, I could reproduce the same issue with other demos as well.
When I read chVTGetSystemTimeX() right after system initialization, I get a correct value of 0. When I read currcore->kernel_stats.m_crit_thd.worst right after, I get an arbitrary value. At first glance, the values seemed random, but when resetting the board, the value would increase every time. Actually, there seems to be some correlation to time, as I found that the value would increment at ~16 MHz (every ~1 second the value increases by 0x01000000). When reading currcore->kernel_stats.m_crit_thd.worst multiple times within a loop afterwards, the value would not change, though. It is "updated" only by reset (and probably whenever the last measurement would exceed it).
Interestingly, the issue does not affect any of the other statistics. Neither the other members of m_crit_thd are affected, nor any member of m_crit_isr. All of those seem to be correct.
I had a glimpse at the code, but I did not find any issues there. I also wonder what kind of error would result in such odd behaviour. Looks like some addresses are VERY off.
Maybe the issue is actually related to the compiler, but I tested with GCC 10.3.1 as well as GCC 9.3.1 with no effect.
I am sorry that I can only (rather vaguely) describe the issue and can not provide any sort of fix.
Regards,
Thomas