sched_note: Permit spinlock and critical section notes in in-memory buffer iff sched_not_get() interfaces is disabled.

This commit is contained in:
Gregory Nutt 2016-11-28 18:36:26 -06:00
parent f3e6264654
commit 9ee3f3b933
4 changed files with 33 additions and 29 deletions

View File

@ -70,7 +70,7 @@ endif
config DRIVER_NOTE
bool "Scheduler instrumentation driver"
default n
depends on SCHED_INSTRUMENTATION_BUFFER
depends on SCHED_INSTRUMENTATION_BUFFER && SCHED_NOTE_GET
---help---
Enable building a serial driver that can be used by an application
to read data from the in-memory, scheduler instrumentation "note"

View File

@ -58,11 +58,11 @@
* old configuration files)
*/
#ifdef CONFIG_SCHED_INSTRUMENTATION_CPUSET
#ifndef CONFIG_SCHED_INSTRUMENTATION_CPUSET
# define CONFIG_SCHED_INSTRUMENTATION_CPUSET 0xffff
#endif
#ifdef CONFIG_SCHED_NOTE_BUFSIZE
#ifndef CONFIG_SCHED_NOTE_BUFSIZE
# define CONFIG_SCHED_NOTE_BUFSIZE 2048
#endif
@ -301,7 +301,8 @@ void sched_note_spinabort(FAR struct tcb_s *tcb, FAR volatile void *spinlock);
*
****************************************************************************/
#ifdef CONFIG_SCHED_INSTRUMENTATION_BUFFER
#if defined(CONFIG_SCHED_INSTRUMENTATION_BUFFER) && \
defined(CONFIG_SCHED_NOTE_GET)
ssize_t sched_note_get(FAR uint8_t *buffer, size_t buflen);
#endif
@ -320,7 +321,8 @@ ssize_t sched_note_get(FAR uint8_t *buffer, size_t buflen);
*
****************************************************************************/
#ifdef CONFIG_SCHED_INSTRUMENTATION_BUFFER
#if defined(CONFIG_SCHED_INSTRUMENTATION_BUFFER) && \
defined(CONFIG_SCHED_NOTE_GET)
ssize_t sched_note_size(void);
#endif

View File

@ -694,15 +694,9 @@ config SCHED_INSTRUMENTATION_PREEMPTION
void sched_note_premption(FAR struct tcb_s *tcb, bool state);
config SCHED_INSTRUMENTATION_FAUXPAS
bool
default y if !EXPERIMENTAL && SCHED_INSTRUMENTATION_BUFFER
default n if EXPERIMENTAL || !SCHED_INSTRUMENTATION_BUFFER
config SCHED_INSTRUMENTATION_CSECTION
bool "Critical section monitor hooks"
default n
depends on !SCHED_INSTRUMENTATION_FAUXPAS
---help---
Enables additional hooks for entry and exit from critical sections.
Interrupts are disabled while within a critical section. Board-
@ -710,18 +704,9 @@ config SCHED_INSTRUMENTATION_CSECTION
void sched_note_csection(FAR struct tcb_s *tcb, bool state);
NOTE: This option is marked EXPERIMENTAL because there is a logical
error in the design when this feature is used with
CONFIG_SCHED_INSTRUMENTATION_BUFFER. That error is that
sched_note_get() calls enter_ and leave_critical_section. That
means that each call to sched_note_get() causes two entries to be
added from the note buffer in order to remove one entry. Not
very useful in its current state!
config SCHED_INSTRUMENTATION_SPINLOCK
bool "Spinlock monitor hooks"
default n
depends on SPINLOCK && (!SMP || !SCHED_INSTRUMENTATION_FAUXPAS)
---help---
Enables additional hooks for spinlock state. Board-specific logic
must provide this additional logic.
@ -731,14 +716,6 @@ config SCHED_INSTRUMENTATION_SPINLOCK
void sched_note_spinunlock(FAR struct tcb_s *tcb, bool state);
void sched_note_spinabort(FAR struct tcb_s *tcb, bool state);
NOTE: This option is marked EXPERIMENTAL because there is a logical
error in the design when this feature is used with
CONFIG_SCHED_INSTRUMENTATION_BUFFER. That error is that
sched_note_get() calls enter_ and leave_critical_section which use
spinlocks in SMP mode. That means that each call to sched_note_get()
causes several additional entries to be added from the note buffer in
order to remove one entry. Not very useful in its current state!
config SCHED_INSTRUMENTATION_BUFFER
bool "Buffer instrumentation data in memory"
default n
@ -763,14 +740,35 @@ config SCHED_INSTRUMENTATION_BUFFER
does not occur. See include/nuttx/sched_note.h for additional
information.
if SCHED_INSTRUMENTATION_BUFFER
config SCHED_NOTE_BUFSIZE
int "Instrumentation buffer size"
default 2048
depends on SCHED_INSTRUMENTATION_BUFFER
---help---
The size of the in-memory, circular instrumentation buffer (in
bytes).
config SCHED_NOTE_GET
int "Callable interface to get instrumentatin data"
default 2048
depends on !SCHED_INSTRUMENTATION_CSECTION && (!SCHED_INSTRUMENTATION_SPINLOCK || !SMP)
---help---
Add support for interfaces to get the size of the next note and also
to extract the next note from the instrumentation buffer:
ssize_t sched_note_get(FAR uint8_t *buffer, size_t buflen);
ssize_t sched_note_size(void);
NOTE: This option is not available if critical sections are being
monitor (nor if spinlocks are being monitored in SMP configuration)
because there would be a logical error in the design in those cases.
That error is that these interfaces call enter_ and leave_critical_section
(and which us spinlocks in SMP mode). That means that each call to
sched_note_get() causes several additional entries to be added from
the note buffer in order to remove one entry.
endif # SCHED_INSTRUMENTATION_BUFFER
endif # SCHED_INSTRUMENTATION
endmenu # Performance Monitoring

View File

@ -551,6 +551,7 @@ void sched_note_spinabort(FAR struct tcb_s *tcb, FAR volatile void *spinlock);
*
****************************************************************************/
#ifdef CONFIG_SCHED_NOTE_GET
ssize_t sched_note_get(FAR uint8_t *buffer, size_t buflen)
{
FAR struct note_common_s *note;
@ -618,6 +619,7 @@ errout_with_csection:
leave_critical_section(flags);
return notelen;
}
#endif
/****************************************************************************
* Name: sched_note_size
@ -634,6 +636,7 @@ errout_with_csection:
*
****************************************************************************/
#ifdef CONFIG_SCHED_NOTE_GET
ssize_t sched_note_size(void)
{
FAR struct note_common_s *note;
@ -668,5 +671,6 @@ errout_with_csection:
leave_critical_section(flags);
return notelen;
}
#endif
#endif /* CONFIG_SCHED_INSTRUMENTATION_BUFFER */