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:
yinshengkai 2023-10-26 21:03:16 +08:00 committed by Xiang Xiao
parent e0c883f487
commit d0a5489ac5
29 changed files with 52 additions and 64 deletions

View File

@ -32,7 +32,7 @@ CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_RAM_SIZE=536870912
CONFIG_RAM_START=0x20200000
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_START_DAY=14
CONFIG_START_MONTH=3
CONFIG_SYSTEM_NSH=y

View File

@ -32,7 +32,7 @@ CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_RAM_SIZE=1048576
CONFIG_RAM_START=0x20200000
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_START_DAY=14
CONFIG_START_MONTH=3
CONFIG_SYSTEM_NSH=y

View File

@ -32,7 +32,7 @@ CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_RAM_SIZE=1048576
CONFIG_RAM_START=0x20200000
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_START_DAY=14
CONFIG_START_MONTH=3
CONFIG_SYSTEM_NSH=y

View File

@ -143,7 +143,6 @@ CONFIG_RAM_SIZE=1048576
CONFIG_RAM_START=0x20200000
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=10
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_TICKLESS=y
CONFIG_SCHED_TICKLESS_ALARM=y

View File

@ -138,7 +138,7 @@ CONFIG_PTHREAD_STACK_MIN=1024
CONFIG_RAM_SIZE=65536
CONFIG_RAM_START=0x10000000
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKPRIORITY=192
CONFIG_SCHED_IRQMONITOR=y

View File

@ -18,7 +18,7 @@ config SAM4S_XPLAINED_PRO_SCHED_TIMER_DEVPATH
config SAM4S_XPLAINED_PRO_CPULOAD_TIMER_DEVPATH
string "CPU Load Timer Device Path"
default "/dev/tc0"
depends on TIMER && SCHED_CPULOAD && SCHED_CPULOAD_EXTCLK
depends on TIMER && SCHED_CPULOAD_EXTCLK
config SAM34_NAND_BLOCKMOUNT
bool "NAND FLASH auto-mount"

View File

@ -50,7 +50,7 @@ CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_RR_INTERVAL=100
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKPRIORITY=192
CONFIG_SCHED_HPWORKSTACKSIZE=1024

View File

@ -63,7 +63,7 @@ CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_RR_INTERVAL=100
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKPRIORITY=192
CONFIG_SCHED_HPWORKSTACKSIZE=1024

View File

@ -49,7 +49,7 @@ CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_RR_INTERVAL=100
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKPRIORITY=192
CONFIG_SCHED_HPWORKSTACKSIZE=1024

View File

@ -50,7 +50,7 @@ CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_RR_INTERVAL=100
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKPRIORITY=192
CONFIG_SCHED_HPWORKSTACKSIZE=1024

View File

@ -88,7 +88,7 @@ CONFIG_RAW_BINARY=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKSTACKSIZE=2048
CONFIG_SCHED_IRQMONITOR=y

View File

@ -65,7 +65,7 @@ CONFIG_RAM_SIZE=134217728
CONFIG_RAM_START=0xc0800000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_SYSCLK=y
CONFIG_SCHED_WAITPID=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=20

View File

@ -213,7 +213,7 @@ static void addentropy(FAR const uint32_t *buf, size_t n, bool inc_new)
static void initentropy(FAR blake2s_state *S)
{
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
struct cpuload_s load;
#endif
uint32_t tmp;
@ -231,7 +231,7 @@ static void initentropy(FAR blake2s_state *S)
tmp = sizeof(entropy_pool.pool);
tmp <<= 27;
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
clock_cpuload(0, &load);
tmp += load.total ^ ROTL_32(load.active, 23);
#endif

View File

@ -45,7 +45,7 @@ config FS_PROCFS_EXCLUDE_CPUINFO
config FS_PROCFS_EXCLUDE_CPULOAD
bool "Exclude CPU load"
depends on SCHED_CPULOAD
depends on !SCHED_CPULOAD_NONE
default DEFAULT_SMALL
config FS_PROCFS_EXCLUDE_ENVIRON

View File

@ -106,7 +106,8 @@ static const struct procfs_entry_s g_procfs_entries[] =
{ "cpuinfo", &g_cpuinfo_operations, PROCFS_FILE_TYPE },
#endif
#if defined(CONFIG_SCHED_CPULOAD) && !defined(CONFIG_FS_PROCFS_EXCLUDE_CPULOAD)
#if !defined(CONFIG_SCHED_CPULOAD_NONE) && \
!defined(CONFIG_FS_PROCFS_EXCLUDE_CPULOAD)
{ "cpuload", &g_cpuload_operations, PROCFS_FILE_TYPE },
#endif

View File

@ -45,7 +45,8 @@
#include <nuttx/fs/procfs.h>
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS)
#if defined(CONFIG_SCHED_CPULOAD) && !defined(CONFIG_FS_PROCFS_EXCLUDE_CPULOAD)
#if !defined(CONFIG_SCHED_CPULOAD_NONE) && \
!defined(CONFIG_FS_PROCFS_EXCLUDE_CPULOAD)
/****************************************************************************
* Pre-processor Definitions

View File

@ -54,7 +54,7 @@
#include <nuttx/fs/ioctl.h>
#include <nuttx/mm/mm.h>
#if defined(CONFIG_SCHED_CPULOAD) || defined(CONFIG_SCHED_CRITMONITOR)
#if !defined(CONFIG_SCHED_CPULOAD_NONE) || defined(CONFIG_SCHED_CRITMONITOR)
# include <nuttx/clock.h>
#endif
@ -84,7 +84,7 @@ enum proc_node_e
PROC_LEVEL0 = 0, /* The top-level directory */
PROC_STATUS, /* Task/thread status */
PROC_CMDLINE, /* Task command line */
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
PROC_LOADAVG, /* Average CPU utilization */
#endif
#ifdef CONFIG_SCHED_CRITMONITOR
@ -171,7 +171,7 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile,
static ssize_t proc_cmdline(FAR struct proc_file_s *procfile,
FAR struct tcb_s *tcb, FAR char *buffer, size_t buflen,
off_t offset);
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
static ssize_t proc_loadavg(FAR struct proc_file_s *procfile,
FAR struct tcb_s *tcb, FAR char *buffer, size_t buflen,
off_t offset);
@ -278,7 +278,7 @@ static const struct proc_node_s g_cmdline =
"cmdline", "cmdline", (uint8_t)PROC_CMDLINE, DTYPE_FILE /* Task command line */
};
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
static const struct proc_node_s g_loadavg =
{
"loadavg", "loadavg", (uint8_t)PROC_LOADAVG, DTYPE_FILE /* Average CPU utilization */
@ -340,7 +340,7 @@ static FAR const struct proc_node_s * const g_nodeinfo[] =
{
&g_status, /* Task/thread status */
&g_cmdline, /* Task command line */
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
&g_loadavg, /* Average CPU utilization */
#endif
#ifdef CONFIG_SCHED_CRITMONITOR
@ -369,7 +369,7 @@ static const struct proc_node_s * const g_level0info[] =
{
&g_status, /* Task/thread status */
&g_cmdline, /* Task command line */
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
&g_loadavg, /* Average CPU utilization */
#endif
#ifdef CONFIG_SCHED_CRITMONITOR
@ -706,7 +706,7 @@ static ssize_t proc_cmdline(FAR struct proc_file_s *procfile,
* Name: proc_loadavg
****************************************************************************/
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
static ssize_t proc_loadavg(FAR struct proc_file_s *procfile,
FAR struct tcb_s *tcb, FAR char *buffer,
size_t buflen, off_t offset)
@ -1521,7 +1521,7 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
ret = proc_cmdline(procfile, tcb, buffer, buflen, filep->f_pos);
break;
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
case PROC_LOADAVG: /* Average CPU utilization */
ret = proc_loadavg(procfile, tcb, buffer, buflen, filep->f_pos);
break;

View File

@ -274,7 +274,7 @@
/* This structure is used to report CPU usage for a particular thread */
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
struct cpuload_s
{
volatile uint32_t total; /* Total number of clock ticks */
@ -615,7 +615,7 @@ int clock_systime_timespec(FAR struct timespec *ts);
*
****************************************************************************/
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
int clock_cpuload(int pid, FAR struct cpuload_s *cpuload);
#endif

View File

@ -625,7 +625,7 @@ struct tcb_s
/* CPU load monitoring support ********************************************/
#ifdef CONFIG_SCHED_CPULOAD
#ifndef CONFIG_SCHED_CPULOAD_NONE
uint32_t ticks; /* Number of ticks on this thread */
#endif

View File

@ -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

View File

@ -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"

View File

@ -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)

View File

@ -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

View File

@ -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.
*/

View File

@ -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 */

View File

@ -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.
*/

View File

@ -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.
*/

View File

@ -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.
*/

View File

@ -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