Skip to content

Commit

Permalink
Gator 9.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bengaineyarm committed Jul 16, 2024
1 parent 28b2d94 commit b458f5d
Show file tree
Hide file tree
Showing 49 changed files with 326 additions and 382 deletions.
4 changes: 1 addition & 3 deletions daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/IMonitor.h
${CMAKE_CURRENT_SOURCE_DIR}/IRawFrameBuilder.h
${CMAKE_CURRENT_SOURCE_DIR}/ISender.h
${CMAKE_CURRENT_SOURCE_DIR}/ISummaryConsumer.h
${CMAKE_CURRENT_SOURCE_DIR}/LocalCapture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/LocalCapture.h
${CMAKE_CURRENT_SOURCE_DIR}/Logging.h
Expand All @@ -216,6 +215,7 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/MidgardDriver.h
${CMAKE_CURRENT_SOURCE_DIR}/Monitor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Monitor.h
${CMAKE_CURRENT_SOURCE_DIR}/monotonic_pair.h
${CMAKE_CURRENT_SOURCE_DIR}/NetDriver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/NetDriver.h
${CMAKE_CURRENT_SOURCE_DIR}/OlySocket.cpp
Expand Down Expand Up @@ -250,8 +250,6 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StreamlineSetup.h
${CMAKE_CURRENT_SOURCE_DIR}/StreamlineSetupLoop.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StreamlineSetupLoop.h
${CMAKE_CURRENT_SOURCE_DIR}/SummaryBuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SummaryBuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/Time.h
${CMAKE_CURRENT_SOURCE_DIR}/TtraceDriver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TtraceDriver.h
Expand Down
2 changes: 2 additions & 0 deletions daemon/CapturedXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ static mxml_node_t * getTree(bool includeTime,

auto * const target = mxmlNewElement(captured, "target");
mxmlElementSetAttrf(target, "sample_rate", "%d", gSessionData.mSampleRate);
mxmlElementSetAttrf(target, "sample_rate_gpu", "%d", gSessionData.mSampleRateGpu);

const auto & cpuInfo = primarySourceProvider.getCpuInfo();
mxmlElementSetAttr(target, "name", cpuInfo.getModelName());
const auto cpuIds = cpuInfo.getCpuIds();
Expand Down
2 changes: 1 addition & 1 deletion daemon/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <set>
#include <string>

enum SampleRate { high = 10007, normal = 1009, low = 101, none = 0, invalid = -1 };
enum SampleRate { high = 10007, normal = 1009, normal_x2 = 2003, low = 101, none = 0, invalid = -1 };

enum class CaptureOperationMode {
system_wide = 0,
Expand Down
11 changes: 9 additions & 2 deletions daemon/ExternalDriver.cpp
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. */

#include "ExternalDriver.h"

Expand All @@ -11,6 +11,7 @@
#include "SessionData.h"
#include "SimpleDriver.h"
#include "Time.h"
#include "lib/Assert.h"
#include "lib/FileDescriptor.h"

#include <cstdint>
Expand Down Expand Up @@ -229,13 +230,19 @@ void ExternalDriver::start()

buf[0] = HEADER_START;
pos = HEADER_SIZE;

// ns/sec / samples/sec = ns/sample
// For sample rate of none, sample every 100ms
static constexpr std::uint64_t min_rate = 10UL;

runtime_assert(gSessionData.mSampleRate != invalid, "Invalid value");

buffer_utils::packInt(
buf,
pos,
static_cast<int32_t>(NS_PER_S / (gSessionData.mSampleRate == 0 ? min_rate : gSessionData.mSampleRate)));
static_cast<int32_t>(
NS_PER_S
/ (gSessionData.mSampleRate == none ? min_rate : static_cast<std::uint64_t>(gSessionData.mSampleRate))));
buffer_utils::packInt(buf, pos, static_cast<int32_t>(gSessionData.mLiveRate));
buffer_utils::writeLEInt(buf + 1, pos);
if (!lib::writeAll(mUds, buf, pos)) {
Expand Down
9 changes: 5 additions & 4 deletions daemon/ExternalSource.cpp
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. */

// Define to adjust Buffer.h interface,
#define BUFFER_USE_SESSION_DATA
Expand All @@ -24,6 +24,7 @@
#include "lib/AutoClosingFd.h"
#include "lib/FileDescriptor.h"
#include "lib/Syscall.h"
#include "monotonic_pair.h"

#include <array>
#include <atomic>
Expand Down Expand Up @@ -170,7 +171,7 @@ class ExternalSourceImpl : public ExternalSource {
return true;
}

void run(std::uint64_t monotonicStart, std::function<void()> endSession) override
void run(monotonic_pair_t monotonicStart, std::function<void()> endSession) override
{
prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(&"gatord-external"), 0, 0, 0);

Expand Down Expand Up @@ -292,7 +293,7 @@ class ExternalSourceImpl : public ExternalSource {
* starve out the gator data.
*/
while (mSessionIsActive) {
if (!transfer(monotonicStart, fd, endSession)) {
if (!transfer(monotonicStart.monotonic_raw, fd, endSession)) {
break;
}
}
Expand All @@ -308,7 +309,7 @@ class ExternalSourceImpl : public ExternalSource {
LOG_WARNING("Failed to change ftrace pipe to blocking reads. Ftrace data may be truncated");
}

while (transfer(monotonicStart, fd, endSession)) {
while (transfer(monotonicStart.monotonic_raw, fd, endSession)) {
}

close(fd);
Expand Down
22 changes: 12 additions & 10 deletions daemon/GatorCLIParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,22 @@ namespace {

using ExecutionMode = ParserResult::ExecutionMode;

SampleRate getSampleRate(const std::string & value)
std::pair<SampleRate, SampleRate> getSampleRate(const std::string & value)
{
if (value == "high") {
return high;
return {high, high};
}
if (value == "normal") {
return normal;
return {normal, normal_x2};
}
if (value == "low") {
return low;
return {low, low};
}
if (value == "none") {

return none;
return {none, none};
}
return invalid;
return {invalid, invalid};
}

void GatorCLIParser::addCounter(int startpos, int pos, std::string & counters)
Expand Down Expand Up @@ -374,7 +374,7 @@ void GatorCLIParser::parseCLIArguments(int argc,
int c;
while ((c = getopt_long(argc, argv, OPTSTRING_SHORT.data(), OPTSTRING_LONG, nullptr)) != -1) {
const int optionInt = optarg == nullptr ? -1 : parseBoolean(optarg);
SampleRate sampleRate;
std::pair<SampleRate, SampleRate> sampleRate;
std::string value;
result.addArgValuePair({std::string(1, char(c)), //
optarg != nullptr ? std::optional<std::string>(optarg) //
Expand Down Expand Up @@ -456,8 +456,9 @@ void GatorCLIParser::parseCLIArguments(int argc,
result.parameterSetFlag = result.parameterSetFlag | USE_CMDLINE_ARG_SAMPLE_RATE;
value = std::string(optarg);
sampleRate = getSampleRate(value);
if (sampleRate != invalid) {
result.mSampleRate = sampleRate;
if (sampleRate.first != invalid) {
result.mSampleRate = sampleRate.first;
result.mSampleRateGpu = sampleRate.second;
}
else {
LOG_ERROR("Invalid sample rate (%s).", optarg);
Expand Down Expand Up @@ -627,7 +628,8 @@ void GatorCLIParser::parseCLIArguments(int argc,
" -r|--sample-rate (none|low|normal|high)\n"
" Specify sample rate for capture. The\n"
" frequencies for each sample rate are: \n"
" high=10kHz, normal=1kHz, low=100Hz.\n"
" high=10kHz, normal=1kHz (2kHz in GPU), \n"
" low=100Hz.\n"
" Setting the sample rate to none will\n"
" sample at the lowest possible rate.\n"
" (defaults to 'normal')\n"
Expand Down
2 changes: 2 additions & 0 deletions daemon/GatorMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ void setDefaults()
gSessionData.mBacktraceDepth = 128;
//sample rate is normal
gSessionData.mSampleRate = normal;
gSessionData.mSampleRateGpu = normal_x2;
//duration default to 0
gSessionData.mDuration = 0;
//use_efficient_ftrace default is yes
Expand Down Expand Up @@ -528,6 +529,7 @@ void updateSessionData(const ParserResult & result)
//and hence cannot be modified during parse session
if ((result.parameterSetFlag & USE_CMDLINE_ARG_SAMPLE_RATE) != 0) {
gSessionData.mSampleRate = result.mSampleRate;
gSessionData.mSampleRateGpu = result.mSampleRateGpu;
}
if ((result.parameterSetFlag & USE_CMDLINE_ARG_CALL_STACK_UNWINDING) != 0) {
gSessionData.mBacktraceDepth = result.mBacktraceDepth;
Expand Down
28 changes: 0 additions & 28 deletions daemon/ISummaryConsumer.h

This file was deleted.

3 changes: 2 additions & 1 deletion daemon/ParserResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class ParserResult {
gator::smmuv3::default_identifiers_t smmu_identifiers;

int mBacktraceDepth {0};
int mSampleRate {0};
SampleRate mSampleRate {none};
SampleRate mSampleRateGpu {none};
int mDuration {0};
int mPerfMmapSizeInPages {-1};
int mSpeSampleRate {-1};
Expand Down
4 changes: 2 additions & 2 deletions daemon/ProtocolVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

/* Define the product release version / protocol version */

// Protocol version Streamline v9.0
#define PROTOCOL_VERSION 900
// Protocol version Streamline v9.1
#define PROTOCOL_VERSION 910
// Differentiates development versions from release code
#define PROTOCOL_VERSION_DEV_MULTIPLIER 100000

20 changes: 14 additions & 6 deletions daemon/SessionData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void SessionData::initialize()
mAPCDir = nullptr;
mCaptureWorkingDir = nullptr;
mCaptureUser = nullptr;
mSampleRate = 0;
mSampleRate = none;
mSampleRateGpu = none;
mLiveRate = 0;
mDuration = 0;
mBacktraceDepth = 0;
Expand All @@ -60,24 +61,31 @@ void SessionData::parseSessionXML(char * xmlString)
// Set session data values - use prime numbers just below the desired value to reduce the chance of events firing at the same time
if ((gSessionData.parameterSetFlag & USE_CMDLINE_ARG_SAMPLE_RATE) == 0) {
if (strcmp(session.parameters.sample_rate, "high") == 0) {
mSampleRate = 10007; // 10000
mSampleRate = high;
mSampleRateGpu = mSampleRate;
}
else if (strcmp(session.parameters.sample_rate, "normal") == 0) {
mSampleRate = 1009; // 1000
mSampleRate = normal;

// sample rate will be doubled in normal mode for gpuid >= Valhall
mSampleRateGpu = normal_x2;
}
else if (strcmp(session.parameters.sample_rate, "low") == 0) {
mSampleRate = 101; // 100
mSampleRate = low;
mSampleRateGpu = mSampleRate;
}
else if (strcmp(session.parameters.sample_rate, "none") == 0) {
mSampleRate = 0;
mSampleRate = none;
mSampleRateGpu = mSampleRate;
}
else {

LOG_ERROR("Invalid sample rate (%s) in session xml.", session.parameters.sample_rate);
handleException();
}
}

if ((gSessionData.parameterSetFlag & USE_CMDLINE_ARG_CALL_STACK_UNWINDING) == 0) {
// NOLINTNEXTLINE(readability-magic-numbers)
mBacktraceDepth = session.parameters.call_stack_unwinding ? 128 : 0;
}

Expand Down
4 changes: 3 additions & 1 deletion daemon/SessionData.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class SessionData {
int mBacktraceDepth {0};
// number of MB to use for the entire collection buffer
int mTotalBufferSize {0};
int mSampleRate {0};
SampleRate mSampleRate {none};
// sampling rate overriden for some GPUs (see mali_userspace::maliGpuSampleRateIsUpgradeable function)
SampleRate mSampleRateGpu {none};
int mDuration {0};
int mPageSize {0};
int mAnnotateStart {0};
Expand Down
8 changes: 4 additions & 4 deletions daemon/Source.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/* Copyright (C) 2010-2021 by Arm Limited. All rights reserved. */
/* Copyright (C) 2010-2024 by Arm Limited. All rights reserved. */

#pragma once

#include <cstdint>
#include <functional>
#include <optional>

class ISender;
struct monotonic_pair_t;

class Source {
public:
virtual ~Source() = default;

virtual void run(std::uint64_t monotonicStart, std::function<void()> endSession) = 0;
virtual void run(monotonic_pair_t monotonicStart, std::function<void()> endSession) = 0;
virtual void interrupt() = 0;

/**
Expand All @@ -28,5 +28,5 @@ class PrimarySource : public Source {
*
* @return monotonic start or empty on failure
*/
virtual std::optional<std::uint64_t> sendSummary() = 0;
virtual std::optional<monotonic_pair_t> sendSummary() = 0;
};
Loading

0 comments on commit b458f5d

Please sign in to comment.