From 4ca7b72a986e7ea9054d7033b33c2fb3c9137e08 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 25 Nov 2018 11:50:15 -0600 Subject: [PATCH] sched/Kconfig: Simplify some configurations. This adds configuration settings that control individual features, rather than long complex OR expressions that determines if an individual feature is required. --- include/nuttx/sched.h | 10 +++------- sched/Kconfig | 22 ++++++++++++++++++++++ sched/irq/Make.defs | 6 +++--- sched/irq/irq_csection.c | 14 ++++++-------- sched/sched/Make.defs | 16 +++++----------- sched/sched/sched_resumescheduler.c | 8 ++------ sched/sched/sched_suspendscheduler.c | 6 ++---- 7 files changed, 43 insertions(+), 39 deletions(-) diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 936845d633..c69385be9c 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -637,8 +637,7 @@ struct tcb_s #endif uint16_t flags; /* Misc. general status flags */ int16_t lockcount; /* 0=preemptable (not-locked) */ -#if defined(CONFIG_SMP) || defined(CONFIG_SCHED_CRITMONITOR) || \ - defined(CONFIG_SCHED_INSTRUMENTATION_CSECTION) +#ifdef CONFIG_IRQCOUNT int16_t irqcount; /* 0=Not in critical section */ #endif #ifdef CONFIG_CANCELLATION_POINTS @@ -952,9 +951,7 @@ int group_exitinfo(pid_t pid, FAR struct binary_s *bininfo); * ********************************************************************************/ -#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC) || \ - defined(CONFIG_SCHED_INSTRUMENTATION) || defined(CONFIG_SCHED_CRITMONITOR) || \ - defined(CONFIG_SMP) +#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_RESUMESCHEDULER) void sched_resume_scheduler(FAR struct tcb_s *tcb); #else # define sched_resume_scheduler(tcb) @@ -976,8 +973,7 @@ void sched_resume_scheduler(FAR struct tcb_s *tcb); * ********************************************************************************/ -#if defined(CONFIG_SCHED_SPORADIC) || defined(CONFIG_SCHED_INSTRUMENTATION) || \ - defined(CONFIG_SCHED_CRITMONITOR) +#ifdef CONFIG_SCHED_SUSPENDSCHEDULER void sched_suspend_scheduler(FAR struct tcb_s *tcb); #else # define sched_suspend_scheduler(tcb) diff --git a/sched/Kconfig b/sched/Kconfig index 09750740fa..568648d207 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -276,11 +276,17 @@ config PREALLOC_IRQCHAIN endif # IRQCHAIN +config IRQCOUNT + bool + default n + config SMP bool "Symmetric Multi-Processing (SMP)" default n depends on ARCH_HAVE_MULTICPU select SPINLOCK + select SCHED_RESUMESCHEDULER + select IRQCOUNT ---help--- Enables support for Symmetric Multi-Processing (SMP) on a multi-CPU platform. @@ -429,6 +435,8 @@ config RR_INTERVAL config SCHED_SPORADIC bool "Support sporadic scheduling" default n + select SCHED_SUSPENDSCHEDULER + select SCHED_RESUMESCHEDULER ---help--- Build in additional logic to support sporadic scheduling (SCHED_SPORADIC). @@ -691,6 +699,14 @@ endmenu # Pthread Options menu "Performance Monitoring" +config SCHED_SUSPENDSCHEDULER + bool + default n + +config SCHED_RESUMESCHEDULER + bool + default n + config SCHED_IRQMONITOR bool "Enable IRQ monitoring" default n @@ -704,6 +720,9 @@ config SCHED_CRITMONITOR bool "Enable Critical Section monitoring" default n depends on FS_PROCFS + select SCHED_SUSPENDSCHEDULER + select SCHED_RESUMESCHEDULER + select IRQCOUNT ---help--- Enables logic that monitors the duration of time that a thread keeps interrupts or pre-emption disabled. These global locks can have @@ -870,6 +889,9 @@ endif # SCHED_CPULOAD config SCHED_INSTRUMENTATION bool "System performance monitor hooks" default n + select SCHED_SUSPENDSCHEDULER + select SCHED_RESUMESCHEDULER + select IRQCOUNT ---help--- Enables instrumentation in scheduler to monitor system performance. If enabled, then the board-specific logic must provide the following diff --git a/sched/irq/Make.defs b/sched/irq/Make.defs index 18c2ad11f5..ad32fb1601 100644 --- a/sched/irq/Make.defs +++ b/sched/irq/Make.defs @@ -42,9 +42,9 @@ ifeq ($(CONFIG_ARCH_GLOBAL_IRQDISABLE),y) CSRCS += irq_spinlock.c endif endif -else ifeq ($(CONFIG_SCHED_INSTRUMENTATION_CSECTION),y) -CSRCS += irq_csection.c -else ifeq ($(CONFIG_SCHED_CRITMONITOR),y) +endif + +ifeq ($(CONFIG_IRQCOUNT),y) CSRCS += irq_csection.c endif diff --git a/sched/irq/irq_csection.c b/sched/irq/irq_csection.c index 45577aefdc..690f56c289 100644 --- a/sched/irq/irq_csection.c +++ b/sched/irq/irq_csection.c @@ -49,8 +49,7 @@ #include "sched/sched.h" #include "irq/irq.h" -#if defined(CONFIG_SMP) || defined(CONFIG_SCHED_INSTRUMENTATION_CSECTION) || \ - defined(CONFIG_SCHED_CRITMONITOR) +#ifdef CONFIG_IRQCOUNT /**************************************************************************** * Public Data @@ -392,8 +391,9 @@ try_again: return ret; } -#else /* defined(CONFIG_SCHED_INSTRUMENTATION_CSECTION) || \ - * defined(CONFIG_SCHED_CRITMONITOR) */ + +#else + irqstate_t enter_critical_section(void) { irqstate_t ret; @@ -585,8 +585,7 @@ void leave_critical_section(irqstate_t flags) up_irq_restore(flags); } -#else /* defined(CONFIG_SCHED_INSTRUMENTATION_CSECTION) || - * defined(CONFIG_SCHED_CRITMONITOR) */ +#else void leave_critical_section(irqstate_t flags) { @@ -704,5 +703,4 @@ bool irq_cpu_locked(int cpu) } #endif -#endif /* CONFIG_SMP || CONFIG_SCHED_INSTRUMENTATION_CSECTION || - * CONFIG_SCHED_CRITMONITOR */ +#endif /* CONFIG_IRQCOUNT */ diff --git a/sched/sched/Make.defs b/sched/sched/Make.defs index 7686cc5d77..91e239dad0 100644 --- a/sched/sched/Make.defs +++ b/sched/sched/Make.defs @@ -70,22 +70,16 @@ CSRCS += sched_roundrobin.c endif ifeq ($(CONFIG_SCHED_SPORADIC),y) -CSRCS += sched_sporadic.c sched_suspendscheduler.c -else ifeq ($(CONFIG_SCHED_INSTRUMENTATION),y) -CSRCS += sched_suspendscheduler.c -else ifeq ($(CONFIG_SCHED_CRITMONITOR),y) +CSRCS += sched_sporadic.c +endif + +ifeq ($(CONFIG_SCHED_SUSPENDSCHEDULER),y) CSRCS += sched_suspendscheduler.c endif ifneq ($(CONFIG_RR_INTERVAL),0) CSRCS += sched_resumescheduler.c -else ifeq ($(CONFIG_SCHED_SPORADIC),y) -CSRCS += sched_resumescheduler.c -else ifeq ($(CONFIG_SCHED_INSTRUMENTATION),y) -CSRCS += sched_resumescheduler.c -else ifeq ($(CONFIG_SCHED_CRITMONITOR),y) -CSRCS += sched_resumescheduler.c -else ifeq ($(CONFIG_SMP),y) +else ifeq ($(CONFIG_SCHED_RESUMESCHEDULER),y) CSRCS += sched_resumescheduler.c endif diff --git a/sched/sched/sched_resumescheduler.c b/sched/sched/sched_resumescheduler.c index fd06c08b1a..58b5a13210 100644 --- a/sched/sched/sched_resumescheduler.c +++ b/sched/sched/sched_resumescheduler.c @@ -48,9 +48,7 @@ #include "irq/irq.h" #include "sched/sched.h" -#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC) || \ - defined(CONFIG_SCHED_INSTRUMENTATION) || defined(CONFIG_SCHED_CRITMONITOR) || \ - defined(CONFIG_SMP) +#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_RESUMESCHEDULER) /**************************************************************************** * Public Functions @@ -145,6 +143,4 @@ void sched_resume_scheduler(FAR struct tcb_s *tcb) } -#endif /* CONFIG_RR_INTERVAL > 0 || CONFIG_SCHED_SPORADIC || \ - * CONFIG_SCHED_INSTRUMENTATION || CONFIG_SCHED_CRITMONITOR || - * CONFIG_SMP */ +#endif /* CONFIG_RR_INTERVAL > 0 || CONFIG_SCHED_RESUMESCHEDULER */ diff --git a/sched/sched/sched_suspendscheduler.c b/sched/sched/sched_suspendscheduler.c index a8be48386a..4581ddc452 100644 --- a/sched/sched/sched_suspendscheduler.c +++ b/sched/sched/sched_suspendscheduler.c @@ -50,8 +50,7 @@ #include "clock/clock.h" #include "sched/sched.h" -#if defined(CONFIG_SCHED_SPORADIC) || defined(CONFIG_SCHED_INSTRUMENTATION) || \ - defined(CONFIG_SCHED_CRITMONITOR) +#ifdef CONFIG_SCHED_SUSPENDSCHEDULER /**************************************************************************** * Public Functions @@ -94,5 +93,4 @@ void sched_suspend_scheduler(FAR struct tcb_s *tcb) #endif } -#endif /* CONFIG_SCHED_SPORADIC || CONFIG_SCHED_INSTRUMENTATION || - * CONFIG_SCHED_CRITMONITOR */ +#endif /* CONFIG_SCHED_SUSPENDSCHEDULER */