sched: Simplify the cpuload process

1.Forward nxsched_process_cpuload to nxsched_process_cpuload_ticks directly
2.Define the dummy nxsched_process_cpuload_ticks when CPULOAD isn't enabled
3.Remove the weak attribute from nxsched_process_cpuload_ticks

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-08-17 02:15:45 +08:00 committed by Petro Karashchenko
parent 95d91ef906
commit 27e8d058e7
8 changed files with 17 additions and 85 deletions

View File

@ -2231,31 +2231,6 @@ void nxsched_timer_expiration(void);
void nxsched_alarm_expiration(FAR const struct timespec *ts); void nxsched_alarm_expiration(FAR const struct timespec *ts);
#endif #endif
/****************************************************************************
* Name: nxsched_process_cpuload
*
* Description:
* Collect data that can be used for CPU load measurements. When
* CONFIG_SCHED_CPULOAD_EXTCLK is defined, this is an exported interface,
* use the the external clock logic. Otherwise, it is an OS internal
* interface.
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
* Assumptions/Limitations:
* This function is called from a timer interrupt handler with all
* interrupts disabled.
*
****************************************************************************/
#if defined(CONFIG_SCHED_CPULOAD) && defined(CONFIG_SCHED_CPULOAD_EXTCLK)
void weak_function nxsched_process_cpuload(void);
#endif
/**************************************************************************** /****************************************************************************
* Name: nxsched_process_cpuload_ticks * Name: nxsched_process_cpuload_ticks
* *
@ -2278,7 +2253,8 @@ void weak_function nxsched_process_cpuload(void);
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_SCHED_CPULOAD) && defined(CONFIG_SCHED_CPULOAD_EXTCLK) #if defined(CONFIG_SCHED_CPULOAD) && defined(CONFIG_SCHED_CPULOAD_EXTCLK)
void weak_function nxsched_process_cpuload_ticks(uint32_t ticks); void nxsched_process_cpuload_ticks(uint32_t ticks);
# define nxsched_process_cpuload() nxsched_process_cpuload_ticks(1)
#endif #endif
/**************************************************************************** /****************************************************************************

View File

@ -821,7 +821,7 @@ config SCHED_CPULOAD_EXTCLK
achieved. This option enables use of such an "external" clock. The achieved. This option enables use of such an "external" clock. The
implementation of the clock must be provided by platform-specific implementation of the clock must be provided by platform-specific
logic; that platform-specific logic must call the system function logic; that platform-specific logic must call the system function
nxsched_process_cpuload() at each timer expiration with interrupts nxsched_process_cpuload_ticks() at each timer expiration with interrupts
disabled. disabled.
if SCHED_CPULOAD_EXTCLK if SCHED_CPULOAD_EXTCLK

View File

@ -386,11 +386,17 @@ int nxsched_pause_cpu(FAR struct tcb_s *tcb);
# define nxsched_islocked_tcb(tcb) ((tcb)->lockcount > 0) # define nxsched_islocked_tcb(tcb) ((tcb)->lockcount > 0)
#endif #endif
#if defined(CONFIG_SCHED_CPULOAD) && !defined(CONFIG_SCHED_CPULOAD_EXTCLK) #ifndef CONFIG_SCHED_CPULOAD_EXTCLK
/* CPU load measurement support */ /* CPU load measurement support */
void weak_function nxsched_process_cpuload(void); # ifdef CONFIG_SCHED_CPULOAD
void weak_function nxsched_process_cpuload_ticks(uint32_t ticks); void nxsched_process_cpuload_ticks(uint32_t ticks);
# else
# define nxsched_process_cpuload_ticks(ticks)
# endif
# define nxsched_process_cpuload() nxsched_process_cpuload_ticks(1)
#endif #endif
/* Critical section monitor */ /* Critical section monitor */

View File

@ -122,32 +122,6 @@ static inline void nxsched_cpu_process_cpuload(int cpu, uint32_t ticks)
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Name: nxsched_process_cpuload
*
* Description:
* Collect data that can be used for CPU load measurements. When
* CONFIG_SCHED_CPULOAD_EXTCLK is defined, this is an exported interface,
* use the the external clock logic. Otherwise, it is an OS Internal
* interface.
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
* Assumptions/Limitations:
* This function is called from a timer interrupt handler with all
* interrupts disabled.
*
****************************************************************************/
void weak_function nxsched_process_cpuload(void)
{
nxsched_process_cpuload_ticks(1);
}
/**************************************************************************** /****************************************************************************
* Name: nxsched_process_cpuload_ticks * Name: nxsched_process_cpuload_ticks
* *
@ -169,7 +143,7 @@ void weak_function nxsched_process_cpuload(void)
* *
****************************************************************************/ ****************************************************************************/
void weak_function nxsched_process_cpuload_ticks(uint32_t ticks) void nxsched_process_cpuload_ticks(uint32_t ticks)
{ {
int i; int i;
irqstate_t flags; irqstate_t flags;

View File

@ -226,12 +226,7 @@ static void nxsched_oneshot_callback(FAR struct oneshot_lowerhalf_s *lower,
{ {
/* Perform CPU load measurements */ /* Perform CPU load measurements */
#ifdef CONFIG_HAVE_WEAKFUNCTIONS nxsched_process_cpuload();
if (nxsched_process_cpuload != NULL)
#endif
{
nxsched_process_cpuload();
}
/* Then restart the oneshot */ /* Then restart the oneshot */

View File

@ -187,12 +187,7 @@ static bool nxsched_period_callback(FAR uint32_t *next_interval_us,
/* Perform CPU load measurements */ /* Perform CPU load measurements */
#ifdef CONFIG_HAVE_WEAKFUNCTIONS nxsched_process_cpuload();
if (nxsched_process_cpuload != NULL)
#endif
{
nxsched_process_cpuload();
}
/* Then continue the timing */ /* Then continue the timing */

View File

@ -225,18 +225,11 @@ void nxsched_process_timer(void)
clock_timer(); clock_timer();
} }
#if defined(CONFIG_SCHED_CPULOAD) && !defined(CONFIG_SCHED_CPULOAD_EXTCLK)
/* Perform CPU load measurements (before any timer-initiated context /* Perform CPU load measurements (before any timer-initiated context
* switches can occur) * switches can occur)
*/ */
#ifdef CONFIG_HAVE_WEAKFUNCTIONS nxsched_process_cpuload();
if (nxsched_process_cpuload != NULL)
#endif
{
nxsched_process_cpuload();
}
#endif
/* Check if the currently executing task has exceeded its /* Check if the currently executing task has exceeded its
* timeslice. * timeslice.

View File

@ -382,18 +382,11 @@ static unsigned int nxsched_timer_process(unsigned int ticks,
clock_update_wall_time(); clock_update_wall_time();
#endif #endif
#if defined(CONFIG_SCHED_CPULOAD) && !defined(CONFIG_SCHED_CPULOAD_EXTCLK)
/* Perform CPU load measurements (before any timer-initiated context /* Perform CPU load measurements (before any timer-initiated context
* switches can occur) * switches can occur)
*/ */
#ifdef CONFIG_HAVE_WEAKFUNCTIONS nxsched_process_cpuload_ticks(ticks);
if (nxsched_process_cpuload_ticks != NULL)
#endif
{
nxsched_process_cpuload_ticks(ticks);
}
#endif
/* Process watchdogs */ /* Process watchdogs */