diff --git a/include/haproxy/task.h b/include/haproxy/task.h index 1020eea4d..6adba4845 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 be9a2bb4b..436b1a8a0 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 34c8624c9..f77d34300 100644 --- a/src/task.c +++ b/src/task.c @@ -37,6 +37,10 @@ DECLARE_POOL(pool_head_notification, "notification", sizeof(struct notification) 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 d6ab185b4..99aed11f8 100644 --- a/src/time.c +++ b/src/time.c @@ -19,8 +19,6 @@ #include 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 @@ void tv_init_process_date() 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 @@ void tv_init_thread_date() 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); }