changeset 50117:9cf8b180ec25

ZGC: UPSTREAM: Introduce os::processor_id() for Linux and Solaris
author duke
date Mon, 30 Apr 2018 11:35:41 +0200
parents 385e6d76e21a
children d259ba324bdf
files src/hotspot/os/linux/os_linux.cpp src/hotspot/os/solaris/os_solaris.cpp src/hotspot/os/solaris/os_solaris.hpp src/hotspot/share/runtime/os.hpp
diffstat 4 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/os/linux/os_linux.cpp	Mon Apr 30 11:35:41 2018 +0200
+++ b/src/hotspot/os/linux/os_linux.cpp	Mon Apr 30 11:35:41 2018 +0200
@@ -5179,6 +5179,10 @@
   return active_cpus;
 }
 
+int os::processor_id() {
+  return Linux::sched_getcpu();
+}
+
 void os::set_native_thread_name(const char *name) {
   if (Linux::_pthread_setname_np) {
     char buf [16]; // according to glibc manpage, 16 chars incl. '/0'
--- a/src/hotspot/os/solaris/os_solaris.cpp	Mon Apr 30 11:35:41 2018 +0200
+++ b/src/hotspot/os/solaris/os_solaris.cpp	Mon Apr 30 11:35:41 2018 +0200
@@ -273,6 +273,10 @@
   return (julong)sysconf(_SC_AVPHYS_PAGES) * os::vm_page_size();
 }
 
+int os::Solaris::getcpuid() {
+  return ::getcpuid();
+}
+
 julong os::Solaris::_physical_memory = 0;
 
 julong os::physical_memory() {
@@ -291,6 +295,10 @@
                                      (julong)sysconf(_SC_PAGESIZE);
 }
 
+int os::processor_id() {
+  return Solaris::getcpuid();
+}
+
 int os::active_processor_count() {
   // User has overridden the number of active processors
   if (ActiveProcessorCount > 0) {
--- a/src/hotspot/os/solaris/os_solaris.hpp	Mon Apr 30 11:35:41 2018 +0200
+++ b/src/hotspot/os/solaris/os_solaris.hpp	Mon Apr 30 11:35:41 2018 +0200
@@ -261,6 +261,8 @@
   }
   static lgrp_cookie_t lgrp_cookie()                 { return _lgrp_cookie; }
 
+  static int getcpuid();
+
   static sigset_t* unblocked_signals();
   static sigset_t* vm_signals();
 
--- a/src/hotspot/share/runtime/os.hpp	Mon Apr 30 11:35:41 2018 +0200
+++ b/src/hotspot/share/runtime/os.hpp	Mon Apr 30 11:35:41 2018 +0200
@@ -233,6 +233,9 @@
   static bool has_allocatable_memory_limit(julong* limit);
   static bool is_server_class_machine();
 
+  // CPU id
+  static int processor_id();
+
   // number of CPUs
   static int processor_count() {
     return _processor_count;