diff options
author | 2022-02-04 14:41:46 +0000 | |
---|---|---|
committer | 2022-02-07 13:01:08 +0000 | |
commit | 79bdf6084b2cf00603588d549441bf2988ead313 (patch) | |
tree | 7ff4505443f614f0e57c39ecaa62769523c0a6f8 | |
parent | ae148feea58c69acd11722e82b1be7bf2324eadb (diff) |
Improve instruction set variants' logging
Follow-up to aosp/1970941, de-duplicating call via android::base::Join and also adding logging to Arm32.
Test: Presubmit tests
Change-Id: I49674b7a7703571c15dbf15bd10479e37663f407
-rw-r--r-- | runtime/arch/arm/instruction_set_features_arm.cc | 16 | ||||
-rw-r--r-- | runtime/arch/arm64/instruction_set_features_arm64.cc | 19 | ||||
-rw-r--r-- | runtime/arch/instruction_set_features.cc | 10 | ||||
-rw-r--r-- | runtime/arch/instruction_set_features.h | 5 | ||||
-rw-r--r-- | runtime/arch/x86/instruction_set_features_x86.cc | 12 |
5 files changed, 34 insertions, 28 deletions
diff --git a/runtime/arch/arm/instruction_set_features_arm.cc b/runtime/arch/arm/instruction_set_features_arm.cc index 6c46f28024..64ed2a7d4b 100644 --- a/runtime/arch/arm/instruction_set_features_arm.cc +++ b/runtime/arch/arm/instruction_set_features_arm.cc @@ -29,6 +29,8 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> +#include "base/array_ref.h" + #include <cpu_features_macros.h> #ifdef CPU_FEATURES_ARCH_ARM @@ -106,7 +108,19 @@ ArmFeaturesUniquePtr ArmInstructionSetFeatures::FromVariant( if (!FindVariantInArray(arm_variants_with_default_features, arraysize(arm_variants_with_default_features), variant)) { - *error_msg = StringPrintf("Attempt to use unsupported ARM variant: %s", variant.c_str()); + std::ostringstream os; + os << "Unexpected CPU variant for Arm: " << variant << ".\n" + << "Known variants with armv8a support: " + << android::base::Join(ArrayRef<const char* const>(arm_variants_with_armv8a), ", ") + << ".\n" + << "Known variants with divide support: " + << android::base::Join(ArrayRef<const char* const>(arm_variants_with_div), ", ") << ".\n" + << "Known variants with LPAE support: " + << android::base::Join(ArrayRef<const char* const>(arm_variants_with_lpae), ", ") << ".\n" + << "Other known variants: " + << android::base::Join(ArrayRef<const char* const>(arm_variants_with_default_features), + ", "); + *error_msg = os.str(); return nullptr; } else { // Warn if we use the default features. diff --git a/runtime/arch/arm64/instruction_set_features_arm64.cc b/runtime/arch/arm64/instruction_set_features_arm64.cc index e65514e709..ad082aed1f 100644 --- a/runtime/arch/arm64/instruction_set_features_arm64.cc +++ b/runtime/arch/arm64/instruction_set_features_arm64.cc @@ -28,6 +28,7 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> +#include "base/array_ref.h" #include "base/stl_util.h" #include <cpu_features_macros.h> @@ -131,8 +132,9 @@ Arm64FeaturesUniquePtr Arm64InstructionSetFeatures::FromVariant( bool has_sve = false; if (!needs_a53_835769_fix) { - // Check to see if this is an expected variant. - static const char* arm64_known_variants[] = { + // Check to see if this is an expected variant. `other_arm64_known_variants` contains the + // variants which do *not* need a fix for a53 erratum 835769. + static const char* other_arm64_known_variants[] = { "cortex-a35", "cortex-a55", "cortex-a75", @@ -145,11 +147,16 @@ Arm64FeaturesUniquePtr Arm64InstructionSetFeatures::FromVariant( "kryo385", "kryo785", }; - if (!FindVariantInArray(arm64_known_variants, arraysize(arm64_known_variants), variant)) { + if (!FindVariantInArray( + other_arm64_known_variants, arraysize(other_arm64_known_variants), variant)) { std::ostringstream os; - os << "Unexpected CPU variant for Arm64: " << variant << ".\n"; - os << "Known variants: "; - CommaSeparateVariants(os, arm64_known_variants, arraysize(arm64_known_variants)); + os << "Unexpected CPU variant for Arm64: " << variant << ".\n" + << "Known variants that need a fix for a53 erratum 835769: " + << android::base::Join(ArrayRef<const char* const>(arm64_variants_with_a53_835769_bug), + ", ") + << ".\n" + << "Known variants that do not need a fix for a53 erratum 835769: " + << android::base::Join(ArrayRef<const char* const>(other_arm64_known_variants), ", "); *error_msg = os.str(); return nullptr; } diff --git a/runtime/arch/instruction_set_features.cc b/runtime/arch/instruction_set_features.cc index 5ae920bef1..ec1e340245 100644 --- a/runtime/arch/instruction_set_features.cc +++ b/runtime/arch/instruction_set_features.cc @@ -267,16 +267,6 @@ bool InstructionSetFeatures::FindVariantInArray(const char* const variants[], si return std::find(begin, end, variant) != end; } -void InstructionSetFeatures::CommaSeparateVariants(std::ostream& os, - const char* const variants[], - size_t num_variants) { - std::string separator = ""; - for (size_t i = 0u; i < num_variants; ++i) { - os << separator << variants[i]; - separator = ", "; - } -} - std::unique_ptr<const InstructionSetFeatures> InstructionSetFeatures::AddRuntimeDetectedFeatures( const InstructionSetFeatures *features ATTRIBUTE_UNUSED) const { UNIMPLEMENTED(FATAL) << kRuntimeISA; diff --git a/runtime/arch/instruction_set_features.h b/runtime/arch/instruction_set_features.h index 4fd96566ed..b80d36f153 100644 --- a/runtime/arch/instruction_set_features.h +++ b/runtime/arch/instruction_set_features.h @@ -130,11 +130,6 @@ class InstructionSetFeatures { static bool FindVariantInArray(const char* const variants[], size_t num_variants, const std::string& variant); - // Comma separates the variants and adds them to the `os` buffer. - static void CommaSeparateVariants(std::ostream& os, - const char* const variants[], - size_t num_variants); - // Add architecture specific features in sub-classes. virtual std::unique_ptr<const InstructionSetFeatures> AddFeaturesFromSplitString(const std::vector<std::string>& features, diff --git a/runtime/arch/x86/instruction_set_features_x86.cc b/runtime/arch/x86/instruction_set_features_x86.cc index 11cfbc9469..325f47f8e3 100644 --- a/runtime/arch/x86/instruction_set_features_x86.cc +++ b/runtime/arch/x86/instruction_set_features_x86.cc @@ -24,6 +24,7 @@ #include <android-base/strings.h> #include "arch/x86_64/instruction_set_features_x86_64.h" +#include "base/array_ref.h" #include <cpu_features_macros.h> @@ -44,6 +45,7 @@ static constexpr const char* x86_known_variants[] = { "sandybridge", "silvermont", "kabylake", + "default", }; static constexpr const char* x86_variants_with_ssse3[] = { @@ -132,13 +134,11 @@ X86FeaturesUniquePtr X86InstructionSetFeatures::FromVariant( // Verify that variant is known. bool known_variant = FindVariantInArray(x86_known_variants, arraysize(x86_known_variants), variant); - if (!known_variant && variant != "default") { + if (!known_variant) { std::ostringstream os; - os << "Unexpected CPU variant for x86: " << variant << ".\n"; - os << "Known variants: "; - CommaSeparateVariants(os, x86_known_variants, arraysize(x86_known_variants)); - // `default` is a valid variant too. - os << ", default"; + os << "Unexpected CPU variant for x86: " << variant << ".\n" + << "Known variants: " + << android::base::Join(ArrayRef<const char* const>(x86_known_variants), ", "); LOG(WARNING) << os.str(); } |