You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/07/26 11:25:08 UTC

[incubator-nuttx] branch master updated: arch/sim: Call sched_note_cpu_* when SCHED_INSTRUMENTATION equal true

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new cc00d2b  arch/sim: Call sched_note_cpu_* when SCHED_INSTRUMENTATION equal true
cc00d2b is described below

commit cc00d2b2b09cd695a4efa6ee5cf5aa8fbdaac112
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Jul 22 03:00:08 2020 +0800

    arch/sim: Call sched_note_cpu_* when SCHED_INSTRUMENTATION equal true
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/sim/src/Makefile           |  3 +++
 arch/sim/src/sim/up_simsmp.c    | 27 ++++++++++++++++++++++++++-
 arch/sim/src/sim/up_smpsignal.c | 29 +++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index 8dfe106..ed9e2ce 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -103,6 +103,9 @@ ifeq ($(CONFIG_SMP),y)
 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
 endif
diff --git a/arch/sim/src/sim/up_simsmp.c b/arch/sim/src/sim/up_simsmp.c
index 187c557..669562d 100644
--- a/arch/sim/src/sim/up_simsmp.c
+++ b/arch/sim/src/sim/up_simsmp.c
@@ -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;
diff --git a/arch/sim/src/sim/up_smpsignal.c b/arch/sim/src/sim/up_smpsignal.c
index eabeb1a..0179bbc 100644
--- a/arch/sim/src/sim/up_smpsignal.c
+++ b/arch/sim/src/sim/up_smpsignal.c
@@ -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();
+}