mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
sched: explicitly select the cpuload clock source configuration
Different configurations require different dependencies. Explicitly select dependencies to avoid automatically selecting inappropriate configurations. Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
+12
-13
@@ -914,9 +914,9 @@ config SCHED_CRITMONITOR_MAXTIME_PANIC
|
||||
If this option is enabled, a panic will be triggered when
|
||||
IRQ/WQUEUE/PREEMPTION execution time exceeds SCHED_CRITMONITOR_MAXTIME_xxx
|
||||
|
||||
config SCHED_CPULOAD
|
||||
bool "Enable CPU load monitoring"
|
||||
default n
|
||||
choice
|
||||
prompt "Select CPU load clock source"
|
||||
default SCHED_CPULOAD_NONE
|
||||
---help---
|
||||
If this option is selected, the timer interrupt handler will monitor
|
||||
if the system is IDLE or busy at the time of that the timer interrupt
|
||||
@@ -932,12 +932,11 @@ config SCHED_CPULOAD
|
||||
possible unless you provide an alternative clock to drive the
|
||||
sampling and select SCHED_CPULOAD_EXTCLK.
|
||||
|
||||
if SCHED_CPULOAD
|
||||
|
||||
choice
|
||||
prompt "Select CPU load clock source"
|
||||
default SCHED_CPULOAD_EXTCLK if SCHED_TICKLESS
|
||||
default SCHED_CPULOAD_CRITMONITOR if SCHED_CRITMONITOR
|
||||
config SCHED_CPULOAD_NONE
|
||||
bool "None CPU load clock source"
|
||||
---help---
|
||||
If this option is enabled, the system will not support CPU load
|
||||
measurement.
|
||||
|
||||
config SCHED_CPULOAD_SYSCLK
|
||||
bool "Use system clock"
|
||||
@@ -955,8 +954,9 @@ config SCHED_CPULOAD_SYSCLK
|
||||
the CPU load attributed to these threads that run synchronously with
|
||||
they system timer may be grossly in error.
|
||||
The CPU load measurements are determined by sampling the active
|
||||
tasks periodically at the occurrence to a timer expiration. By
|
||||
default, the system clock is used to do that sampling.
|
||||
tasks periodically at the occurrence to a timer expiration.
|
||||
If tickless is enabled, SYSCLK should not be used. Its error will be
|
||||
very large, and using it for analysis will lead to wrong conclusions.
|
||||
|
||||
config SCHED_CPULOAD_EXTCLK
|
||||
bool "Use external clock"
|
||||
@@ -1068,14 +1068,13 @@ endif # SCHED_CPULOAD_EXTCLK
|
||||
|
||||
config SCHED_CPULOAD_TIMECONSTANT
|
||||
int "CPU load time constant"
|
||||
depends on !SCHED_CPULOAD_NONE
|
||||
default 2
|
||||
---help---
|
||||
The accumulated CPU count is divided by two when the accumulated
|
||||
tick count exceeds this time constant. This time constant is in
|
||||
units of seconds.
|
||||
|
||||
endif # SCHED_CPULOAD
|
||||
|
||||
menuconfig SCHED_INSTRUMENTATION
|
||||
bool "System performance monitor hooks"
|
||||
default n
|
||||
|
||||
+5
-5
@@ -297,7 +297,7 @@ static void dump_task(FAR struct tcb_s *tcb, FAR void *arg)
|
||||
size_t stack_filled = 0;
|
||||
size_t stack_used;
|
||||
#endif
|
||||
#ifdef CONFIG_SCHED_CPULOAD
|
||||
#ifndef CONFIG_SCHED_CPULOAD_NONE
|
||||
struct cpuload_s cpuload;
|
||||
size_t fracpart = 0;
|
||||
size_t intpart = 0;
|
||||
@@ -349,7 +349,7 @@ static void dump_task(FAR struct tcb_s *tcb, FAR void *arg)
|
||||
#ifdef CONFIG_STACK_COLORATION
|
||||
" %7zu %3zu.%1zu%%%c"
|
||||
#endif
|
||||
#ifdef CONFIG_SCHED_CPULOAD
|
||||
#ifndef CONFIG_SCHED_CPULOAD_NONE
|
||||
" %3zu.%01zu%%"
|
||||
#endif
|
||||
" %s%s\n"
|
||||
@@ -375,7 +375,7 @@ static void dump_task(FAR struct tcb_s *tcb, FAR void *arg)
|
||||
, stack_filled / 10, stack_filled % 10
|
||||
, (stack_filled >= 10 * 80 ? '!' : ' ')
|
||||
#endif
|
||||
#ifdef CONFIG_SCHED_CPULOAD
|
||||
#ifndef CONFIG_SCHED_CPULOAD_NONE
|
||||
, intpart, fracpart
|
||||
#endif
|
||||
#if CONFIG_TASK_NAME_SIZE > 0
|
||||
@@ -431,7 +431,7 @@ static void dump_tasks(void)
|
||||
#ifdef CONFIG_STACK_COLORATION
|
||||
" USED FILLED "
|
||||
#endif
|
||||
#ifdef CONFIG_SCHED_CPULOAD
|
||||
#ifndef CONFIG_SCHED_CPULOAD_NONE
|
||||
" CPU"
|
||||
#endif
|
||||
" COMMAND\n");
|
||||
@@ -450,7 +450,7 @@ static void dump_tasks(void)
|
||||
# ifdef CONFIG_STACK_COLORATION
|
||||
" %7zu %3zu.%1zu%%%c"
|
||||
# endif
|
||||
# ifdef CONFIG_SCHED_CPULOAD
|
||||
# ifndef CONFIG_SCHED_CPULOAD_NONE
|
||||
" ----"
|
||||
# endif
|
||||
" irq\n"
|
||||
|
||||
@@ -91,7 +91,7 @@ elseif(CONFIG_SCHED_RESUMESCHEDULER)
|
||||
list(APPEND SRCS sched_resumescheduler.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_CPULOAD)
|
||||
if(NOT CONFIG_SCHED_CPULOAD_NONE)
|
||||
list(APPEND SRCS sched_cpuload.c)
|
||||
if(CONFIG_CPULOAD_ONESHOT)
|
||||
list(APPEND SRCS sched_cpuload_oneshot.c)
|
||||
|
||||
@@ -68,7 +68,7 @@ else ifeq ($(CONFIG_SCHED_RESUMESCHEDULER),y)
|
||||
CSRCS += sched_resumescheduler.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SCHED_CPULOAD),y)
|
||||
ifneq ($(CONFIG_SCHED_CPULOAD_NONE),y)
|
||||
CSRCS += sched_cpuload.c
|
||||
ifeq ($(CONFIG_CPULOAD_ONESHOT),y)
|
||||
CSRCS += sched_cpuload_oneshot.c
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ extern volatile int g_npidhash;
|
||||
|
||||
extern const struct tasklist_s g_tasklisttable[NUM_TASK_STATES];
|
||||
|
||||
#ifdef CONFIG_SCHED_CPULOAD
|
||||
#ifndef CONFIG_SCHED_CPULOAD_NONE
|
||||
/* This is the total number of clock tick counts. Essentially the
|
||||
* 'denominator' for all CPU load calculations.
|
||||
*/
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
||||
#ifdef CONFIG_SCHED_CPULOAD
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
@@ -227,5 +225,3 @@ int clock_cpuload(int pid, FAR struct cpuload_s *cpuload)
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SCHED_CPULOAD */
|
||||
|
||||
@@ -44,10 +44,6 @@
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#if !defined(CONFIG_SCHED_CPULOAD) || !defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
# error CONFIG_SCHED_CPULOAD and CONFIG_SCHED_CPULOAD_EXTCLK must be defined
|
||||
#endif
|
||||
|
||||
/* CONFIG_SCHED_CPULOAD_TICKSPERSEC is the frequency of the external clock
|
||||
* source.
|
||||
*/
|
||||
|
||||
@@ -41,10 +41,6 @@
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#if !defined(CONFIG_SCHED_CPULOAD) || !defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
# error CONFIG_SCHED_CPULOAD and CONFIG_SCHED_CPULOAD_EXTCLK must be defined
|
||||
#endif
|
||||
|
||||
/* CONFIG_SCHED_CPULOAD_TICKSPERSEC is the frequency of the external clock
|
||||
* source.
|
||||
*/
|
||||
|
||||
@@ -51,7 +51,7 @@ static void nxsched_releasepid(pid_t pid)
|
||||
irqstate_t flags = enter_critical_section();
|
||||
int hash_ndx = PIDHASH(pid);
|
||||
|
||||
#ifdef CONFIG_SCHED_CPULOAD
|
||||
#ifndef CONFIG_SCHED_CPULOAD_NONE
|
||||
/* Decrement the total CPU load count held by this thread from the
|
||||
* total for all threads.
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
int sysinfo(FAR struct sysinfo *info)
|
||||
{
|
||||
#ifdef CONFIG_SCHED_CPULOAD
|
||||
#ifndef CONFIG_SCHED_CPULOAD_NONE
|
||||
struct cpuload_s cpuload;
|
||||
#endif
|
||||
#ifdef CONFIG_MM_PGALLOC
|
||||
@@ -62,7 +62,7 @@ int sysinfo(FAR struct sysinfo *info)
|
||||
|
||||
memset(info, 0, sizeof(*info));
|
||||
|
||||
#ifdef CONFIG_SCHED_CPULOAD
|
||||
#ifndef CONFIG_SCHED_CPULOAD_NONE
|
||||
clock_cpuload(0, &cpuload);
|
||||
|
||||
/* On the simulator, you may hit cpuload.total == 0, but probably never
|
||||
|
||||
Reference in New Issue
Block a user