Mercurial > hg > graal-compiler
diff src/os/linux/vm/os_linux.cpp @ 14726:92aa6797d639
Backed out merge changeset: b51e29501f30
Backed out merge revision to its first parent (8f483e200405)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 24 Mar 2014 21:30:43 +0100 |
parents | b51e29501f30 |
children |
line wrap: on
line diff
--- a/src/os/linux/vm/os_linux.cpp Fri Mar 21 16:36:59 2014 -0700 +++ b/src/os/linux/vm/os_linux.cpp Mon Mar 24 21:30:43 2014 +0100 @@ -5284,6 +5284,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { static bool proc_task_unchecked = true; + static const char *proc_stat_path = "/proc/%d/stat"; pid_t tid = thread->osthread()->thread_id(); char *s; char stat[2048]; @@ -5296,8 +5297,6 @@ long ldummy; FILE *fp; - snprintf(proc_name, 64, "/proc/%d/stat", tid); - // The /proc/<tid>/stat aggregates per-process usage on // new Linux kernels 2.6+ where NPTL is supported. // The /proc/self/task/<tid>/stat still has the per-thread usage. @@ -5309,11 +5308,12 @@ proc_task_unchecked = false; fp = fopen("/proc/self/task", "r"); if (fp != NULL) { - snprintf(proc_name, 64, "/proc/self/task/%d/stat", tid); + proc_stat_path = "/proc/self/task/%d/stat"; fclose(fp); } } + sprintf(proc_name, proc_stat_path, tid); fp = fopen(proc_name, "r"); if ( fp == NULL ) return -1; statlen = fread(stat, 1, 2047, fp);