cpuload: nxsched_cpu_process_cpuload: add ticks parameter

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
This commit is contained in:
zhuyanlin 2022-04-22 17:10:18 +08:00 committed by Xiang Xiao
parent 45fe3fb4c6
commit 6facf18a01
2 changed files with 58 additions and 6 deletions

View File

@ -1863,7 +1863,7 @@ int up_timer_start(FAR const struct timespec *ts);
#ifdef CONFIG_SCHED_THREAD_LOCAL
int up_tls_size(void);
#else
#define up_tls_size() sizeof(struct tls_info_s)
#define up_tls_size() sizeof(struct tls_info_s)
#endif
/****************************************************************************
@ -2303,6 +2303,31 @@ void nxsched_alarm_expiration(FAR const struct timespec *ts);
void weak_function nxsched_process_cpuload(void);
#endif
/****************************************************************************
* Name: nxsched_process_cpuload_ticks
*
* 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:
* ticks - The ticks that we increment in this cpuload
*
* 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_ticks(uint32_t ticks);
#endif
/****************************************************************************
* Name: irq_dispatch
*

View File

@ -91,7 +91,8 @@ volatile uint32_t g_cpuload_total;
* Collect data that can be used for CPU load measurements.
*
* Input Parameters:
* cpu - The CPU that we are performing the load operations on.
* cpu - The CPU that we are performing the load operations on.
* ticks - The ticks that we process in this cpuload.
*
* Returned Value:
* None
@ -102,19 +103,19 @@ volatile uint32_t g_cpuload_total;
*
****************************************************************************/
static inline void nxsched_cpu_process_cpuload(int cpu)
static inline void nxsched_cpu_process_cpuload(int cpu, uint32_t ticks)
{
FAR struct tcb_s *rtcb = current_task(cpu);
/* Increment the count on the currently executing thread */
rtcb->ticks++;
rtcb->ticks += ticks;
/* Increment tick count. NOTE that the count is increment once for each
* CPU on each sample interval.
*/
g_cpuload_total++;
g_cpuload_total += ticks;
}
/****************************************************************************
@ -143,6 +144,32 @@ static inline void nxsched_cpu_process_cpuload(int cpu)
****************************************************************************/
void weak_function nxsched_process_cpuload(void)
{
nxsched_process_cpuload_ticks(1);
}
/****************************************************************************
* Name: nxsched_process_cpuload_ticks
*
* 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:
* ticks - The ticks that we increment in this cpuload
*
* Returned Value:
* None
*
* Assumptions/Limitations:
* This function is called from a timer interrupt handler with all
* interrupts disabled.
*
****************************************************************************/
void weak_function nxsched_process_cpuload_ticks(uint32_t ticks)
{
int i;
irqstate_t flags;
@ -153,7 +180,7 @@ void weak_function nxsched_process_cpuload(void)
for (i = 0; i < CONFIG_SMP_NCPUS; i++)
{
nxsched_cpu_process_cpuload(i);
nxsched_cpu_process_cpuload(i, ticks);
}
/* If the accumulated tick value exceed a time constant, then shift the