Critical Section Monitor (sched/ and fs/procfs: Remove SCHED_IRQMONITOR_GETTIME to simplify the clock source selection: (1) Use up_critmon_gettime if SCHED_IRQMONITOR, (2) Call clock_systimespec if SCHED_TICKLESS, (3) Don't collect timing info for all other cases and move up_critmon_* to arch.h avoid the duplicated declaration.

This commit is contained in:
Xiang Xiao 2019-01-27 10:13:28 -06:00 committed by Gregory Nutt
parent 1c75aa76f0
commit e57f7cf6ae
6 changed files with 46 additions and 139 deletions

View file

@ -85,17 +85,6 @@ struct critmon_file_s
char line[CRITMON_LINELEN]; /* Pre-allocated buffer for formatted lines */
};
/****************************************************************************
* External Function Prototypes
****************************************************************************/
/* If CONFIG_SCHED_CRITMONITOR is selected, then platform-specific logic
* must provide the following interface. This function converts platform-
* specific elapsed time into a well-known time format.
*/
void up_critmon_convert(uint32_t elapsed, FAR struct timespec *ts);
/****************************************************************************
* Private Function Prototypes
****************************************************************************/

View file

@ -174,20 +174,6 @@ static FAR const char *g_policy[4] =
"SCHED_FIFO", "SCHED_RR", "SCHED_SPORADIC", "SCHED_OTHER"
};
/****************************************************************************
* External Function Prototypes
****************************************************************************/
#ifdef CONFIG_SCHED_CRITMONITOR
/* If CONFIG_SCHED_CRITMONITOR is selected, then platform-specific logic
* must provide the following interface. This interface simply converts an
* elapsed time into well known units for presentation by the ProcFS file
* system..
*/
void up_critmon_convert(uint32_t starttime, FAR struct timespec *ts);
#endif
/****************************************************************************
* Private Function Prototypes
****************************************************************************/

View file

@ -2400,6 +2400,30 @@ void arch_sporadic_suspend(FAR struct tcb_s *tcb);
void arch_sporadic_resume(FAR struct tcb_s *tcb);
#endif
/********************************************************************************
* Name: up_critmon_*
*
* Description:
* The first interface simply provides the current time value in unknown
* units. NOTE: This function may be called early before the timer has
* been initialized. In that event, the function should just return a
* start time of zero.
*
* Nothing is assumed about the units of this time value. The following
* are assumed, however: (1) The time is an unsigned integer value, (2)
* the time is monotonically increasing, and (3) the elapsed time (also
* in unknown units) can be obtained by subtracting a start time from
* the current time.
*
* The second interface simple converts an elapsed time into well known
* units.
********************************************************************************/
#ifdef CONFIG_SCHED_CRITMONITOR
uint32_t up_critmon_gettime(void);
void up_critmon_convert(uint32_t elapsed, FAR struct timespec *ts);
#endif
#undef EXTERN
#if defined(__cplusplus)
}

View file

@ -724,38 +724,6 @@ config SCHED_IRQMONITOR
counts will be available in the mounted procfs file systems at the
top-level file, "irqs".
config SCHED_IRQMONITOR_GETTIME
bool "Custom Platform-specific Timer"
default n
depends on SCHED_IRQMONITOR && SCHED_TICKLESS && !SCHED_CRITMONITOR
---help---
If CONFIG_SCHED_TICKLESS is enabled, then the high resolution
Tickless timer will be used by default. Otherwise, a platform-
specific timer is expected (the same timer used with the Critical
Section Monitor). The option will force use of that platform-
specifier timer even the CONFIG_SCHED_TICKLESs is defined.
if CONFIG_SCHED_TICKLESS is not enabled or CONFIG_SCHED_IRQMONITOR_GETTIME
is selected, then platform-specific logic must provide the following in
order to support high resolution timing:
uint32_t up_critmon_gettime(void);
void up_critmon_convert(uint32_t elapsed, FAR struct timespec *ts);
The first interface simply provides the current time value in unknown
units. NOTE: This function may be called early before the timer has
been initialized. In that event, the function should just return a
start time of zero.
Nothing is assumed about the units of this time value. The following
are assumed, however: (1) The time is an unsigned integer value, (2)
the time is monotonically increasing, and (3) the elapsed time (also
in unknown units) can be obtained by subtracting a start time from
the current time.
The second interface simple converts an elapsed time into well known
units for presentation by the ProcFS file system.
config SCHED_CRITMONITOR
bool "Enable Critical Section monitoring"
default n

View file

@ -54,43 +54,35 @@
/* INCR_COUNT - Increment the count of interrupts taken on this IRQ number */
#ifdef CONFIG_SCHED_IRQMONITOR
# ifdef CONFIG_HAVE_LONG_LONG
# define INCR_COUNT(ndx) \
do \
{ \
g_irqvector[ndx].count++; \
} \
while (0)
# else
# define INCR_COUNT(ndx) \
do \
{ \
if (++g_irqvector[ndx].lscount == 0) \
{ \
g_irqvector[ndx].mscount++; \
} \
} \
while (0)
# endif
#else
#ifndef CONFIG_SCHED_IRQMONITOR
# define INCR_COUNT(ndx)
#elif defined(CONFIG_HAVE_LONG_LONG)
# define INCR_COUNT(ndx) \
do \
{ \
g_irqvector[ndx].count++; \
} \
while (0)
#else
# define INCR_COUNT(ndx) \
do \
{ \
if (++g_irqvector[ndx].lscount == 0) \
{ \
g_irqvector[ndx].mscount++; \
} \
} \
while (0)
#endif
/* CALL_VECTOR - Call the interrupt service routine attached to this interrupt
* request
*/
#undef HAVE_PLATFORM_GETTIME
#if defined(CONFIG_SCHED_IRQMONITOR) && \
(!defined(CONFIG_SCHED_TICKLESS) || \
defined(CONFIG_SCHED_CRITMONITOR) || \
defined(CONFIG_SCHED_IRQMONITOR_GETTIME))
# define HAVE_PLATFORM_GETTIME 1
#endif
#ifdef CONFIG_SCHED_IRQMONITOR
#ifdef HAVE_PLATFORM_GETTIME
#ifndef CONFIG_SCHED_IRQMONITOR
# define CALL_VECTOR(ndx, vector, irq, context, arg) \
vector(irq, context, arg)
#elif defined(CONFIG_SCHED_CRITMONITOR)
# define CALL_VECTOR(ndx, vector, irq, context, arg) \
do \
{ \
@ -124,41 +116,8 @@
} \
} \
while (0)
#endif /* HAVE_PLATFORM_GETTIME */
#else
# define CALL_VECTOR(ndx, vector, irq, context, arg) \
vector(irq, context, arg)
#endif /* CONFIG_SCHED_IRQMONITOR */
/****************************************************************************
* External Function Prototypes
****************************************************************************/
#ifdef HAVE_PLATFORM_GETTIME
/* If CONFIG_SCHED_TICKLESS is enabled, then the high resolution Tickless
* timer will be used. Otherwise, the platform specific logic must provide
* the following in order to support high resolution timing:
*/
uint32_t up_critmon_gettime(void);
void up_critmon_convert(uint32_t elapsed, FAR struct timespec *ts);
/* The first interface simply provides the current time value in unknown
* units. NOTE: This function may be called early before the timer has
* been initialized. In that event, the function should just return a
* start time of zero.
*
* Nothing is assumed about the units of this time value. The following
* are assumed, however: (1) The time is an unsigned integer value, (2)
* the time is monotonically increasing, and (3) the elapsed time (also
* in unknown units) can be obtained by subtracting a start time from
* the current time.
*
* The second interface simple converts an elapsed time into well known
* units.
*/
#endif /* HAVE_PLATFORM_GETTIME */
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -46,25 +46,6 @@
#ifdef CONFIG_SCHED_CRITMONITOR
/****************************************************************************
* External Function Prototypes
****************************************************************************/
/* If CONFIG_SCHED_CRITMONITOR is selected, then platform-specific logic
* must provide the following interface. This interface simply provides the
* current time value in unknown units. NOTE: This function may be called
* early before the timer has been initialized. In that event, the function
* should just return a start time of zero.
*
* Nothing is assumed about the units of this time value. The following
* are assumed, however: (1) The time is an unsigned is an unsigned integer
* value, (2) is is monotonically increasing, and (3) the elapsed time
* (also in unknown units) can be obtained by subtracting a start time
* from the current time.
*/
uint32_t up_critmon_gettime(void);
/************************************************************************************
* Private Data
************************************************************************************/