This is an automated email from the ASF dual-hosted git repository. jiuzhudong pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3b11545356a241b963541e562a46af97441f34d9 Author: wangzhi16 <[email protected]> AuthorDate: Mon Jan 26 15:10:58 2026 +0800 sched/spinlock: Update the information of critmon in docu. Since the busy-wait time statistics for entering the critical section have been added, the critmon information in the document has been updated accordingly. Signed-off-by: wangzhi16 <[email protected]> --- Documentation/implementation/critical_sections.rst | 8 ++++++++ fs/procfs/fs_procfscritmon.c | 14 +++++++------- sched/irq/irq_csection.c | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Documentation/implementation/critical_sections.rst b/Documentation/implementation/critical_sections.rst index 248c852e2a2..7857a39f6a7 100644 --- a/Documentation/implementation/critical_sections.rst +++ b/Documentation/implementation/critical_sections.rst @@ -257,6 +257,14 @@ and preemption operations. Only have instructions when scheduler triggers contex * >= 0 to enable critical section entered time statistic, data will be in critmon procfs. * > 0 to also do alert log when critical section entered time above the configuration ticks. +**Critical section pre-entry busywait time**:: + + CONFIG_SCHED_CRITMONITOR_MAXTIME_BUSYWAIT=-1 + +* Default -1 to disable critical section pre-entry busywait time statistic. +* >= 0 to enable critical section pre-entry busywait time statistic, data will be in critmon procfs. +* > 0 to also do alert log when critical section pre-entry busywait time above the configuration ticks. + **Irq executing time**:: CONFIG_SCHED_CRITMONITOR_MAXTIME_IRQ=-1 diff --git a/fs/procfs/fs_procfscritmon.c b/fs/procfs/fs_procfscritmon.c index bc05e0a4e57..9bf1ae840bd 100644 --- a/fs/procfs/fs_procfscritmon.c +++ b/fs/procfs/fs_procfscritmon.c @@ -191,7 +191,7 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr, size_t copysize; size_t totalsize; #if CONFIG_SCHED_CRITMONITOR_MAXTIME_BUSYWAIT >= 0 - struct timespec alltime; + struct timespec all_time; clock_t elapsed; uint32_t rate; #endif @@ -321,24 +321,24 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr, if (g_busywait_total[cpu] > 0) { - perf_convert(g_busywait_total[cpu], &alltime); + perf_convert(g_busywait_total[cpu], &all_time); } else { - alltime.tv_sec = 0; - alltime.tv_nsec = 0; + all_time.tv_sec = 0; + all_time.tv_nsec = 0; } elapsed = clock() * CONFIG_USEC_PER_TICK; - rate = (uint64_t)(alltime.tv_sec * 1000000 + alltime.tv_nsec / 1000) * + rate = (uint64_t)(all_time.tv_sec * 1000000 + all_time.tv_nsec / 1000) * 1000000 / elapsed; /* Generate output for all busywait time to enter csection(get spinlock) */ linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%lu.%09lu %2" PRId32 ".%04" PRId32 "%%", - (unsigned long)alltime.tv_sec, - (unsigned long)alltime.tv_nsec, + (unsigned long)all_time.tv_sec, + (unsigned long)all_time.tv_nsec, rate / 10000, rate % 10000); copysize = procfs_memcpy(attr->line, linesize, buffer, buflen, offset); diff --git a/sched/irq/irq_csection.c b/sched/irq/irq_csection.c index cee5da70840..1680d11bb92 100644 --- a/sched/irq/irq_csection.c +++ b/sched/irq/irq_csection.c @@ -285,6 +285,7 @@ irqstate_t enter_critical_section_notrace(void) #endif #if CONFIG_SCHED_CRITMONITOR_MAXTIME_CSECTION >= 0 || \ + CONFIG_SCHED_CRITMONITOR_MAXTIME_BUSYWAIT >= 0 || \ defined(CONFIG_SCHED_INSTRUMENTATION_CSECTION) irqstate_t enter_critical_section(void) {
