Skip to content

Commit

Permalink
Gator 9.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bengaineyarm committed Jul 16, 2024
1 parent b458f5d commit b446164
Show file tree
Hide file tree
Showing 137 changed files with 7,126 additions and 6,063 deletions.
39 changes: 11 additions & 28 deletions daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ SET(HWCPIPE_ENABLE_SYMBOLS_VISIBILITY OFF CACHE BOOL "")
SET(HWCPIPE_ENABLE_RTTI OFF CACHE BOOL "")
SET(HWCPIPE_WERROR OFF CACHE BOOL "")
SET(HWCPIPE_WALL OFF CACHE BOOL "")
SET(HWCPIPE_ENABLE_NEURAL_ENGINE OFF CACHE BOOL "")
SET(HWCPIPE_ENABLE_END_TO_END_TESTS OFF CACHE BOOL "")
ADD_SUBDIRECTORY(hwcpipe2)

Expand All @@ -69,7 +70,7 @@ ENDIF()

MESSAGE(STATUS "GATORD_BUILD_ID = ${GATORD_BUILD_ID}")

SET(GATORD_C_CXX_FLAGS "${GATORD_C_CXX_FLAGS} -DCONFIG_SUPPORT_PROC_POLLING=0")
SET(GATORD_C_CXX_FLAGS "${GATORD_C_CXX_FLAGS}")

IF(NOT CONFIG_PREFER_SYSTEM_WIDE_MODE)
SET(GATORD_C_CXX_FLAGS "${GATORD_C_CXX_FLAGS} -DCONFIG_PREFER_SYSTEM_WIDE_MODE=0")
Expand Down Expand Up @@ -112,6 +113,12 @@ INCLUDE_DIRECTORIES(SYSTEM
${CMAKE_CURRENT_SOURCE_DIR}/extheaders
${CMAKE_CURRENT_SOURCE_DIR}/libsensors)

#Get copyright year from git
find_package(Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%cd --date=format:%Y
OUTPUT_VARIABLE COPYRIGHT_YEAR
OUTPUT_STRIP_TRAILING_WHITESPACE)

# This file is generated and contains a hash of the source files
SET(GENERATED_MD5_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/SrcMd5.cpp)
SET(GENERATED_MD5_FILE ${CMAKE_CURRENT_BINARY_DIR}/SrcMd5.md5)
Expand Down Expand Up @@ -566,6 +573,8 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/metrics/definitions.hpp
${CMAKE_CURRENT_SOURCE_DIR}/metrics/group_generator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/metrics/group_generator.hpp
${CMAKE_CURRENT_SOURCE_DIR}/metrics/metric_group_set.hpp
${CMAKE_CURRENT_SOURCE_DIR}/metrics/metric_group_set.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mali_userspace/MaliDevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mali_userspace/MaliDevice.h
${CMAKE_CURRENT_SOURCE_DIR}/mali_userspace/MaliGPUClockPolledDriverCounter.h
Expand All @@ -581,32 +590,6 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mali_userspace/MaliHwCntrTask.h
${CMAKE_CURRENT_SOURCE_DIR}/mali_userspace/MaliInstanceLocator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mali_userspace/MaliInstanceLocator.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/CounterHelpers.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/GlobalCounter.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/GlobalPoller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/GlobalPoller.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/GlobalStateChangeHandler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/GlobalStateChangeHandler.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/GlobalStatsTracker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/GlobalStatsTracker.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/MixedFrameBuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/MixedFrameBuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/NonRootCounter.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/NonRootDriver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/NonRootDriver.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/NonRootSource.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/NonRootSource.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/PerCoreMixedFrameBuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/PerCoreMixedFrameBuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/ProcessCounter.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/ProcessPoller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/ProcessPoller.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/ProcessStateChangeHandler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/ProcessStateChangeHandler.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/ProcessStateTracker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/ProcessStateTracker.h
${CMAKE_CURRENT_SOURCE_DIR}/non_root/ProcessStatsTracker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/non_root/ProcessStatsTracker.h
${CMAKE_CURRENT_SOURCE_DIR}/xml/CurrentConfigXML.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xml/CurrentConfigXML.h
${CMAKE_CURRENT_SOURCE_DIR}/xml/EventsXMLHelpers.cpp
Expand Down Expand Up @@ -663,7 +646,7 @@ SET(FILES_TO_HASH ${FILES_TO_HASH}
${CMAKE_CURRENT_SOURCE_DIR}/defaults.xml)
LIST(FILTER FILES_TO_HASH EXCLUDE REGEX "/ipc/proto/generated/|SrcMd5\\.cpp|_xml\\.h|events\\.xml")

CREATE_SRC_MD5("gSrcMd5" "gBuildId" "${GATORD_BUILD_ID}" "${GENERATED_MD5_SOURCE}" "${GENERATED_MD5_FILE}" ${FILES_TO_HASH})
CREATE_SRC_MD5("gSrcMd5" "gBuildId" "gCopyrightYear" "${GATORD_BUILD_ID}" "${COPYRIGHT_YEAR}" "${GENERATED_MD5_SOURCE}" "${GENERATED_MD5_FILE}" ${FILES_TO_HASH})

# Build the merged events.xml
FILE(GLOB EVENTS_XML_FILES
Expand Down
37 changes: 35 additions & 2 deletions daemon/Child.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "lib/Waiter.h"
#include "logging/suppliers.h"
#include "mali_userspace/MaliHwCntrSource.h"
#include "metrics/metric_group_set.hpp"
#include "xml/EventsXML.h"

#include <algorithm>
Expand All @@ -50,10 +51,12 @@
#include <mutex>
#include <set>
#include <string>
#include <string_view>
#include <thread>
#include <utility>
#include <vector>

#include <linux/prctl.h>
#include <mxml.h>
#include <semaphore.h>
#include <sys/epoll.h>
Expand Down Expand Up @@ -157,11 +160,38 @@ Child::~Child()
runtime_assert(prevSingleton == this, "Exchanged Child::gSingleton with something other than this");
}

namespace {
CounterConfiguration counterConfigFromName(std::string_view name)
{
CounterConfiguration result {};
result.counterName = name;
return result;
}

std::set<CounterConfiguration> metricsToBeEnabled(metrics::metric_group_set_t const & metricGroups,
Drivers & drivers)
{
std::set<CounterConfiguration> metrics {};
for (Driver * const driver : drivers.getAll()) {
std::set<std::string_view> const metricIds = driver->metricsSupporting(metricGroups);
for (auto const & id : metricIds) {
metrics.insert(counterConfigFromName(id));
}
}
return metrics;
}

bool userSpecifiedNoCountersOnCmdLine(Child::Config const & config)
{
static const metrics::metric_group_set_t empty {};
return config.events.empty() && config.spes.empty() && config.metric_groups == empty;
}
}

void Child::run()
{
prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(&"gatord-child"), 0, 0, 0);

// TODO: better place for this
agent_workers_process->start();

// Disable line wrapping when generating xml files; carriage returns and indentation to be added manually
Expand All @@ -175,6 +205,9 @@ void Child::run()

std::set<SpeConfiguration> speConfigs = config.spes;
std::set<CounterConfiguration> counterConfigs = config.events;
std::set<CounterConfiguration> metrics = metricsToBeEnabled(config.metric_groups, drivers);
counterConfigs.insert(metrics.begin(), metrics.end());

bool countersAreDefaults = false;
const auto checkError = [](const std::string & error) {
if (!error.empty()) {
Expand All @@ -184,7 +217,7 @@ void Child::run()

// Only read the configuration.xml if no counters were already given (via cmdline) or the configuration.xml
// was explicitly given. Given counters take priority.
if ((config.events.empty() && config.spes.empty()) || gSessionData.mConfigurationXMLPath != nullptr) {
if (userSpecifiedNoCountersOnCmdLine(config) || gSessionData.mConfigurationXMLPath != nullptr) {
auto && result = configuration_xml::getConfigurationXML(primarySourceProvider.getCpuInfo().getClusters());
countersAreDefaults = result.isDefault;
for (auto && counter : result.counterConfigurations) {
Expand Down
4 changes: 3 additions & 1 deletion daemon/Child.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2010-2023 by Arm Limited. All rights reserved. */
/* Copyright (C) 2010-2024 by Arm Limited. All rights reserved. */

#ifndef __CHILD_H__
#define __CHILD_H__
Expand All @@ -10,6 +10,7 @@
#include "handleException.h"
#include "lib/AutoClosingFd.h"
#include "logging/suppliers.h"
#include "metrics/metric_group_set.hpp"

#include <atomic>
#include <memory>
Expand All @@ -31,6 +32,7 @@ class Child : private agents::i_agent_worker_manager_callbacks_t {
struct Config {
std::set<CounterConfiguration> events;
std::set<SpeConfiguration> spes;
metrics::metric_group_set_t metric_groups;
};

static std::unique_ptr<Child> createLocal(agents::i_agent_spawner_t & hi_priv_spawner,
Expand Down
12 changes: 5 additions & 7 deletions daemon/Config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2010-2023 by Arm Limited. All rights reserved. */
/* Copyright (C) 2010-2024 by Arm Limited. All rights reserved. */

#ifndef CONFIG_H
#define CONFIG_H
Expand All @@ -8,15 +8,13 @@

#define ARRAY_LENGTH(A) static_cast<int>(sizeof(A) / sizeof((A)[0]))

#define MAX_PERFORMANCE_COUNTERS 256

// feature control options
#ifndef CONFIG_PREFER_SYSTEM_WIDE_MODE
#define CONFIG_PREFER_SYSTEM_WIDE_MODE 1
#endif

#ifndef CONFIG_SUPPORT_PROC_POLLING
#define CONFIG_SUPPORT_PROC_POLLING 0
#endif

#if CONFIG_SUPPORT_PROC_POLLING
#error "CONFIG_SUPPORT_PROC_POLLING is no longer supported"
#endif
Expand All @@ -34,8 +32,8 @@
#define CONFIG_ASSUME_PERF_HIGH_PARANOIA 1
#endif

#if !CONFIG_SUPPORT_PERF && !CONFIG_SUPPORT_PROC_POLLING
#error "at least one of CONFIG_SUPPORT_PERF and CONFIG_SUPPORT_PROC_POLLING must be set"
#if !CONFIG_SUPPORT_PERF
#error "CONFIG_SUPPORT_PERF must be set"
#endif

#ifndef CONFIG_PERF_SUPPORT_REGISTER_UNWINDING
Expand Down
36 changes: 27 additions & 9 deletions daemon/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define CONFIGURATION_H_

#include "EventCode.h"
#include "linux/perf/PerfEventGroupIdentifier.h"

#include <set>
#include <string>
Expand All @@ -12,10 +13,11 @@ enum SampleRate { high = 10007, normal = 1009, normal_x2 = 2003, low = 101, none

enum class CaptureOperationMode {
system_wide = 0,
application_inherit = 1,
application_no_inherit = 2,
application_poll = 3,
application_experimental_patch = 4,
application_default = 1,
application_inherit = 2,
application_no_inherit = 3,
application_poll = 4,
application_experimental_patch = 5,
};

[[nodiscard]] constexpr bool isCaptureOperationModeSystemWide(CaptureOperationMode mode)
Expand All @@ -24,6 +26,7 @@ enum class CaptureOperationMode {

case CaptureOperationMode::system_wide:
return true;
case CaptureOperationMode::application_default:
case CaptureOperationMode::application_inherit:
case CaptureOperationMode::application_no_inherit:
case CaptureOperationMode::application_poll:
Expand All @@ -33,7 +36,8 @@ enum class CaptureOperationMode {
}
}

[[nodiscard]] constexpr bool isCaptureOperationModeSupportingCounterGroups(CaptureOperationMode mode)
[[nodiscard]] constexpr bool isCaptureOperationModeSupportingCounterGroups(CaptureOperationMode mode,
bool supports_inherit_sample_read)
{
switch (mode) {

Expand All @@ -42,21 +46,25 @@ enum class CaptureOperationMode {
case CaptureOperationMode::application_poll:
case CaptureOperationMode::application_experimental_patch:
return true;
case CaptureOperationMode::application_default:
return supports_inherit_sample_read;
case CaptureOperationMode::application_inherit:
default:
return false;
}
}

[[nodiscard]] constexpr bool isCaptureOperationModeSupportingMetrics(CaptureOperationMode mode)
[[nodiscard]] constexpr bool isCaptureOperationModeSupportingMetrics(CaptureOperationMode mode,
bool supports_inherit_sample_read)
{
return isCaptureOperationModeSupportingCounterGroups(mode);
return isCaptureOperationModeSupportingCounterGroups(mode, supports_inherit_sample_read);
}

[[nodiscard]] constexpr bool isCaptureOperationModeSupportingUsesInherit(CaptureOperationMode mode)
[[nodiscard]] constexpr bool isCaptureOperationModeSupportingUsesInherit(CaptureOperationMode mode,
bool /*supports_inherit_sample_read*/)
{
switch (mode) {

case CaptureOperationMode::application_default:
case CaptureOperationMode::application_inherit:
case CaptureOperationMode::application_experimental_patch:
return true;
Expand All @@ -79,6 +87,16 @@ struct SpeConfiguration {
uint64_t event_filter_mask {}; // if 0 filtering is disabled, else equals PMSEVFR_EL1 (ref doc).
std::set<SpeOps> ops {};
int min_latency = 0;

static constexpr std::string_view workflow_spe {"workflow_spe"};

[[nodiscard]] bool applies_to_counter(std::string_view const counter_name,
PerfEventGroupIdentifier const & pegi) const
{
return id == counter_name || //
(id == workflow_spe && //
pegi.getType() == PerfEventGroupIdentifier::Type::SPE);
}
};

inline bool operator==(const SpeConfiguration & lhs, const SpeConfiguration & rhs)
Expand Down
16 changes: 1 addition & 15 deletions daemon/CpuUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2013-2023 by Arm Limited. All rights reserved. */
/* Copyright (C) 2013-2024 by Arm Limited. All rights reserved. */

#include "CpuUtils.h"

Expand Down Expand Up @@ -264,20 +264,6 @@ namespace cpu_utils {
cpuIds.size());
}
}
//
// when we don't care about onlining the cores, just read them directly, one by one, any that are offline will be ignored anyway
//
else {
for (unsigned cpu = 0; cpu < cpuIds.size(); ++cpu) {
if (collected_properties.count(cpu) == 0) {
auto const properties = PerCoreIdentificationThread::detectFor(cpu);
auto const it = collected_properties.emplace(cpu, properties).first;
for (auto const sibling : it->second.core_siblings) {
collected_properties.try_emplace(sibling, properties);
}
}
}
}

// lock to prevent concurrent access to maps if one of the threads stalls
std::lock_guard<std::mutex> lock(mutex);
Expand Down
4 changes: 3 additions & 1 deletion daemon/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "CapturedSpe.h"
#include "Constant.h"
#include "metrics/metric_group_set.hpp"

#include <cstdint>
#include <functional>
#include <optional>
#include <set>
Expand Down Expand Up @@ -73,6 +73,8 @@ class Driver {
//Any warning messages to be displayed in Streamline post analysis of a capture.
[[nodiscard]] virtual std::vector<std::string> get_other_warnings() const { return {}; }

virtual std::set<std::string_view> metricsSupporting(metrics::metric_group_set_t const & /*unused*/) { return {}; };

// name pointer is not owned by this so should just be copied
Driver(const Driver &) = default;
Driver & operator=(const Driver &) = default;
Expand Down
8 changes: 6 additions & 2 deletions daemon/DriverCounter.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Copyright (C) 2013-2021 by Arm Limited. All rights reserved. */
/* Copyright (C) 2013-2024 by Arm Limited. All rights reserved. */

#ifndef NATIVE_GATOR_DAEMON_DRIVERCOUNTER_H_
#define NATIVE_GATOR_DAEMON_DRIVERCOUNTER_H_

#include "Driver.h"
#include "metrics/metric_group_set.hpp"

#include <string>

Expand All @@ -27,6 +27,10 @@ class DriverCounter {
bool isEnabled() const { return mEnabled; }
void setEnabled(const bool enabled) { mEnabled = enabled; }
virtual int64_t read() { return -1; }
[[nodiscard]] virtual bool supportsAtLeastOne(metrics::metric_group_set_t const & /*unused*/) const
{
return false;
}

private:
DriverCounter * const mNext;
Expand Down
Loading

0 comments on commit b446164

Please sign in to comment.