drivers/note: Replace the scritical section with spin_xxx_wo_note

to avoid to generate the unexpected schedule information

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-12-30 12:02:47 +08:00 committed by Petro Karashchenko
parent abf5ea24b4
commit 98ab55ef68
2 changed files with 16 additions and 14 deletions

View File

@ -146,9 +146,9 @@ struct note_taskname_s
static struct note_filter_s g_note_filter =
{
{
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE
#ifdef CONFIG_SMP
, CONFIG_SCHED_INSTRUMENTATION_CPUSET
, CONFIG_SCHED_INSTRUMENTATION_CPUSET
#endif
}
};
@ -173,6 +173,8 @@ FAR static struct note_driver_s *g_note_drivers[CONFIG_DRIVER_NOTE_MAX + 1] =
static struct note_taskname_s g_note_taskname;
#endif
static spinlock_t g_note_lock;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -1750,7 +1752,7 @@ void sched_note_filter_mode(FAR struct note_filter_mode_s *oldm,
{
irqstate_t irq_mask;
irq_mask = enter_critical_section();
irq_mask = spin_lock_irqsave_wo_note(&g_note_lock);
if (oldm != NULL)
{
@ -1762,7 +1764,7 @@ void sched_note_filter_mode(FAR struct note_filter_mode_s *oldm,
g_note_filter.mode = *newm;
}
leave_critical_section(irq_mask);
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
}
/****************************************************************************
@ -1791,7 +1793,7 @@ void sched_note_filter_syscall(FAR struct note_filter_syscall_s *oldf,
{
irqstate_t irq_mask;
irq_mask = enter_critical_section();
irq_mask = spin_lock_irqsave_wo_note(&g_note_lock);
if (oldf != NULL)
{
@ -1807,7 +1809,7 @@ void sched_note_filter_syscall(FAR struct note_filter_syscall_s *oldf,
g_note_filter.syscall_mask = *newf;
}
leave_critical_section(irq_mask);
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
}
#endif
@ -1837,7 +1839,7 @@ void sched_note_filter_irq(FAR struct note_filter_irq_s *oldf,
{
irqstate_t irq_mask;
irq_mask = enter_critical_section();
irq_mask = spin_lock_irqsave_wo_note(&g_note_lock);
if (oldf != NULL)
{
@ -1853,7 +1855,7 @@ void sched_note_filter_irq(FAR struct note_filter_irq_s *oldf,
g_note_filter.irq_mask = *newf;
}
leave_critical_section(irq_mask);
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
}
#endif
@ -1883,12 +1885,12 @@ int note_get_taskname(pid_t pid, FAR char *buffer)
FAR struct tcb_s *tcb;
irqstate_t irq_mask;
irq_mask = enter_critical_section();
irq_mask = spin_lock_irqsave_wo_note(&g_note_lock);
tcb = nxsched_get_tcb(pid);
if (tcb != NULL)
{
strlcpy(buffer, tcb->name, CONFIG_TASK_NAME_SIZE + 1);
leave_critical_section(irq_mask);
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
return OK;
}
@ -1896,11 +1898,11 @@ int note_get_taskname(pid_t pid, FAR char *buffer)
if (ti != NULL)
{
strlcpy(buffer, ti->name, CONFIG_TASK_NAME_SIZE + 1);
leave_critical_section(irq_mask);
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
return OK;
}
leave_critical_section(irq_mask);
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
return -ESRCH;
}

View File

@ -56,7 +56,7 @@ FAR struct tcb_s *nxsched_get_tcb(pid_t pid)
irqstate_t flags;
int hash_ndx;
flags = enter_critical_section();
flags = spin_lock_irqsave_wo_note(NULL);
/* Verify whether g_pidhash hash table has already been allocated and
* whether the PID is within range.
@ -84,7 +84,7 @@ FAR struct tcb_s *nxsched_get_tcb(pid_t pid)
}
}
leave_critical_section(flags);
spin_unlock_irqrestore_wo_note(NULL, flags);
/* Return the TCB. */