From 6335b735545482c0e78acfb9ecd3b9b66516a490 Mon Sep 17 00:00:00 2001
From: Ali Mohammed <ali.mohammed@hpe.com>
Date: Thu, 26 Jan 2023 05:04:04 -0600
Subject: [PATCH] update numa node of thread teams

---
 maestro/thread_team.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/maestro/thread_team.c b/maestro/thread_team.c
index 1ac72483..61f38042 100644
--- a/maestro/thread_team.c
+++ b/maestro/thread_team.c
@@ -53,7 +53,7 @@ erl_thread_team_bind_and_update_numa(struct erl_thread_team_ctx *ctx)
  
  #ifdef HAVE_NUMA
  /**update numa node*/
- int numa_node = numa_node_of_cpu(mstro_numa_get_cpu(void));
+ int numa_node = numa_node_of_cpu(mstro_numa_get_cpu());
  ctx->numa_node = numa_node;
  #endif
  
@@ -70,6 +70,13 @@ erl_thread_team_threadfun(void *closure)
   char threadid[TID_LEN];
   struct erl_thread_team_ctx *ctx = (struct erl_thread_team_ctx*)closure;
 
+  /*check thread pinning and update ctx numa*/
+  mstro_status status = erl_thread_team_bind_and_update_numa(ctx);
+  if(status != MSTRO_OK)
+  {
+          WARN("Failed to pin the thread \n");
+  }
+
   int n = snprintf(threadid, TID_LEN, "%s-H-%d-%zu",
                    ctx->tidprefix, ctx->numa_node, ctx->id);
   if(n>=TID_LEN) {
@@ -85,12 +92,6 @@ erl_thread_team_threadfun(void *closure)
   }
   
   DEBUG("%s handler thread %zu running\n", ctx->tidprefix, ctx->id);
-  /*check thread pinning*/
-  s = erl_thread_team_bind_and_update_numa(ctx);
-  if(s != MSTRO_OK)
-  {
-	  WARN("Failed to pin the thread \n");
-  }
   INFO("Running on CPU: %d\n", mstro_numa_get_cpu());
 
   do {
-- 
GitLab