merge sched_note_spinxx into sched_note_spincommon
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
aeed8f5d26
commit
552cf4b549
|
@ -380,46 +380,6 @@ static inline int note_isenabled_dump(void)
|
|||
}
|
||||
#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
|
||||
****************************************************************************/
|
||||
|
@ -704,27 +664,43 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
|
|||
}
|
||||
#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
|
||||
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,
|
||||
FAR volatile void *spinlock)
|
||||
{
|
||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCKED);
|
||||
}
|
||||
if (!note_isenabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void sched_note_spinunlock(FAR struct tcb_s *tcb,
|
||||
FAR volatile void *spinlock)
|
||||
{
|
||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_UNLOCK);
|
||||
}
|
||||
/* Format the note */
|
||||
|
||||
void sched_note_spinabort(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
|
||||
{
|
||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_ABORT);
|
||||
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
|
||||
|
||||
|
|
|
@ -34,56 +34,6 @@
|
|||
* 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
|
||||
****************************************************************************/
|
||||
|
@ -319,29 +269,53 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
|
|||
}
|
||||
#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
|
||||
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 volatile void *spinlock)
|
||||
{
|
||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCKED);
|
||||
}
|
||||
FAR const char * msg = tmp[type - NOTE_SPINLOCK_LOCK];
|
||||
|
||||
void sched_note_spinunlock(FAR struct tcb_s *tcb,
|
||||
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_spincommon(tcb, spinlock, NOTE_SPINLOCK_ABORT);
|
||||
#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
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
/* 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
|
||||
void sched_note_spinlock(FAR struct tcb_s *tcb,
|
||||
FAR volatile void *spinlock);
|
||||
void sched_note_spinlocked(FAR struct tcb_s *tcb,
|
||||
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);
|
||||
FAR volatile spinlock_t *spinlock,
|
||||
int type);
|
||||
#else
|
||||
# define sched_note_spinlock(t,s)
|
||||
# define sched_note_spinlocked(t,s)
|
||||
# define sched_note_spinunlock(t,s)
|
||||
# define sched_note_spinabort(t,s)
|
||||
# define sched_note_spinlock(tcb, spinlock, type)
|
||||
#endif
|
||||
|
||||
#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_premption(t,l)
|
||||
# define sched_note_csection(t,e)
|
||||
# define sched_note_spinlock(t,s)
|
||||
# define sched_note_spinlocked(t,s)
|
||||
# define sched_note_spinunlock(t,s)
|
||||
# define sched_note_spinabort(t,s)
|
||||
# define sched_note_spinlock(t,s,i)
|
||||
# define sched_note_syscall_enter(n,a,...)
|
||||
# define sched_note_syscall_leave(n,r)
|
||||
# define sched_note_irqhandler(i,h,e)
|
||||
|
|
|
@ -1037,10 +1037,7 @@ config SCHED_INSTRUMENTATION_SPINLOCKS
|
|||
Enables additional hooks for spinlock state. Board-specific logic
|
||||
must provide this additional logic.
|
||||
|
||||
void sched_note_spinlock(FAR struct tcb_s *tcb, bool state);
|
||||
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);
|
||||
void sched_note_spinlock(FAR struct tcb_s *tcb, FAR volatile spinlock_t *spinlock, int type)
|
||||
|
||||
config SCHED_INSTRUMENTATION_SYSCALL
|
||||
bool "System call monitor hooks"
|
||||
|
|
|
@ -113,7 +113,7 @@ static bool irq_waitlock(int cpu)
|
|||
|
||||
/* 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
|
||||
|
||||
/* 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
|
||||
/* 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
|
||||
|
||||
return false;
|
||||
|
@ -145,7 +145,7 @@ static bool irq_waitlock(int cpu)
|
|||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||
/* Notify that we have the spinlock */
|
||||
|
||||
sched_note_spinlocked(tcb, &g_cpu_irqlock);
|
||||
sched_note_spinlock(tcb, &g_cpu_irqlock, NOTE_SPINLOCK_LOCKED);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
|
|
@ -68,7 +68,7 @@ void spin_lock(FAR volatile spinlock_t *lock)
|
|||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||
/* Notify that we are waiting for a spinlock */
|
||||
|
||||
sched_note_spinlock(this_task(), lock);
|
||||
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_LOCK);
|
||||
#endif
|
||||
|
||||
while (up_testset(lock) == SP_LOCKED)
|
||||
|
@ -80,7 +80,7 @@ void spin_lock(FAR volatile spinlock_t *lock)
|
|||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||
/* Notify that we have the spinlock */
|
||||
|
||||
sched_note_spinlocked(this_task(), lock);
|
||||
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_LOCKED);
|
||||
#endif
|
||||
SP_DMB();
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ spinlock_t spin_trylock(FAR volatile spinlock_t *lock)
|
|||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||
/* Notify that we are waiting for a spinlock */
|
||||
|
||||
sched_note_spinlock(this_task(), lock);
|
||||
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_LOCK);
|
||||
#endif
|
||||
|
||||
if (up_testset(lock) == SP_LOCKED)
|
||||
|
@ -150,7 +150,7 @@ spinlock_t spin_trylock(FAR volatile spinlock_t *lock)
|
|||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||
/* Notify that we abort for a spinlock */
|
||||
|
||||
sched_note_spinabort(this_task(), &lock);
|
||||
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_ABORT);
|
||||
#endif
|
||||
SP_DSB();
|
||||
return SP_LOCKED;
|
||||
|
@ -159,7 +159,7 @@ spinlock_t spin_trylock(FAR volatile spinlock_t *lock)
|
|||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||
/* Notify that we have the spinlock */
|
||||
|
||||
sched_note_spinlocked(this_task(), lock);
|
||||
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_LOCKED);
|
||||
#endif
|
||||
SP_DMB();
|
||||
return SP_UNLOCKED;
|
||||
|
@ -222,7 +222,7 @@ void spin_unlock(FAR volatile spinlock_t *lock)
|
|||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
||||
/* Notify that we are unlocking the spinlock */
|
||||
|
||||
sched_note_spinunlock(this_task(), lock);
|
||||
sched_note_spinlock(this_task(), lock, NOTE_SPINLOCK_UNLOCK);
|
||||
#endif
|
||||
|
||||
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 */
|
||||
|
||||
sched_note_spinlocked(this_task(), orlock);
|
||||
sched_note_spinlock(this_task(), orlock, NOTE_SPINLOCK_LOCKED);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -373,7 +373,7 @@ void spin_clrbit(FAR volatile cpu_set_t *set, unsigned int cpu,
|
|||
{
|
||||
/* Notify that we have unlocked the spinlock */
|
||||
|
||||
sched_note_spinunlock(this_task(), orlock);
|
||||
sched_note_spinlock(this_task(), orlock, NOTE_SPINLOCK_UNLOCK);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue