REORG: sched: moved samp_time and idle_time to task.c as well
The idle time calculation stuff was moved to task.h by commit 6dfab112e
("REORG: sched: move idle time calculation from time.h to task.h") but
these two variables that are only maintained by task.{c,h} were still
left in time.{c,h}. They have to move as well.
diff --git a/include/haproxy/task.h b/include/haproxy/task.h
index 1020eea..6adba48 100644
--- a/include/haproxy/task.h
+++ b/include/haproxy/task.h
@@ -90,6 +90,10 @@
extern volatile unsigned long global_tasks_mask; /* Mask of threads with tasks in the global runqueue */
extern unsigned int grq_total; /* total number of entries in the global run queue, atomic */
extern unsigned int niced_tasks; /* number of niced tasks in the run queue */
+
+extern THREAD_LOCAL unsigned int samp_time; /* total elapsed time over current sample */
+extern THREAD_LOCAL unsigned int idle_time; /* total idle time over current sample */
+
extern struct pool_head *pool_head_task;
extern struct pool_head *pool_head_tasklet;
extern struct pool_head *pool_head_notification;
diff --git a/include/haproxy/time.h b/include/haproxy/time.h
index be9a2bb..436b1a8 100644
--- a/include/haproxy/time.h
+++ b/include/haproxy/time.h
@@ -50,8 +50,6 @@
#define SETNOW(a) (*a=now)
extern THREAD_LOCAL unsigned int now_ms; /* internal date in milliseconds (may wrap) */
-extern THREAD_LOCAL unsigned int samp_time; /* total elapsed time over current sample */
-extern THREAD_LOCAL unsigned int idle_time; /* total idle time over current sample */
extern THREAD_LOCAL struct timeval now; /* internal date is a monotonic function of real clock */
extern THREAD_LOCAL struct timeval date; /* the real current date */
extern struct timeval start_date; /* the process's start date */
diff --git a/src/task.c b/src/task.c
index 34c8624..f77d343 100644
--- a/src/task.c
+++ b/src/task.c
@@ -37,6 +37,10 @@
volatile unsigned long global_tasks_mask = 0; /* Mask of threads with tasks in the global runqueue */
unsigned int niced_tasks = 0; /* number of niced tasks in the run queue */
+/* used for idle time calculation */
+THREAD_LOCAL unsigned int samp_time = 0; /* total elapsed time over current sample */
+THREAD_LOCAL unsigned int idle_time = 0; /* total idle time over current sample */
+
THREAD_LOCAL struct task_per_thread *sched = &task_per_thread[0]; /* scheduler context for the current thread */
__decl_aligned_spinlock(rq_lock); /* spin lock related to run queue */
diff --git a/src/time.c b/src/time.c
index d6ab185..99aed11 100644
--- a/src/time.c
+++ b/src/time.c
@@ -19,8 +19,6 @@
#include <haproxy/tools.h>
THREAD_LOCAL unsigned int now_ms; /* internal date in milliseconds (may wrap) */
-THREAD_LOCAL unsigned int samp_time; /* total elapsed time over current sample */
-THREAD_LOCAL unsigned int idle_time; /* total idle time over current sample */
THREAD_LOCAL struct timeval now; /* internal date is a monotonic function of real clock */
THREAD_LOCAL struct timeval date; /* the real current date */
struct timeval start_date; /* the process's start date */
@@ -278,7 +276,6 @@
now = after_poll = before_poll = date;
global_now = ((ullong)date.tv_sec << 32) + (uint)date.tv_usec;
global_now_ms = now.tv_sec * 1000 + now.tv_usec / 1000;
- samp_time = idle_time = 0;
ti->idle_pct = 100;
tv_update_date(0, 1);
}
@@ -296,7 +293,6 @@
old_now = _HA_ATOMIC_LOAD(&global_now);
now.tv_sec = old_now >> 32;
now.tv_usec = (uint)old_now;
- samp_time = idle_time = 0;
ti->idle_pct = 100;
tv_update_date(0, 1);
}