arch/sim: Call sched_note_cpu_* when SCHED_INSTRUMENTATION equal true
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
8792ade0fe
commit
cc00d2b2b0
3 changed files with 58 additions and 1 deletions
|
|
@ -102,6 +102,9 @@ ifeq ($(CONFIG_SMP),y)
|
|||
HOSTCFLAGS += -DCONFIG_USEC_PER_TICK=$(CONFIG_USEC_PER_TICK)
|
||||
ifeq ($(CONFIG_SIM_WALLTIME),y)
|
||||
HOSTCFLAGS += -DCONFIG_SIM_WALLTIME=1
|
||||
endif
|
||||
ifeq ($(CONFIG_SCHED_INSTRUMENTATION),y)
|
||||
HOSTCFLAGS += -DCONFIG_SCHED_INSTRUMENTATION=1
|
||||
endif
|
||||
HOSTSRCS += up_simsmp.c
|
||||
STDLIBS += -lpthread
|
||||
|
|
|
|||
|
|
@ -99,9 +99,16 @@ volatile spinlock_t g_cpu_paused[CONFIG_SMP_NCPUS];
|
|||
|
||||
void nx_start(void);
|
||||
void up_cpu_started(void);
|
||||
int up_cpu_paused(int cpu);
|
||||
int up_cpu_paused(int cpu);
|
||||
void host_sleepuntil(uint64_t nsec);
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
struct tcb_s *up_this_task(void);
|
||||
void sched_note_cpu_start(struct tcb_s *tcb, int cpu);
|
||||
void sched_note_cpu_pause(struct tcb_s *tcb, int cpu);
|
||||
void sched_note_cpu_resume(struct tcb_s *tcb, int cpu);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -330,6 +337,12 @@ int up_cpu_start(int cpu)
|
|||
struct sim_cpuinfo_s cpuinfo;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
/* Notify of the start event */
|
||||
|
||||
sched_note_cpu_start(up_this_task(), cpu);
|
||||
#endif
|
||||
|
||||
/* Initialize the CPU info */
|
||||
|
||||
cpuinfo.cpu = cpu;
|
||||
|
|
@ -400,6 +413,12 @@ errout_with_mutex:
|
|||
|
||||
int up_cpu_pause(int cpu)
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
/* Notify of the pause event */
|
||||
|
||||
sched_note_cpu_pause(up_this_task(), cpu);
|
||||
#endif
|
||||
|
||||
/* Take the spinlock that will prevent the CPU thread from running */
|
||||
|
||||
g_cpu_wait[cpu] = SP_LOCKED;
|
||||
|
|
@ -440,6 +459,12 @@ int up_cpu_pause(int cpu)
|
|||
|
||||
int up_cpu_resume(int cpu)
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
/* Notify of the resume event */
|
||||
|
||||
sched_note_cpu_resume(up_this_task(), cpu);
|
||||
#endif
|
||||
|
||||
/* Release the spinlock that will alloc the CPU thread to continue */
|
||||
|
||||
g_cpu_wait[cpu] = SP_UNLOCKED;
|
||||
|
|
|
|||
|
|
@ -105,6 +105,12 @@ int up_cpu_paused(int cpu)
|
|||
|
||||
nxsched_suspend_scheduler(rtcb);
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
/* Notify that we are paused */
|
||||
|
||||
sched_note_cpu_paused(rtcb);
|
||||
#endif
|
||||
|
||||
/* Copy the exception context into the TCB at the (old) head of the
|
||||
* CPUs assigned task list. if up_setjmp returns a non-zero value, then
|
||||
* this is really the previously running task restarting!
|
||||
|
|
@ -145,6 +151,12 @@ int up_cpu_paused(int cpu)
|
|||
rtcb->xcp.sigdeliver = NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
/* Notify that we have resumed */
|
||||
|
||||
sched_note_cpu_resumed(rtcb);
|
||||
#endif
|
||||
|
||||
/* Reset scheduler parameters */
|
||||
|
||||
nxsched_resume_scheduler(rtcb);
|
||||
|
|
@ -170,8 +182,25 @@ void up_cpu_started(void)
|
|||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
FAR struct tcb_s *tcb = this_task();
|
||||
|
||||
/* Notify that this CPU has started */
|
||||
|
||||
sched_note_cpu_started(tcb);
|
||||
|
||||
/* Announce that the IDLE task has started */
|
||||
|
||||
sched_note_start(tcb);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_this_task
|
||||
*
|
||||
* Description:
|
||||
* Return the currrent task tcb.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct tcb_s *up_this_task(void)
|
||||
{
|
||||
return this_task();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue