diff options
author | Lukas Larsson <[email protected]> | 2018-05-15 16:32:26 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2018-05-15 16:36:48 +0200 |
commit | d5dc5584884488c8fcb5710997a14c2c418692f3 (patch) | |
tree | 1058b4ef8953d6b814d898b890873ae2627a16d3 /erts/emulator/sys | |
parent | 3b3e2f46841e3e86c991be92d62cbb0360ca80e3 (diff) | |
download | otp-d5dc5584884488c8fcb5710997a14c2c418692f3.tar.gz otp-d5dc5584884488c8fcb5710997a14c2c418692f3.tar.bz2 otp-d5dc5584884488c8fcb5710997a14c2c418692f3.zip |
erts: Make cpu_timestamp use per thread on Linux
If we don't use per thread the value becomes completely
nonsensical on systems with more than one scheduler.
We keep the old solaris behaviour in order to support the
option, but it only really works when using a single
scheduler.
Diffstat (limited to 'erts/emulator/sys')
-rw-r--r-- | erts/emulator/sys/unix/erl_unix_sys.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/erts/emulator/sys/unix/erl_unix_sys.h b/erts/emulator/sys/unix/erl_unix_sys.h index 10adf80875..5bfe5a8e2d 100644 --- a/erts/emulator/sys/unix/erl_unix_sys.h +++ b/erts/emulator/sys/unix/erl_unix_sys.h @@ -292,6 +292,8 @@ erts_sys_perf_counter() /* * Functions for measuring CPU time + * + * Note that gethrvtime is time per process and clock_gettime is per thread. */ #if (defined(HAVE_GETHRVTIME) || defined(HAVE_CLOCK_GETTIME_CPU_TIME)) @@ -300,15 +302,15 @@ typedef struct timespec SysTimespec; #if defined(HAVE_GETHRVTIME) #define sys_gethrvtime() gethrvtime() -#define sys_get_proc_cputime(t,tp) (t) = sys_gethrvtime(), \ - (tp).tv_sec = (time_t)((t)/1000000000LL), \ - (tp).tv_nsec = (long)((t)%1000000000LL) +#define sys_get_cputime(t,tp) (t) = sys_gethrvtime(), \ + (tp).tv_sec = (time_t)((t)/1000000000LL), \ + (tp).tv_nsec = (long)((t)%1000000000LL) int sys_start_hrvtime(void); int sys_stop_hrvtime(void); #elif defined(HAVE_CLOCK_GETTIME_CPU_TIME) #define sys_clock_gettime(cid,tp) clock_gettime((cid),&(tp)) -#define sys_get_proc_cputime(t,tp) sys_clock_gettime(CLOCK_PROCESS_CPUTIME_ID,(tp)) +#define sys_get_cputime(t,tp) sys_clock_gettime(CLOCK_THREAD_CPUTIME_ID,(tp)) #endif #endif |