8206919: s390: add missing info to vm_version_ext_s390 jdk-11+22
authorghaug
Tue, 10 Jul 2018 11:36:36 +0200
changeset 51034 9937ef7499dc
parent 51033 003aa3e59090
child 51035 0484b16ef437
8206919: s390: add missing info to vm_version_ext_s390 Reviewed-by: simonis, mdoerr
src/hotspot/cpu/s390/vm_version_ext_s390.cpp
src/hotspot/cpu/s390/vm_version_ext_s390.hpp
src/hotspot/cpu/s390/vm_version_s390.cpp
src/hotspot/cpu/s390/vm_version_s390.hpp
test/jdk/jdk/jfr/event/os/TestCPUInformation.java
--- a/src/hotspot/cpu/s390/vm_version_ext_s390.cpp	Wed Jul 11 13:41:25 2018 +0300
+++ b/src/hotspot/cpu/s390/vm_version_ext_s390.cpp	Tue Jul 10 11:36:36 2018 +0200
@@ -31,13 +31,23 @@
 int   VM_Version_Ext::_no_of_threads = 0;
 int   VM_Version_Ext::_no_of_cores = 0;
 int   VM_Version_Ext::_no_of_sockets = 0;
+bool  VM_Version_Ext::_initialized = false;
 char  VM_Version_Ext::_cpu_name[CPU_TYPE_DESC_BUF_SIZE] = {0};
 char  VM_Version_Ext::_cpu_desc[CPU_DETAILED_DESC_BUF_SIZE] = {0};
 
 // get cpu information.
-bool VM_Version_Ext::initialize_cpu_information(void) {
-  // Not yet implemented.
-  return false;
+void  VM_Version_Ext::initialize_cpu_information(void) {
+  // do nothing if cpu info has been initialized
+  if (_initialized) {
+    return;
+  }
+
+  _no_of_cores  = os::processor_count();
+  _no_of_threads = _no_of_cores;
+  _no_of_sockets = _no_of_cores;
+  snprintf(_cpu_name, CPU_TYPE_DESC_BUF_SIZE, "s390 %s", VM_Version::get_model_string());
+  snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "zArch %s", features_string());
+  _initialized = true;
 }
 
 int VM_Version_Ext::number_of_threads(void) {
@@ -56,9 +66,7 @@
 }
 
 const char* VM_Version_Ext::cpu_name(void) {
-  if (!initialize_cpu_information()) {
-    return NULL;
-  }
+  initialize_cpu_information();
   char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_TYPE_DESC_BUF_SIZE, mtTracing);
   if (NULL == tmp) {
     return NULL;
@@ -68,9 +76,7 @@
 }
 
 const char* VM_Version_Ext::cpu_description(void) {
-  if (!initialize_cpu_information()) {
-    return NULL;
-  }
+  initialize_cpu_information();
   char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_DETAILED_DESC_BUF_SIZE, mtTracing);
   if (NULL == tmp) {
     return NULL;
--- a/src/hotspot/cpu/s390/vm_version_ext_s390.hpp	Wed Jul 11 13:41:25 2018 +0300
+++ b/src/hotspot/cpu/s390/vm_version_ext_s390.hpp	Tue Jul 10 11:36:36 2018 +0200
@@ -43,10 +43,11 @@
   static int               _no_of_threads;
   static int               _no_of_cores;
   static int               _no_of_sockets;
+  static bool              _initialized;
   static char              _cpu_name[CPU_TYPE_DESC_BUF_SIZE];
   static char              _cpu_desc[CPU_DETAILED_DESC_BUF_SIZE];
 
-  static bool initialize_cpu_information(void);
+  static void initialize_cpu_information(void);
 
  public:
 
--- a/src/hotspot/cpu/s390/vm_version_s390.cpp	Wed Jul 11 13:41:25 2018 +0300
+++ b/src/hotspot/cpu/s390/vm_version_s390.cpp	Tue Jul 10 11:36:36 2018 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016, 2017 SAP SE. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 # include <sys/sysinfo.h>
 
 bool VM_Version::_is_determine_features_test_running  = false;
+const char*   VM_Version::_model_string;
 
 unsigned long VM_Version::_features[_features_buffer_len]           = {0, 0, 0, 0};
 unsigned long VM_Version::_cipher_features[_features_buffer_len]    = {0, 0, 0, 0};
@@ -248,32 +249,40 @@
 void VM_Version::set_features_string() {
 
   unsigned int ambiguity = 0;
+  _model_string = z_name[0];
   if (is_z13()) {
     _features_string = "System z G7-z13  (LDISP_fast, ExtImm, PCrel Load/Store, CmpB, Cond Load/Store, Interlocked Update, TxM, VectorInstr)";
+    _model_string = z_name[7];
     ambiguity++;
   }
   if (is_ec12()) {
     _features_string = "System z G6-EC12 (LDISP_fast, ExtImm, PCrel Load/Store, CmpB, Cond Load/Store, Interlocked Update, TxM)";
+    _model_string = z_name[6];
     ambiguity++;
   }
   if (is_z196()) {
     _features_string = "System z G5-z196 (LDISP_fast, ExtImm, PCrel Load/Store, CmpB, Cond Load/Store, Interlocked Update)";
+    _model_string = z_name[5];
     ambiguity++;
   }
   if (is_z10()) {
     _features_string = "System z G4-z10  (LDISP_fast, ExtImm, PCrel Load/Store, CmpB)";
+    _model_string = z_name[4];
     ambiguity++;
   }
   if (is_z9()) {
     _features_string = "System z G3-z9   (LDISP_fast, ExtImm), out-of-support as of 2016-04-01";
+    _model_string = z_name[3];
     ambiguity++;
   }
   if (is_z990()) {
     _features_string = "System z G2-z990 (LDISP_fast), out-of-support as of 2014-07-01";
+    _model_string = z_name[2];
     ambiguity++;
   }
   if (is_z900()) {
     _features_string = "System z G1-z900 (LDISP), out-of-support as of 2014-07-01";
+    _model_string = z_name[1];
     ambiguity++;
   }
 
--- a/src/hotspot/cpu/s390/vm_version_s390.hpp	Wed Jul 11 13:41:25 2018 +0300
+++ b/src/hotspot/cpu/s390/vm_version_s390.hpp	Tue Jul 10 11:36:36 2018 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -131,6 +131,7 @@
   static unsigned int  _Dcache_lineSize;
   static unsigned int  _Icache_lineSize;
   static bool          _is_determine_features_test_running;
+  static const char*   _model_string;
 
   static bool test_feature_bit(unsigned long* featureBuffer, int featureNum, unsigned int bufLen);
   static void set_features_string();
@@ -346,6 +347,7 @@
   static bool is_determine_features_test_running() { return _is_determine_features_test_running; }
 
   // CPU feature query functions
+  static const char* get_model_string()       { return _model_string; }
   static bool has_StoreFacilityListExtended() { return  (_features[0] & StoreFacilityListExtendedMask) == StoreFacilityListExtendedMask; }
   static bool has_Crypto()                    { return  (_features[0] & CryptoFacilityMask)            == CryptoFacilityMask; }
   static bool has_ETF2()                      { return  (_features[0] & ETF2Mask)                      == ETF2Mask; }
--- a/test/jdk/jdk/jfr/event/os/TestCPUInformation.java	Wed Jul 11 13:41:25 2018 +0300
+++ b/test/jdk/jdk/jfr/event/os/TestCPUInformation.java	Tue Jul 10 11:36:36 2018 +0200
@@ -53,8 +53,8 @@
             Events.assertField(event, "hwThreads").atLeast(1);
             Events.assertField(event, "cores").atLeast(1);
             Events.assertField(event, "sockets").atLeast(1);
-            Events.assertField(event, "cpu").containsAny("Intel", "AMD", "Unknown x86", "sparc", "ARM", "PPC", "PowerPC", "AArch64");
-            Events.assertField(event, "description").containsAny("Intel", "AMD", "Unknown x86", "SPARC", "ARM", "PPC", "PowerPC", "AArch64");
+            Events.assertField(event, "cpu").containsAny("Intel", "AMD", "Unknown x86", "sparc", "ARM", "PPC", "PowerPC", "AArch64", "s390");
+            Events.assertField(event, "description").containsAny("Intel", "AMD", "Unknown x86", "SPARC", "ARM", "PPC", "PowerPC", "AArch64", "zArch");
         }
     }
 }