MINOR: time: move the cpu, mono, and idle time to thread_info
These ones are useful across all threads and would be better placed
in struct thread_info than thread-local. There are very few users.
diff --git a/include/common/hathreads.h b/include/common/hathreads.h
index b3c4564..1042c26 100644
--- a/include/common/hathreads.h
+++ b/include/common/hathreads.h
@@ -51,6 +51,9 @@
extern struct thread_info {
clockid_t clock_id;
+ uint64_t prev_cpu_time; /* previous per thread CPU time */
+ uint64_t prev_mono_time; /* previous system wide monotonic time */
+ unsigned int idle_pct; /* idle to total ratio over last sample (percent) */
/* pad to cache line (64B) */
char __pad[0]; /* unused except to check remaining room */
char __end[0] __attribute__((aligned(64)));
@@ -382,6 +385,9 @@
extern struct thread_info {
pthread_t pthread;
clockid_t clock_id;
+ uint64_t prev_cpu_time; /* previous per thread CPU time */
+ uint64_t prev_mono_time; /* previous system wide monotonic time */
+ unsigned int idle_pct; /* idle to total ratio over last sample (percent) */
/* pad to cache line (64B) */
char __pad[0]; /* unused except to check remaining room */
char __end[0] __attribute__((aligned(64)));
diff --git a/include/common/time.h b/include/common/time.h
index 42bc957..0790873 100644
--- a/include/common/time.h
+++ b/include/common/time.h
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <sys/time.h>
#include <common/config.h>
+#include <common/hathreads.h>
#include <common/standard.h>
/* eternity when exprimed in timeval */
@@ -57,14 +58,11 @@
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 unsigned int idle_pct; /* idle to total ratio over last sample (percent) */
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 */
extern THREAD_LOCAL struct timeval before_poll; /* system date before calling poll() */
extern THREAD_LOCAL struct timeval after_poll; /* system date after leaving poll() */
-extern THREAD_LOCAL uint64_t prev_cpu_time; /* previous per thread CPU time */
-extern THREAD_LOCAL uint64_t prev_mono_time; /* previous system wide monotonic time */
/**** exported functions *************************************************/
@@ -567,7 +565,7 @@
if (samp_time < 500000)
return;
- idle_pct = (100 * idle_time + samp_time / 2) / samp_time;
+ ti->idle_pct = (100 * idle_time + samp_time / 2) / samp_time;
idle_time = samp_time = 0;
}
@@ -587,8 +585,8 @@
static inline void tv_leaving_poll(int timeout, int interrupted)
{
measure_idle();
- prev_cpu_time = now_cpu_time();
- prev_mono_time = now_mono_time();
+ ti->prev_cpu_time = now_cpu_time();
+ ti->prev_mono_time = now_mono_time();
}
#endif /* _COMMON_TIME_H */