Change QueryCacheParams to return if there was an error and handle that during Initialize

PiperOrigin-RevId: 617949545
diff --git a/ruy/cpuinfo.cc b/ruy/cpuinfo.cc
index 0969cd7..5daee0b 100644
--- a/ruy/cpuinfo.cc
+++ b/ruy/cpuinfo.cc
@@ -39,7 +39,7 @@
 }
 
 namespace {
-void QueryCacheParams(CpuCacheParams* cache_params) {
+bool QueryCacheParams(CpuCacheParams* cache_params) {
   const int processors_count = cpuinfo_get_processors_count();
   RUY_DCHECK_GT(processors_count, 0);
   int overall_local_cache_size = std::numeric_limits<int>::max();
@@ -57,14 +57,16 @@
                    // L2.
       }
       if (!cache->processor_count) {
-        continue;  // crashes from Chrome on Android suggests that might happen?
+        // This may happen in a sand-boxed process, e.g.: a browser renderer.
+        continue;
       }
       const cpuinfo_processor* processor_start =
           cpuinfo_get_processor(cache->processor_start);
       const cpuinfo_processor* processor_end = cpuinfo_get_processor(
           cache->processor_start + cache->processor_count - 1);
       if (!processor_start || !processor_end) {
-        continue;  // crashes from Chrome on Android suggests this might happen.
+        // This may happen in a sand-boxed process, e.g.: a browser renderer.
+        continue;
       }
       const bool is_local = processor_start->core == processor_end->core;
       if (is_local) {
@@ -76,8 +78,9 @@
     if (!local_cache_size) {
       local_cache_size = last_level_cache_size;
     }
-    RUY_DCHECK_GT(local_cache_size, 0);
-    RUY_DCHECK_GT(last_level_cache_size, 0);
+    if (local_cache_size == 0 || last_level_cache_size == 0) {
+      return false;
+    }
     RUY_DCHECK_GE(last_level_cache_size, local_cache_size);
     overall_local_cache_size =
         std::min(overall_local_cache_size, local_cache_size);
@@ -86,6 +89,7 @@
   }
   cache_params->local_cache_size = overall_local_cache_size;
   cache_params->last_level_cache_size = overall_last_level_cache_size;
+  return true;
 }
 }  // end namespace
 
@@ -95,7 +99,10 @@
     MakeDummyCacheParams(&cache_params_);
     return InitStatus::kFailed;
   }
-  QueryCacheParams(&cache_params_);
+  if (!QueryCacheParams(&cache_params_)) {
+    MakeDummyCacheParams(&cache_params_);
+    return InitStatus::kFailed;
+  }
   return InitStatus::kInitialized;
 }
 
diff --git a/ruy/profiler/instrumentation.h b/ruy/profiler/instrumentation.h
index 2b15ae3..c4df1e6 100644
--- a/ruy/profiler/instrumentation.h
+++ b/ruy/profiler/instrumentation.h
@@ -19,7 +19,6 @@
 #ifdef RUY_PROFILER
 #include <cstdio>
 #include <mutex>
-#include <string>
 #include <vector>
 #endif