mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
merge sched_note_spinxx into sched_note_spincommon
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
+32
-56
@@ -380,46 +380,6 @@ static inline int note_isenabled_dump(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: note_spincommon
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Common logic for NOTE_SPINLOCK, NOTE_SPINLOCKED, and NOTE_SPINUNLOCK
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* tcb - The TCB containing the information
|
|
||||||
* note - The common note structure to use
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
|
||||||
static void note_spincommon(FAR struct tcb_s *tcb,
|
|
||||||
FAR volatile spinlock_t *spinlock,
|
|
||||||
int type)
|
|
||||||
{
|
|
||||||
struct note_spinlock_s note;
|
|
||||||
|
|
||||||
if (!note_isenabled())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Format the note */
|
|
||||||
|
|
||||||
note_common(tcb, ¬e.nsp_cmn, sizeof(struct note_spinlock_s), type);
|
|
||||||
|
|
||||||
sched_note_flatten(note.nsp_spinlock, &spinlock, sizeof(spinlock));
|
|
||||||
note.nsp_value = *(FAR uint8_t *)spinlock;
|
|
||||||
|
|
||||||
/* Add the note to circular buffer */
|
|
||||||
|
|
||||||
sched_note_add(¬e, sizeof(struct note_spinlock_s));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -704,27 +664,43 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: sched_note_spinlock
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Common logic for NOTE_SPINLOCK, NOTE_SPINLOCKED, and NOTE_SPINUNLOCK
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tcb - The TCB containing the information
|
||||||
|
* note - The common note structure to use
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
void sched_note_spinlock(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
|
void sched_note_spinlock(FAR struct tcb_s *tcb,
|
||||||
|
FAR volatile spinlock_t *spinlock,
|
||||||
|
int type)
|
||||||
{
|
{
|
||||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCK);
|
struct note_spinlock_s note;
|
||||||
}
|
|
||||||
|
|
||||||
void sched_note_spinlocked(FAR struct tcb_s *tcb,
|
if (!note_isenabled())
|
||||||
FAR volatile void *spinlock)
|
{
|
||||||
{
|
return;
|
||||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCKED);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void sched_note_spinunlock(FAR struct tcb_s *tcb,
|
/* Format the note */
|
||||||
FAR volatile void *spinlock)
|
|
||||||
{
|
|
||||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_UNLOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sched_note_spinabort(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
|
note_common(tcb, ¬e.nsp_cmn, sizeof(struct note_spinlock_s), type);
|
||||||
{
|
|
||||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_ABORT);
|
sched_note_flatten(note.nsp_spinlock, &spinlock, sizeof(spinlock));
|
||||||
|
note.nsp_value = *(FAR uint8_t *)spinlock;
|
||||||
|
|
||||||
|
/* Add the note to circular buffer */
|
||||||
|
|
||||||
|
sched_note_add(¬e, sizeof(struct note_spinlock_s));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -34,56 +34,6 @@
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: note_spincommon
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Common logic for NOTE_SPINLOCK, NOTE_SPINLOCKED, and NOTE_SPINUNLOCK
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* tcb - The TCB containing the information
|
|
||||||
* note - The common note structure to use
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
|
||||||
static inline void note_spincommon(FAR struct tcb_s *tcb,
|
|
||||||
FAR volatile void *spinlock,
|
|
||||||
int type)
|
|
||||||
{
|
|
||||||
FAR static const char * const tmp[] =
|
|
||||||
{
|
|
||||||
"LOCK",
|
|
||||||
"LOCKED",
|
|
||||||
"UNLOCK",
|
|
||||||
"ABORT"
|
|
||||||
};
|
|
||||||
|
|
||||||
FAR const char * msg = tmp[type - NOTE_SPINLOCK_LOCK];
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p spinlock@%p %s\n",
|
|
||||||
tcb->cpu, tcb->name, tcb, spinlock, msg);
|
|
||||||
#else
|
|
||||||
syslog(LOG_INFO, "CPU%d: TCB@%p spinlock@%p %s\n",
|
|
||||||
tcb->cpu, tcb, spinlock, msg);
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
syslog(LOG_INFO, "Task %s TCB@%p spinlock@%p %s\n",
|
|
||||||
tcb->name, tcb, spinlock, msg);
|
|
||||||
#else
|
|
||||||
syslog(LOG_INFO, "TCB@%p spinlock@%p %s\n",
|
|
||||||
tcb, spinlock, msg);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -319,29 +269,53 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: sched_note_spinlock
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Common logic for NOTE_SPINLOCK, NOTE_SPINLOCKED, and NOTE_SPINUNLOCK
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tcb - The TCB containing the information
|
||||||
|
* note - The common note structure to use
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
void sched_note_spinlock(FAR struct tcb_s *tcb,
|
void sched_note_spinlock(FAR struct tcb_s *tcb,
|
||||||
FAR volatile void *spinlock)
|
FAR volatile spinlock_t *spinlock,
|
||||||
|
int type)
|
||||||
{
|
{
|
||||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCK);
|
FAR static const char * const tmp[] =
|
||||||
}
|
{
|
||||||
|
"LOCK",
|
||||||
|
"LOCKED",
|
||||||
|
"UNLOCK",
|
||||||
|
"ABORT"
|
||||||
|
};
|
||||||
|
|
||||||
void sched_note_spinlocked(FAR struct tcb_s *tcb,
|
FAR const char * msg = tmp[type - NOTE_SPINLOCK_LOCK];
|
||||||
FAR volatile void *spinlock)
|
|
||||||
{
|
|
||||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCKED);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sched_note_spinunlock(FAR struct tcb_s *tcb,
|
#ifdef CONFIG_SMP
|
||||||
FAR volatile void *spinlock)
|
#if CONFIG_TASK_NAME_SIZE > 0
|
||||||
{
|
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p spinlock@%p %s\n",
|
||||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_UNLOCK);
|
tcb->cpu, tcb->name, tcb, spinlock, msg);
|
||||||
}
|
#else
|
||||||
|
syslog(LOG_INFO, "CPU%d: TCB@%p spinlock@%p %s\n",
|
||||||
void sched_note_spinabort(FAR struct tcb_s *tcb,
|
tcb->cpu, tcb, spinlock, msg);
|
||||||
FAR volatile void *spinlock)
|
#endif
|
||||||
{
|
#else
|
||||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_ABORT);
|
#if CONFIG_TASK_NAME_SIZE > 0
|
||||||
|
syslog(LOG_INFO, "Task %s TCB@%p spinlock@%p %s\n",
|
||||||
|
tcb->name, tcb, spinlock, msg);
|
||||||
|
#else
|
||||||
|
syslog(LOG_INFO, "TCB@%p spinlock@%p %s\n",
|
||||||
|
tcb, spinlock, msg);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
|
#include <nuttx/spinlock.h>
|
||||||
|
|
||||||
/* For system call numbers definition */
|
/* For system call numbers definition */
|
||||||
|
|
||||||
@@ -512,18 +513,10 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter);
|
|||||||
|
|
||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
void sched_note_spinlock(FAR struct tcb_s *tcb,
|
void sched_note_spinlock(FAR struct tcb_s *tcb,
|
||||||
FAR volatile void *spinlock);
|
FAR volatile spinlock_t *spinlock,
|
||||||
void sched_note_spinlocked(FAR struct tcb_s *tcb,
|
int type);
|
||||||
FAR volatile void *spinlock);
|
|
||||||
void sched_note_spinunlock(FAR struct tcb_s *tcb,
|
|
||||||
FAR volatile void *spinlock);
|
|
||||||
void sched_note_spinabort(FAR struct tcb_s *tcb,
|
|
||||||
FAR volatile void *spinlock);
|
|
||||||
#else
|
#else
|
||||||
# define sched_note_spinlock(t,s)
|
# define sched_note_spinlock(tcb, spinlock, type)
|
||||||
# define sched_note_spinlocked(t,s)
|
|
||||||
# define sched_note_spinunlock(t,s)
|
|
||||||
# define sched_note_spinabort(t,s)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
||||||
@@ -695,10 +688,7 @@ void sched_note_filter_irq(FAR struct note_filter_irq_s *oldf,
|
|||||||
# define sched_note_cpu_resumed(t)
|
# define sched_note_cpu_resumed(t)
|
||||||
# define sched_note_premption(t,l)
|
# define sched_note_premption(t,l)
|
||||||
# define sched_note_csection(t,e)
|
# define sched_note_csection(t,e)
|
||||||
# define sched_note_spinlock(t,s)
|
# define sched_note_spinlock(t,s,i)
|
||||||
# define sched_note_spinlocked(t,s)
|
|
||||||
# define sched_note_spinunlock(t,s)
|
|
||||||
# define sched_note_spinabort(t,s)
|
|
||||||
# define sched_note_syscall_enter(n,a,...)
|
# define sched_note_syscall_enter(n,a,...)
|
||||||
# define sched_note_syscall_leave(n,r)
|
# define sched_note_syscall_leave(n,r)
|
||||||
# define sched_note_irqhandler(i,h,e)
|
# define sched_note_irqhandler(i,h,e)
|
||||||
|
|||||||
+1
-4
@@ -1037,10 +1037,7 @@ config SCHED_INSTRUMENTATION_SPINLOCKS
|
|||||||
Enables additional hooks for spinlock state. Board-specific logic
|
Enables additional hooks for spinlock state. Board-specific logic
|
||||||
must provide this additional logic.
|
must provide this additional logic.
|
||||||
|
|
||||||
void sched_note_spinlock(FAR struct tcb_s *tcb, bool state);
|
void sched_note_spinlock(FAR struct tcb_s *tcb, FAR volatile spinlock_t *spinlock, int type)
|
||||||
void sched_note_spinlocked(FAR struct tcb_s *tcb, bool state);
|
|
||||||
void sched_note_spinunlock(FAR struct tcb_s *tcb, bool state);
|
|
||||||
void sched_note_spinabort(FAR struct tcb_s *tcb, bool state);
|
|
||||||
|
|
||||||
config SCHED_INSTRUMENTATION_SYSCALL
|
config SCHED_INSTRUMENTATION_SYSCALL
|
||||||
bool "System call monitor hooks"
|
bool "System call monitor hooks"
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ static bool irq_waitlock(int cpu)
|
|||||||
|
|
||||||
/* Notify that we are waiting for a spinlock */
|
/* Notify that we are waiting for a spinlock */
|
||||||
|
|
||||||
sched_note_spinlock(tcb, &g_cpu_irqlock);
|
sched_note_spinlock(tcb, &g_cpu_irqlock, NOTE_SPINLOCK_LOCK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Duplicate the spin_lock() logic from spinlock.c, but adding the check
|
/* Duplicate the spin_lock() logic from spinlock.c, but adding the check
|
||||||
@@ -133,7 +133,7 @@ static bool irq_waitlock(int cpu)
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
/* Notify that we have aborted the wait for the spinlock */
|
/* Notify that we have aborted the wait for the spinlock */
|
||||||
|
|
||||||
sched_note_spinabort(tcb, &g_cpu_irqlock);
|
sched_note_spinlock(tcb, &g_cpu_irqlock, NOTE_SPINLOCK_ABORT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -145,7 +145,7 @@ static bool irq_waitlock(int cpu)
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
/* Notify that we have the spinlock */
|
/* Notify that we have the spinlock */
|
||||||
|
|
||||||
sched_note_spinlocked(tcb, &g_cpu_irqlock);
|
sched_note_spinlock(tcb, &g_cpu_irqlock, NOTE_SPINLOCK_LOCKED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void spin_lock(FAR volatile spinlock_t *lock)
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
/* Notify that we are waiting for a spinlock */
|
/* Notify that we are waiting for a spinlock */
|
||||||
|
|
||||||
sched_note_spinlock(this_task(), lock);
|
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_LOCK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (up_testset(lock) == SP_LOCKED)
|
while (up_testset(lock) == SP_LOCKED)
|
||||||
@@ -80,7 +80,7 @@ void spin_lock(FAR volatile spinlock_t *lock)
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
/* Notify that we have the spinlock */
|
/* Notify that we have the spinlock */
|
||||||
|
|
||||||
sched_note_spinlocked(this_task(), lock);
|
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_LOCKED);
|
||||||
#endif
|
#endif
|
||||||
SP_DMB();
|
SP_DMB();
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ spinlock_t spin_trylock(FAR volatile spinlock_t *lock)
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
/* Notify that we are waiting for a spinlock */
|
/* Notify that we are waiting for a spinlock */
|
||||||
|
|
||||||
sched_note_spinlock(this_task(), lock);
|
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_LOCK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (up_testset(lock) == SP_LOCKED)
|
if (up_testset(lock) == SP_LOCKED)
|
||||||
@@ -150,7 +150,7 @@ spinlock_t spin_trylock(FAR volatile spinlock_t *lock)
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
/* Notify that we abort for a spinlock */
|
/* Notify that we abort for a spinlock */
|
||||||
|
|
||||||
sched_note_spinabort(this_task(), &lock);
|
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_ABORT);
|
||||||
#endif
|
#endif
|
||||||
SP_DSB();
|
SP_DSB();
|
||||||
return SP_LOCKED;
|
return SP_LOCKED;
|
||||||
@@ -159,7 +159,7 @@ spinlock_t spin_trylock(FAR volatile spinlock_t *lock)
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
/* Notify that we have the spinlock */
|
/* Notify that we have the spinlock */
|
||||||
|
|
||||||
sched_note_spinlocked(this_task(), lock);
|
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_LOCKED);
|
||||||
#endif
|
#endif
|
||||||
SP_DMB();
|
SP_DMB();
|
||||||
return SP_UNLOCKED;
|
return SP_UNLOCKED;
|
||||||
@@ -222,7 +222,7 @@ void spin_unlock(FAR volatile spinlock_t *lock)
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||||
/* Notify that we are unlocking the spinlock */
|
/* Notify that we are unlocking the spinlock */
|
||||||
|
|
||||||
sched_note_spinunlock(this_task(), lock);
|
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_UNLOCK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SP_DMB();
|
SP_DMB();
|
||||||
@@ -310,7 +310,7 @@ void spin_setbit(FAR volatile cpu_set_t *set, unsigned int cpu,
|
|||||||
{
|
{
|
||||||
/* Notify that we have locked the spinlock */
|
/* Notify that we have locked the spinlock */
|
||||||
|
|
||||||
sched_note_spinlocked(this_task(), orlock);
|
sched_note_spinlock(this_task(), orlock, NOTE_SPINLOCK_LOCKED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ void spin_clrbit(FAR volatile cpu_set_t *set, unsigned int cpu,
|
|||||||
{
|
{
|
||||||
/* Notify that we have unlocked the spinlock */
|
/* Notify that we have unlocked the spinlock */
|
||||||
|
|
||||||
sched_note_spinunlock(this_task(), orlock);
|
sched_note_spinlock(this_task(), orlock, NOTE_SPINLOCK_UNLOCK);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user