Skip to content

Commit

Permalink
7.5.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
bengaineyarm committed Feb 3, 2021
1 parent bbc8e31 commit 6088d35
Show file tree
Hide file tree
Showing 114 changed files with 2,706 additions and 1,261 deletions.
29 changes: 19 additions & 10 deletions daemon/BlockCounterFrameBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

BlockCounterFrameBuilder::~BlockCounterFrameBuilder()
{
if (isFrameStarted) {
rawBuilder.endFrame();
}
endFrame();
}

bool BlockCounterFrameBuilder::eventHeader(uint64_t time)
Expand Down Expand Up @@ -83,17 +81,18 @@ bool BlockCounterFrameBuilder::event64(int key, int64_t value)
bool BlockCounterFrameBuilder::check(const uint64_t time)
{
if ((*flushIsNeeded)(time, rawBuilder.needsFlush())) {
bool shouldEndFrame = isFrameStarted;
if (shouldEndFrame) {
rawBuilder.endFrame();
isFrameStarted = false;
}
rawBuilder.flush();
return shouldEndFrame;
return flush();
}
return false;
}

bool BlockCounterFrameBuilder::flush()
{
const bool shouldEndFrame = endFrame();
rawBuilder.flush();
return shouldEndFrame;
}

bool BlockCounterFrameBuilder::checkSpace(const int bytes)
{
return rawBuilder.bytesAvailable() >= bytes;
Expand All @@ -114,3 +113,13 @@ bool BlockCounterFrameBuilder::ensureFrameStarted()
isFrameStarted = true;
return true;
}

bool BlockCounterFrameBuilder::endFrame()
{
const bool shouldEndFrame = isFrameStarted;
if (shouldEndFrame) {
rawBuilder.endFrame();
isFrameStarted = false;
}
return shouldEndFrame;
}
3 changes: 3 additions & 0 deletions daemon/BlockCounterFrameBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ class BlockCounterFrameBuilder : public IBlockCounterFrameBuilder {

virtual bool check(const uint64_t time) override;

virtual bool flush() override;

private:
IRawFrameBuilder & rawBuilder;
std::shared_ptr<CommitTimeChecker> flushIsNeeded;
bool isFrameStarted = false;

bool ensureFrameStarted();
bool endFrame();
bool checkSpace(const int bytes);
};
19 changes: 18 additions & 1 deletion daemon/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int Buffer::bytesAvailable() const
// this is full.
remaining -= 200;

return remaining;
return std::max(remaining, 0);
}

void Buffer::waitForSpace(int bytes)
Expand Down Expand Up @@ -226,3 +226,20 @@ void Buffer::setDone()
// as sender waits for new data *and* EOF
sem_post(&mReaderSem);
}

int Buffer::getWriteIndex() const
{
return mWritePos;
}

void Buffer::advanceWrite(int bytes)
{
mWritePos = (mWritePos + bytes) & /*mask*/ (mSize - 1);
}

void Buffer::writeDirect(int index, const void * data, std::size_t count)
{
for (std::size_t i = 0; i < count; ++i) {
mBuf[(index + i) & mask] = static_cast<const char *>(data)[i];
}
}
7 changes: 5 additions & 2 deletions daemon/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <cstdint>
#include <semaphore.h>

class Buffer : public IBufferControl, public IRawFrameBuilder {
class Buffer : public IBufferControl, public IRawFrameBuilderWithDirectAccess {
public:
Buffer(int size, sem_t & readerSem, bool includeResponseType);
#ifdef BUFFER_USE_SESSION_DATA
Expand All @@ -32,7 +32,10 @@ class Buffer : public IBufferControl, public IRawFrameBuilder {

// Prefer a new member to using these functions if possible
char * getWritePos() { return mBuf + mWritePos; }
void advanceWrite(int bytes) { mWritePos = (mWritePos + bytes) & /*mask*/ (mSize - 1); }

int getWriteIndex() const override;
void advanceWrite(int bytes) override;
void writeDirect(int index, const void * data, std::size_t count) override;

int packInt(int32_t x) override;
int packInt64(int64_t x) override;
Expand Down
7 changes: 5 additions & 2 deletions daemon/CCNDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,11 @@ std::string CCNDriver::validateCounters()
continue;
}

if (strncmp(counter.getType(), ARM_CCN_5XX_CNT, sizeof(ARM_CCN_5XX_CNT) - 1) == 0) {
const int node = counter.getEvent() & mask;
const auto isCnnCounter = (strncmp(counter.getType(), ARM_CCN_5XX_CNT, sizeof(ARM_CCN_5XX_CNT) - 1) == 0);
const auto & eventCode = counter.getEventCode();

if (isCnnCounter && eventCode.isValid()) {
const int node = eventCode.asI32() & mask;

for (auto & count : counts) {
if (count[0] == 0) {
Expand Down
35 changes: 33 additions & 2 deletions daemon/CapturedXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "CapturedXML.h"

#include "CapturedSpe.h"
#include "Constant.h"
#include "ICpuInfo.h"
#include "Logging.h"
#include "OlyUtility.h"
Expand Down Expand Up @@ -68,6 +69,19 @@ static const char * detectOs()
}
#endif

static std::string modeAsString(const ConstantMode mode)
{
switch (mode) {
case ConstantMode::SystemWide:
return "system-wide";
case ConstantMode::PerCore:
return "per-core";
default:
logg.logError("Unexpected ConstantMode %d", static_cast<int>(mode));
handleException();
}
}

/** Generate the xml tree for capture.xml */
static mxml_node_t * getTree(bool includeTime,
lib::Span<const CapturedSpe> spes,
Expand Down Expand Up @@ -152,8 +166,8 @@ static mxml_node_t * getTree(bool includeTime,
mxml_node_t * const node = mxmlNewElement(counters, "counter");
mxmlElementSetAttrf(node, "key", "0x%x", counter.getKey());
mxmlElementSetAttr(node, "type", counter.getType());
if (counter.getEvent() != -1) {
mxmlElementSetAttrf(node, "event", "0x%x", counter.getEvent());
if (counter.getEventCode().isValid()) {
mxmlElementSetAttrf(node, "event", "0x%" PRIxEventCode, counter.getEventCode().asU64());
}
if (counter.getCount() > 0) {
mxmlElementSetAttrf(node, "count", "%d", counter.getCount());
Expand All @@ -164,6 +178,23 @@ static mxml_node_t * getTree(bool includeTime,
}
}

for (const auto & constant : gSessionData.mConstants) {

const std::string mode = modeAsString(constant.getMode());

if (counters == nullptr) {
counters = mxmlNewElement(captured, "counters");
}
mxml_node_t * const node = mxmlNewElement(counters, "counter");

mxmlElementSetAttrf(node, "key", "0x%x", constant.getKey());
mxmlElementSetAttr(node, "counter", constant.getCounterString().c_str());
mxmlElementSetAttr(node, "title", constant.getTitle().c_str());
mxmlElementSetAttr(node, "name", constant.getName().c_str());
mxmlElementSetAttr(node, "class", "constant");
mxmlElementSetAttr(node, "mode", mode.c_str());
}

for (const auto & spe : spes) {
if (counters == nullptr) {
counters = mxmlNewElement(captured, "counters");
Expand Down
30 changes: 18 additions & 12 deletions daemon/Child.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "CounterXML.h"
#include "Driver.h"
#include "Drivers.h"
#include "ExitStatus.h"
#include "ExternalSource.h"
#include "ICpuInfo.h"
#include "LocalCapture.h"
Expand Down Expand Up @@ -43,13 +44,6 @@ std::atomic<Child *> Child::gSingleton = ATOMIC_VAR_INIT(nullptr);

extern void cleanUp();

constexpr int exceptionExitCode = 1;
constexpr int secondExceptionExitCode = 2;
// constexpr int secondSignalExitCode = 3; no longer used
// constexpr int alarmExitCode = 4; no longer used
constexpr int noSingletonExitCode = 5;
constexpr int signalFailedExitCode = 6;

void handleException()
{
Child * const singleton = Child::getSingleton();
Expand All @@ -69,7 +63,7 @@ void handleException()

// don't call exit handlers / global destructors
// because other threads may be still running
_exit(exceptionExitCode);
_exit(EXCEPTION_EXIT_CODE);
}

std::unique_ptr<Child> Child::createLocal(Drivers & drivers, const Child::Config & config)
Expand All @@ -93,7 +87,7 @@ void Child::signalHandler(int signum)
if (singleton == nullptr) {
// this should not be possible because we set the singleton before
// installing the handlers
exit(noSingletonExitCode);
exit(NO_SINGLETON_EXIT_CODE);
}

singleton->endSession(signum);
Expand Down Expand Up @@ -188,9 +182,11 @@ void Child::run()

checkError(configuration_xml::setCounters(counterConfigs, !countersAreDefaults, drivers));

// Initialize all drivers
// Initialize all drivers and register their constants with the global constant list
for (Driver * driver : drivers.getAll()) {
driver->resetCounters();

driver->insertConstants(gSessionData.mConstants);
}

// Set up counters using the associated driver's setup function
Expand Down Expand Up @@ -435,7 +431,7 @@ void Child::endSession(int signum)
if (signum != 0) {
// we're in a signal handler so it's not safe to log
// and if this has failed something has gone really wrong
_exit(signalFailedExitCode);
_exit(SIGNAL_FAILED_EXIT_CODE);
}
logg.logError("write failed (%d) %s", errno, strerror(errno));
handleException();
Expand Down Expand Up @@ -465,7 +461,7 @@ void Child::cleanupException()
logg.logMessage("Received multiple exceptions, terminating the child");

// Something is really wrong, exit immediately
_exit(secondExceptionExitCode);
_exit(SECOND_EXCEPTION_EXIT_CODE);
}

if (command) {
Expand Down Expand Up @@ -544,6 +540,16 @@ namespace {
sender.writeData(nullptr, 0, ResponseType::ACK);
return State::PROCESS_COMMANDS;
}
State handleExit() override
{
logg.logMessage("INVESTIGATE: Received unknown command type COMMAND_EXIT");
return State::EXIT_OK;
}
State handleRequestCurrentConfig() override
{
logg.logMessage("INVESTIGATE: Received unknown command type COMMAND_REQUEST_CURRENT_CONFIG");
return State::PROCESS_COMMANDS;
}

private:
Sender & sender;
Expand Down
8 changes: 4 additions & 4 deletions daemon/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

#define MAX_PERFORMANCE_COUNTERS 100

// If debugfs is not mounted at /sys/kernel/debug, update TRACING_PATH
#define TRACING_PATH "/sys/kernel/debug/tracing"
#define EVENTS_PATH TRACING_PATH "/events"

// feature control options
#ifndef CONFIG_PREFER_SYSTEM_WIDE_MODE
#define CONFIG_PREFER_SYSTEM_WIDE_MODE 1
Expand All @@ -31,6 +27,10 @@
#define GATORD_BUILD_ID "oss"
#endif

#ifndef GATOR_SELF_PROFILE
#define GATOR_SELF_PROFILE 0
#endif

// assume /proc/sys/kernel/perf_event_paranoid == 2 if it cannot be read
#ifndef CONFIG_ASSUME_PERF_HIGH_PARANOIA
#define CONFIG_ASSUME_PERF_HIGH_PARANOIA 1
Expand Down
4 changes: 3 additions & 1 deletion daemon/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_

#include "EventCode.h"

#include <set>
#include <string>
#include <vector>
Expand Down Expand Up @@ -46,7 +48,7 @@ namespace std {

struct CounterConfiguration {
std::string counterName {};
int event = -1;
EventCode event {};
int count = 0;
int cores = 0;
};
Expand Down
Loading

0 comments on commit 6088d35

Please sign in to comment.