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

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

commit 1b42a7bf84a5ae2d62779ab24bbc116c02a01cb9
Author: yinshengkai <[email protected]>
AuthorDate: Wed Sep 25 22:17:06 2024 +0800

    sched: gprof SMP support
    
    In the case of SMP, use smp_call to get other CPU data
    
    Signed-off-by: yinshengkai <[email protected]>
---
 sched/sched/sched_profil.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/sched/sched/sched_profil.c b/sched/sched/sched_profil.c
index 46e2b1fef5..de77d4e60f 100644
--- a/sched/sched/sched_profil.c
+++ b/sched/sched/sched_profil.c
@@ -59,9 +59,9 @@ static struct profinfo_s g_prof;
  * Private Functions
  ****************************************************************************/
 
-static void profil_timer_handler(wdparm_t arg)
+static int profil_timer_handler_cpu(FAR void *arg)
 {
-  FAR struct profinfo_s *prof = (FAR struct profinfo_s *)(uintptr_t)arg;
+  FAR struct profinfo_s *prof = (FAR struct profinfo_s *)arg;
   uintptr_t pc = up_getusrpc(NULL);
   irqstate_t flags;
 
@@ -78,6 +78,21 @@ static void profil_timer_handler(wdparm_t arg)
     }
 
   spin_unlock_irqrestore(&prof->lock, flags);
+  return OK;
+}
+
+static void profil_timer_handler(wdparm_t arg)
+{
+  FAR struct profinfo_s *prof = (FAR struct profinfo_s *)(uintptr_t)arg;
+
+#ifdef CONFIG_SMP
+  cpu_set_t cpus = (1 << CONFIG_SMP_NCPUS) - 1;
+  CPU_CLR(this_cpu(), &cpus);
+  nxsched_smp_call(cpus, profil_timer_handler_cpu,
+                   (FAR void *)arg, false);
+#endif
+
+  profil_timer_handler_cpu(prof);
   wd_start(&prof->timer, PROFTICK, profil_timer_handler, arg);
 }
 

Reply via email to