Sun, 18 Sep 2016 13:43:10 +0800
os::active_processor_count() is modified to return the number of processors numactl-binded.
src/os/linux/vm/os_linux.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/os/linux/vm/os_linux.cpp Sat Sep 17 03:44:08 2016 -0400 1.2 +++ b/src/os/linux/vm/os_linux.cpp Sun Sep 18 13:43:10 2016 +0800 1.3 @@ -4985,10 +4985,40 @@ 1.4 } 1.5 }; 1.6 1.7 +#ifdef MIPS64 1.8 +/* 2016/9/18 Jin 1.9 + * Refer to: libnuma_init() */ 1.10 +int get_available_cpus() { 1.11 + typedef int (*numa_num_task_cpus_t)(void); 1.12 + static numa_num_task_cpus_t _numa_num_task_cpus; 1.13 + 1.14 + void *handle = dlopen("libnuma.so.1", RTLD_LAZY); 1.15 + 1.16 + if (handle == NULL) 1.17 + return sysconf(_SC_NPROCESSORS_ONLN); 1.18 + 1.19 + _numa_num_task_cpus = CAST_FROM_FN_PTR(numa_num_task_cpus_t, dlsym(handle, "numa_num_task_cpus")); 1.20 + 1.21 + if (_numa_num_task_cpus == NULL) { 1.22 + dlclose(handle); 1.23 + return sysconf(_SC_NPROCESSORS_ONLN); 1.24 + } 1.25 + 1.26 + int ret = _numa_num_task_cpus(); 1.27 + dlclose(handle); 1.28 + return ret; 1.29 +} 1.30 +#endif 1.31 + 1.32 int os::active_processor_count() { 1.33 // Linux doesn't yet have a (official) notion of processor sets, 1.34 // so just return the number of online processors. 1.35 +#ifdef MIPS64 1.36 + int online_cpus = get_available_cpus(); 1.37 +#else 1.38 int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN); 1.39 +#endif 1.40 + 1.41 assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check"); 1.42 return online_cpus; 1.43 }