Skip to content

Commit

Permalink
Gator 9.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bengaineyarm committed Oct 23, 2024
1 parent fe21b00 commit 7f98149
Show file tree
Hide file tree
Showing 62 changed files with 1,269 additions and 964 deletions.
6 changes: 3 additions & 3 deletions build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ checkout_vcpkg() {
echo "Fetching vcpkg git submodule"
git submodule update --init
# checkout manually?
elif [ ! -d "${root}/vcpkg/.git" ]; then
elif [ ! -e "${root}/vcpkg/.git" ]; then
echo "Cloning vcpkg git repo into '${root}/vcpkg/'"
git clone https://github.com/microsoft/vcpkg.git "${root}/vcpkg/"
echo "Switching to correct commit"
git -C "${root}/vcpkg/" clean -ffxd
git -C "${root}/vcpkg/" reset --hard "${vcpkg_commit}"
git -C "${root}/vcpkg/" reset --hard "${vcpkg_commit}" --
fi
# Now bootstrap it?
if [ ! -f "${exe_path}" ] || [ ! -r "${exe_path}" ] || [ ! -x "${exe_path}" ]; then
Expand All @@ -114,7 +114,7 @@ checkout_perfetto() {
echo "Fetching perfetto git submodule"
git submodule update --init
# checkout manually?
elif [ ! -d "${root}/ext/perfetto/.git" ]; then
elif [ ! -e "${root}/ext/perfetto/.git" ]; then
echo "Cloning perfetto git repo into '${root}/ext/perfetto/'"
git clone https://github.com/google/perfetto.git "${root}/ext/perfetto/"
echo "Switching to correct commit"
Expand Down
27 changes: 24 additions & 3 deletions daemon/AtraceDriver.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2014-2023 by Arm Limited. All rights reserved. */
/* Copyright (C) 2014-2024 by Arm Limited. All rights reserved. */

#include "AtraceDriver.h"

Expand All @@ -7,15 +7,19 @@
#include "Logging.h"
#include "OlyUtility.h"
#include "SimpleDriver.h"
#include "capture/Environment.h"
#include "lib/String.h"

#include <cstdlib>
#include <cstring>
#include <string_view>

#include <mxml.h>
#include <sys/types.h>
#include <unistd.h>

constexpr std::string_view ATRACE_ENABLE_TAG {"atrace_enable"};

class AtraceCounter : public DriverCounter {
public:
AtraceCounter(DriverCounter * next, const char * name, int flag);
Expand Down Expand Up @@ -48,10 +52,20 @@ void AtraceDriver::readEvents(mxml_node_t * const xml)
//LOG_SETUP("Atrace is disabled\nUnable to find setprop, this is not an Android target");
return;
}

if (!mFtraceDriver.isSupported()) {
LOG_SETUP("Atrace is disabled\nSupport for ftrace is required");
return;
}

const auto os_type = capture::detectOs();
const bool is_android = (os_type == capture::OsType::Android);

// Add this whenever ftrace is supported.
if (is_android) {
setCounters(new AtraceCounter(getCounters(), ATRACE_ENABLE_TAG.data(), 0));
}

if (getApplicationFullPath(mNotifyPath, sizeof(mNotifyPath)) != 0) {
LOG_DEBUG("Unable to determine the full path of gatord, the cwd will be used");
}
Expand All @@ -74,7 +88,7 @@ void AtraceDriver::readEvents(mxml_node_t * const xml)
continue;
}

if (strncmp(counter, "atrace_", 7) != 0) {
if (strncmp(counter, "atrace_", 7) != 0 || strcmp(counter, ATRACE_ENABLE_TAG.data()) == 0) {
continue;
}

Expand Down Expand Up @@ -122,15 +136,22 @@ void AtraceDriver::start()
if (!counter->isEnabled()) {
continue;
}
if (strcmp(counter->getName(), ATRACE_ENABLE_TAG.data()) == 0) {
isATraceEnabled = true;
}
flags |= counter->getFlag();
}

if (!isATraceEnabled) {
return;
}

setAtrace(flags);
}

void AtraceDriver::stop()
{
if (!mSupported) {
if (!mSupported || !isATraceEnabled) {
return;
}

Expand Down
5 changes: 3 additions & 2 deletions daemon/AtraceDriver.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2015-2023 by Arm Limited. All rights reserved. */
/* Copyright (C) 2015-2024 by Arm Limited. All rights reserved. */

#ifndef ATRACEDRIVER_H
#define ATRACEDRIVER_H
Expand All @@ -24,12 +24,13 @@ class AtraceDriver : public SimpleDriver {
void start();
void stop();

bool isSupported() const { return mSupported; }
[[nodiscard]] bool isSupported() const { return mSupported; }

private:
void setAtrace(int flags);

bool mSupported;
bool isATraceEnabled {false};
char mNotifyPath[256];
const FtraceDriver & mFtraceDriver;
};
Expand Down
274 changes: 137 additions & 137 deletions daemon/CCNDriver.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions daemon/CCNDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class CCNDriver : public Driver {
CCNDriver(CCNDriver &&) = delete;
CCNDriver & operator=(CCNDriver &&) = delete;

[[nodiscard]] bool claimCounter(Counter & counter) const override;
[[nodiscard]] bool claimCounter(Counter & counter) const override;
void resetCounters() override;
void setupCounter(Counter & counter) override;

void readEvents(mxml_node_t * const /*unused*/) override;
void readEvents(mxml_node_t * root) override;
[[nodiscard]] int writeCounters(available_counter_consumer_t const & consumer) const override;
void writeEvents(mxml_node_t * const /*unused*/) const override;
void writeEvents(mxml_node_t * root) const override;

static std::string validateCounters();

Expand Down
16 changes: 14 additions & 2 deletions daemon/Child.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Child.h"

#include "CapturedSpe.h"
#include "CapturedXML.h"
#include "Config.h"
#include "Configuration.h"
Expand Down Expand Up @@ -254,12 +255,22 @@ void Child::run()
}
}

// Check if any of the PMUs have correct SPE version
auto supportsSpev1p2 = false;
for (const auto & cluster : primarySourceProvider.getCpuInfo().getClusters()) {
const auto * speVersion = cluster.getSpeVersion();
if (speVersion != nullptr && strcmp(speVersion, "v1p0") != 0 && strcmp(speVersion, "v1p1") != 0) {
// Assume the speVersion is a supported version.
supportsSpev1p2 = true;
}
}

std::vector<CapturedSpe> capturedSpes;
for (const auto & speConfig : speConfigs) {
bool claimed = false;

for (Driver * driver : drivers.getAll()) {
auto && capturedSpe = driver->setupSpe(gSessionData.mSpeSampleRate, speConfig);
auto && capturedSpe = driver->setupSpe(gSessionData.mSpeSampleRate, speConfig, supportsSpev1p2);
if (capturedSpe) {
capturedSpes.push_back(std::move(*capturedSpe));
claimed = true;
Expand Down Expand Up @@ -395,7 +406,8 @@ void Child::run()
!gSessionData.mCaptureCommand.empty(),
*agent_workers_process);
if (newPrimarySource == nullptr) {
LOG_ERROR("%s", primarySourceProvider.getPrepareFailedMessage());
LOG_ERROR(
"Unable to communicate with the perf API. Please refer to streamline/gator/README.md for more information.");
handleException();
}

Expand Down
15 changes: 7 additions & 8 deletions daemon/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ enum class CaptureOperationMode {
return isCaptureOperationModeSupportingCounterGroups(mode, supports_inherit_sample_read);
}

[[nodiscard]] constexpr bool isCaptureOperationModeSupportingUsesInherit(CaptureOperationMode mode,
bool /*supports_inherit_sample_read*/)
[[nodiscard]] constexpr bool isCaptureOperationModeSupportingUsesInherit(CaptureOperationMode mode)
{
switch (mode) {
case CaptureOperationMode::application_default:
Expand All @@ -83,11 +82,11 @@ enum class SpeOps {
};

struct SpeConfiguration {
std::string id {};
std::string id;
uint64_t event_filter_mask {}; // if 0 filtering is disabled, else equals PMSEVFR_EL1 (ref doc).
std::set<SpeOps> ops {};
std::set<SpeOps> ops;
int min_latency = 0;

bool inverse_event_filter_mask {false}; // When this is set event_filter_mask will be set for PMSNEVFR_EL1
static constexpr std::string_view workflow_spe {"workflow_spe"};

[[nodiscard]] bool applies_to_counter(std::string_view const counter_name,
Expand Down Expand Up @@ -122,8 +121,8 @@ namespace std {
}

struct CounterConfiguration {
std::string counterName {};
EventCode event {};
std::string counterName;
EventCode event;
int count = 0;
int cores = 0;
};
Expand Down Expand Up @@ -151,7 +150,7 @@ namespace std {
}

struct TemplateConfiguration {
std::string raw {};
std::string raw;
};

#endif /* CONFIGURATION_H_ */
32 changes: 17 additions & 15 deletions daemon/ConfigurationXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@

#include <mxml.h>

static const char TAG_CONFIGURATION[] = "configuration";

static const char ATTR_COUNTER[] = "counter";

static const char CLUSTER_VAR[] = "${cluster}";

#define CONFIGURATION_REVISION 3

static void appendError(std::ostream & error, const std::string & possibleError)
{
if (!possibleError.empty()) {
if (error.tellp() != 0) {
error << "\n\n";
namespace {
constexpr const char * TAG_CONFIGURATION = "configuration";
constexpr const char * ATTR_COUNTER = "counter";
constexpr const char * CLUSTER_VAR = "${cluster}";

void appendError(std::ostream & error, const std::string & possibleError)
{
if (!possibleError.empty()) {
if (error.tellp() != 0) {
error << "\n\n";
}
error << possibleError;
}
error << possibleError;
}
}

Expand Down Expand Up @@ -162,25 +162,27 @@ namespace configuration_xml {
counterToEventMap);
}

appendError(error, drivers.getCcnDriver().validateCounters());
appendError(error, CCNDriver::validateCounters());

return error.str();
}

std::unique_ptr<char, void (*)(void *)> getDefaultConfigurationXml(lib::Span<const GatorCpu> clusters)
{
constexpr const std::size_t BUFFER_SIZE = 128;

// Resolve ${cluster}
mxml_node_t * xml = mxmlLoadString(nullptr, DEFAULTS_XML.data(), MXML_NO_CALLBACK);
for (mxml_node_t *node = mxmlFindElement(xml, xml, TAG_CONFIGURATION, nullptr, nullptr, MXML_DESCEND),
*next = mxmlFindElement(node, xml, TAG_CONFIGURATION, nullptr, nullptr, MXML_DESCEND);
node != nullptr;
node = next, next = mxmlFindElement(node, xml, TAG_CONFIGURATION, nullptr, nullptr, MXML_DESCEND)) {
const char * counter = mxmlElementGetAttr(node, ATTR_COUNTER);
if (counter != nullptr && strncmp(counter, CLUSTER_VAR, sizeof(CLUSTER_VAR) - 1) == 0) {
if (counter != nullptr && strncmp(counter, CLUSTER_VAR, strlen(CLUSTER_VAR)) == 0) {
for (const GatorCpu & cluster : clusters) {
mxml_node_t * n = mxmlNewElement(mxmlGetParent(node), TAG_CONFIGURATION);
copyMxmlElementAttrs(n, node);
lib::printf_str_t<1 << 7> buf {"%s%s", cluster.getId(), counter + sizeof(CLUSTER_VAR) - 1};
lib::printf_str_t<BUFFER_SIZE> buf {"%s%s", cluster.getId(), counter + strlen(CLUSTER_VAR)};
mxmlElementSetAttr(n, ATTR_COUNTER, buf);
}
mxmlDelete(node);
Expand Down
Loading

0 comments on commit 7f98149

Please sign in to comment.