From 3cb5f29064bb96da68008385d0aecbd43c2333e0 Mon Sep 17 00:00:00 2001 From: iveresov Date: Fri, 10 Apr 2015 15:27:05 -0700 Subject: [PATCH] 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect Summary: Chcek both l2-dcache-line-size and l2-cache-line-size properties to determine the size of the line Reviewed-by: kvn --- src/cpu/sparc/vm/vm_version_sparc.cpp | 4 +-- src/cpu/sparc/vm/vm_version_sparc.hpp | 6 ++-- .../vm/vm_version_solaris_sparc.cpp | 29 ++++++++++++++----- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/cpu/sparc/vm/vm_version_sparc.cpp b/src/cpu/sparc/vm/vm_version_sparc.cpp index 2fd9c396a..664f29e0f 100644 --- a/src/cpu/sparc/vm/vm_version_sparc.cpp +++ b/src/cpu/sparc/vm/vm_version_sparc.cpp @@ -37,7 +37,7 @@ int VM_Version::_features = VM_Version::unknown_m; const char* VM_Version::_features_str = ""; -unsigned int VM_Version::_L2_cache_line_size = 0; +unsigned int VM_Version::_L2_data_cache_line_size = 0; void VM_Version::initialize() { _features = determine_features(); @@ -363,7 +363,7 @@ void VM_Version::initialize() { #ifndef PRODUCT if (PrintMiscellaneous && Verbose) { - tty->print_cr("L2 cache line size: %u", L2_cache_line_size()); + tty->print_cr("L2 data cache line size: %u", L2_data_cache_line_size()); tty->print("Allocation"); if (AllocatePrefetchStyle <= 0) { tty->print_cr(": no prefetching"); diff --git a/src/cpu/sparc/vm/vm_version_sparc.hpp b/src/cpu/sparc/vm/vm_version_sparc.hpp index fa823863b..59969ed10 100644 --- a/src/cpu/sparc/vm/vm_version_sparc.hpp +++ b/src/cpu/sparc/vm/vm_version_sparc.hpp @@ -96,8 +96,8 @@ protected: static int _features; static const char* _features_str; - static unsigned int _L2_cache_line_size; - static unsigned int L2_cache_line_size() { return _L2_cache_line_size; } + static unsigned int _L2_data_cache_line_size; + static unsigned int L2_data_cache_line_size() { return _L2_data_cache_line_size; } static void print_features(); static int determine_features(); @@ -171,7 +171,7 @@ public: static const char* cpu_features() { return _features_str; } // default prefetch block size on sparc - static intx prefetch_data_size() { return L2_cache_line_size(); } + static intx prefetch_data_size() { return L2_data_cache_line_size(); } // Prefetch static intx prefetch_copy_interval_in_bytes() { diff --git a/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp b/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp index fcc5c3afd..8a3c46c2c 100644 --- a/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp +++ b/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp @@ -127,7 +127,7 @@ class PICL { bool is_inconsistent() { return _state == INCONSISTENT; } void set_inconsistent() { _state = INCONSISTENT; } - void visit(picl_nodehdl_t nodeh, const char* name) { + bool visit(picl_nodehdl_t nodeh, const char* name) { assert(!is_inconsistent(), "Precondition"); int curr; if (_picl->get_int_property(nodeh, name, &curr) == PICL_SUCCESS) { @@ -136,7 +136,9 @@ class PICL { } else if (curr != value()) { // following iterations set_inconsistent(); } + return true; } + return false; } }; @@ -153,8 +155,19 @@ class PICL { if (!l1_visitor->is_inconsistent()) { l1_visitor->visit(nodeh, "l1-dcache-line-size"); } - if (!l2_visitor->is_inconsistent()) { - l2_visitor->visit(nodeh, "l2-cache-line-size"); + static const char* l2_data_cache_line_property_name = NULL; + // On the first visit determine the name of the l2 cache line size property and memoize it. + if (l2_data_cache_line_property_name == NULL) { + assert(!l2_visitor->is_inconsistent(), "First iteration cannot be inconsistent"); + l2_data_cache_line_property_name = "l2-cache-line-size"; + if (!l2_visitor->visit(nodeh, l2_data_cache_line_property_name)) { + l2_data_cache_line_property_name = "l2-dcache-line-size"; + l2_visitor->visit(nodeh, l2_data_cache_line_property_name); + } + } else { + if (!l2_visitor->is_inconsistent()) { + l2_visitor->visit(nodeh, l2_data_cache_line_property_name); + } } if (l1_visitor->is_inconsistent() && l2_visitor->is_inconsistent()) { @@ -170,13 +183,13 @@ class PICL { UniqueValueVisitor* l2_visitor() { return &_l2_visitor; } }; int _L1_data_cache_line_size; - int _L2_cache_line_size; + int _L2_data_cache_line_size; public: static int visit_cpu(picl_nodehdl_t nodeh, void *state) { return CPUVisitor::visit(nodeh, state); } - PICL(bool is_fujitsu) : _L1_data_cache_line_size(0), _L2_cache_line_size(0), _dl_handle(NULL) { + PICL(bool is_fujitsu) : _L1_data_cache_line_size(0), _L2_data_cache_line_size(0), _dl_handle(NULL) { if (!open_library()) { return; } @@ -194,7 +207,7 @@ public: _L1_data_cache_line_size = cpu_visitor.l1_visitor()->value(); } if (cpu_visitor.l2_visitor()->is_assigned()) { - _L2_cache_line_size = cpu_visitor.l2_visitor()->value(); + _L2_data_cache_line_size = cpu_visitor.l2_visitor()->value(); } } _picl_shutdown(); @@ -203,7 +216,7 @@ public: } unsigned int L1_data_cache_line_size() const { return _L1_data_cache_line_size; } - unsigned int L2_cache_line_size() const { return _L2_cache_line_size; } + unsigned int L2_data_cache_line_size() const { return _L2_data_cache_line_size; } }; @@ -482,7 +495,7 @@ int VM_Version::platform_features(int features) { // Figure out cache line sizes using PICL PICL picl((features & sparc64_family_m) != 0); - _L2_cache_line_size = picl.L2_cache_line_size(); + _L2_data_cache_line_size = picl.L2_data_cache_line_size(); return features; } -- GitLab