Commit 919d3130 authored by Stanca Serban's avatar Stanca Serban
Browse files

Backed out changeset 0f0edda611cf (bug 1874454) for causing bp-nu bustages in...

Backed out changeset 0f0edda611cf (bug 1874454) for causing bp-nu bustages in CocoaHeterogeneousCpuInfo.cpp. CLOSED TREE
parent 73e42fe7
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -94,11 +94,9 @@ class PerformanceHintSession {
 * information.
 */
struct HeterogeneousCpuInfo {
  // We use a max of 32 because this was initially implemented only for Android
  // We use a max of 32 because currently this is only implemented for Android
  // where we are unlikely to need more CPUs than that, and it simplifies
  // dealing with cpu_set_t as CPU_SETSIZE is 32 on 32-bit Android.
  // If there are more than 32 CPU cores, the implementation should try to fill
  // first mBigCpus before adding anything to mMediumCpus or mLittleCpus.
  static const size_t MAX_CPUS = 32;
  size_t mTotalNumCpus;
  mozilla::BitSet<MAX_CPUS> mLittleCpus;
+0 −58
Original line number Diff line number Diff line
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */

#include <sys/types.h>
#include <sys/sysctl.h>
#include "mozilla/BitSet.h"
#include "nsSystemInfo.h"

namespace mozilla::hal_impl {

mozilla::Maybe<HeterogeneousCpuInfo> CreateHeterogeneousCpuInfo() {
#ifdef __aarch64__
  // As of now on Apple Silicon the number of *.logicalcpu_max is the same as
  // *.physicalcpu_max.
  size_t len = sizeof(uint32_t);
  uint32_t pCores = 0;
  if (sysctlbyname("hw.perflevel0.logicalcpu_max", &pCores, &len, nullptr, 0)) {
    return Nothing();
  }

  len = sizeof(uint32_t);
  uint32_t eCores = 0;
  if (sysctlbyname("hw.perflevel1.logicalcpu_max", &eCores, &len, nullptr, 0)) {
    return Nothing();
  }

  HeterogeneousCpuInfo info;
  info.mTotalNumCpus = pCores + eCores;

  // The API has currently a limit how many cpu cores it can tell about.
  for (uint32_t i = 0; i < HeterogeneousCpuInfo::MAX_CPUS; ++i) {
    if (pCores) {
      --pCores;
      info.mBigCpus[i] = true;
    } else if (eCores) {
      --eCores;
      info.mLittleCpus[i] = true;
    } else {
      break;
    }
  }

  return Some(info);
#else
  return Nothing();
#endif
}

const Maybe<HeterogeneousCpuInfo>& GetHeterogeneousCpuInfo() {
  static const Maybe<HeterogeneousCpuInfo> cpuInfo =
      CreateHeterogeneousCpuInfo();
  return cpuInfo;
}

}  // namespace mozilla::hal_impl
+1 −5
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
    ]
elif CONFIG["OS_TARGET"] == "Linux":
    UNIFIED_SOURCES += [
        "fallback/FallbackHeterogeneousCpuInfo.cpp",
        "fallback/FallbackScreenConfiguration.cpp",
        "fallback/FallbackSensor.cpp",
        "fallback/FallbackVibration.cpp",
@@ -64,7 +63,6 @@ elif CONFIG["OS_TARGET"] == "Linux":
        ]
elif CONFIG["OS_TARGET"] == "WINNT":
    UNIFIED_SOURCES += [
        "fallback/FallbackHeterogeneousCpuInfo.cpp",
        "fallback/FallbackVibration.cpp",
        "windows/WindowsProcessPriority.cpp",
        "windows/WindowsScreenConfiguration.cpp",
@@ -77,14 +75,12 @@ elif CONFIG["OS_TARGET"] == "WINNT":
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
    UNIFIED_SOURCES += [
        "cocoa/CocoaBattery.cpp",
        "cocoa/CocoaHeterogeneousCpuInfo.cpp",
        "fallback/FallbackProcessPriority.cpp",
        "fallback/FallbackScreenConfiguration.cpp",
        "fallback/FallbackVibration.cpp",
    ]
elif CONFIG["OS_TARGET"] in ("OpenBSD", "NetBSD", "FreeBSD", "DragonFly"):
    UNIFIED_SOURCES += [
        "fallback/FallbackHeterogeneousCpuInfo.cpp",
        "fallback/FallbackProcessPriority.cpp",
        "fallback/FallbackScreenConfiguration.cpp",
        "fallback/FallbackSensor.cpp",
@@ -101,7 +97,6 @@ elif CONFIG["OS_TARGET"] in ("OpenBSD", "NetBSD", "FreeBSD", "DragonFly"):
else:
    UNIFIED_SOURCES += [
        "fallback/FallbackBattery.cpp",
        "fallback/FallbackHeterogeneousCpuInfo.cpp",
        "fallback/FallbackProcessPriority.cpp",
        "fallback/FallbackScreenConfiguration.cpp",
        "fallback/FallbackSensor.cpp",
@@ -111,6 +106,7 @@ else:
# Fallbacks for backends implemented on Android only.
if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android":
    UNIFIED_SOURCES += [
        "fallback/FallbackHeterogeneousCpuInfo.cpp",
        "fallback/FallbackNetwork.cpp",
        "fallback/FallbackPerformanceHintManager.cpp",
    ]
+0 −2
Original line number Diff line number Diff line
@@ -113,8 +113,6 @@ static const char SandboxPolicyContent[] = R"SANDBOX_LITERAL(
    (sysctl-name "hw.pagesize_compat")
    (sysctl-name "hw.logicalcpu")
    (sysctl-name "hw.logicalcpu_max")
    (sysctl-name "hw.perflevel0.logicalcpu_max")
    (sysctl-name "hw.perflevel1.logicalcpu_max")
    (sysctl-name "hw.physicalcpu_max")
    (sysctl-name "hw.busfrequency_compat")
    (sysctl-name "hw.busfrequency_max")