From: Willy Tarreau Date: Wed, 6 Oct 2021 13:58:46 +0000 (+0200) Subject: REORG: sched: moved samp_time and idle_time to task.c as well X-Git-Tag: v2.5-dev9~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=078c2573c2feeee8d5c9007a4ec95b01e7768514;p=thirdparty%2Fhaproxy.git 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 1020eea4d3..6adba48458 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 be9a2bb4b4..436b1a8a09 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 34c8624c91..f77d34300b 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 d6ab185b41..99aed11f84 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); }