casaroli commented on code in PR #21428:
URL: https://github.com/apache/nuttx/pull/21428#discussion_r4472040743


##########
sched/clock/clock_perf.c:
##########
@@ -31,13 +31,25 @@
 #include <nuttx/spinlock.h>
 #include <nuttx/wdog.h>
 
-#ifndef CONFIG_ARCH_PERF_EVENTS_USER_ACCESS
-
 /****************************************************************************
  * Preprocessors
  ****************************************************************************/
 
-#  if defined(CONFIG_PERF_OVERFLOW_CORRECTION) && ULONG_MAX != UINT64_MAX
+/* Use up_perf_*() only when they count: the arch starts its counter with
+ * ARCH_PERF_EVENTS, and arch_alarm.c / arch_timer.c provide them when the
+ * arch has no counter.  Else use the system ticks.
+ */
+
+#if defined(CONFIG_ARCH_PERF_EVENTS) || \
+    defined(CONFIG_ARCH_PERF_EVENTS_USER_ACCESS) || \
+    (!defined(CONFIG_ARCH_HAVE_PERF_EVENTS) && \
+     (defined(CONFIG_ALARM_ARCH) || defined(CONFIG_TIMER_ARCH)))

Review Comment:
   That condition is true on qemu-armv8a:nsh with ARCH_PERF_EVENTS off: it has 
ALARM_ARCH and ARCH_HAVE_PERF_EVENTS, and arch_alarm.c provides up_perf_*() 
only without ARCH_HAVE_PERF_EVENTS, so perf_gettime() reads a counter that 
nothing starts. The critmon run time is then 0 ms, the first row of the table; 
with this PR it is 200 ms.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to