Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various remaining issues with EventDescription Rework, streamline interfaces, move configuration of Events in own EventConfig class. #358

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ set(SOURCE_FILES
src/monitor/tracepoint_monitor.cpp
src/process_controller.cpp

src/perf/event_provider.cpp
src/perf/event.cpp
src/perf/event_resolver.cpp
src/perf/event_attr.cpp

src/perf/bio/block_device.cpp
src/perf/counter/counter_provider.cpp
src/perf/event_composer.cpp
src/perf/counter/group/reader.cpp
src/perf/counter/userspace/reader.cpp

Expand All @@ -194,7 +194,7 @@ set(SOURCE_FILES
src/perf/sample/writer.cpp
src/perf/time/converter.cpp src/perf/time/reader.cpp
src/perf/tracepoint/writer.cpp
src/perf/tracepoint/event.cpp
src/perf/tracepoint/event_attr.cpp
src/perf/syscall/writer.cpp

src/time/time.cpp
Expand Down
2 changes: 1 addition & 1 deletion include/lo2s/build_config.hpp.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Predefined events which are only present in more modern kernels src/perf/event_provider.cpp
// Predefined events which are only present in more modern kernels src/perf/event_resolver.cpp

#cmakedefine HAVE_PERF_EVENT_STALLED_CYCLES_FRONTEND

Expand Down
37 changes: 20 additions & 17 deletions include/lo2s/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#pragma once

#include <chrono>
#include <optional>
#include <string>
#include <vector>

Expand Down Expand Up @@ -51,55 +52,57 @@ struct Config
Process process;
std::vector<std::string> command;
std::string command_line;
bool quiet;
bool drop_root;
bool quiet = false;
bool drop_root = false;
std::string user = "";
// Optional features
std::vector<std::string> tracepoint_events;
#ifdef HAVE_X86_ADAPT
std::vector<std::string> x86_adapt_knobs;
#endif
bool use_sensors;
bool use_sensors = false;
int cgroup_fd = -1;
// OTF2
std::string trace_path;
// perf
std::size_t mmap_pages;
bool exclude_kernel;
bool exclude_kernel = false;
// Instruction sampling
bool sampling;
bool sampling = false;
std::uint64_t sampling_period;
std::string sampling_event;
bool enable_cct;
bool suppress_ip;
bool disassemble;
bool enable_cct = false;
bool suppress_ip = false;
bool disassemble = false;
// Interval monitors
std::chrono::nanoseconds read_interval;
std::chrono::nanoseconds userspace_read_interval;
std::chrono::nanoseconds perf_read_interval = std::chrono::nanoseconds(0);
// Metrics
bool metric_use_frequency;
bool metric_use_frequency = true;

std::uint64_t metric_count;
std::uint64_t metric_frequency;

// time synchronization
bool use_clockid;
bool use_pebs;
clockid_t clockid;
std::string metric_leader;
std::vector<std::string> group_counters;
std::vector<std::string> userspace_counters;
// time synchronizatio
std::optional<clockid_t> clockid;
bool use_pebs = false;
// x86_energy
bool use_x86_energy;
bool use_x86_energy = false;
// block I/O
bool use_block_io;
bool use_block_io = false;
// syscalls
bool use_syscalls = false;
std::vector<int64_t> syscall_filter;
// NEC SX-Aurora Tsubasa
bool use_nec;
bool use_nec = false;
std::chrono::microseconds nec_read_interval;
std::chrono::milliseconds nec_check_interval;
// Nvidia CUPTI
bool use_nvidia;
bool use_nvidia = false;
cvonelm marked this conversation as resolved.
Show resolved Hide resolved
std::string cuda_injectionlib_path;
uint64_t nvidia_ringbuf_size;
};
Expand Down
15 changes: 8 additions & 7 deletions include/lo2s/perf/bio/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#pragma once

#include <lo2s/perf/event_composer.hpp>
#include <lo2s/perf/io_reader.hpp>
#include <lo2s/perf/time/converter.hpp>
#include <lo2s/perf/tracepoint/format.hpp>
Expand Down Expand Up @@ -155,14 +156,14 @@ class Writer
}
}

std::vector<perf::tracepoint::TracepointEvent> get_tracepoints()
std::vector<perf::tracepoint::TracepointEventAttr> get_tracepoints()
{
bio_queue_ =
perf::EventProvider::instance().create_tracepoint_event("block:block_bio_queue");
perf::EventComposer::instance().create_tracepoint_event("block:block_bio_queue");
bio_issue_ =
perf::EventProvider::instance().create_tracepoint_event("block:block_rq_issue");
perf::EventComposer::instance().create_tracepoint_event("block:block_rq_issue");
bio_complete_ =
perf::EventProvider::instance().create_tracepoint_event("block:block_rq_complete");
perf::EventComposer::instance().create_tracepoint_event("block:block_rq_complete");

return { bio_queue_.value(), bio_issue_.value(), bio_complete_.value() };
}
Expand All @@ -185,9 +186,9 @@ class Writer
time::Converter& time_converter_;

// Unavailable until get_tracepoints() is called
std::optional<perf::tracepoint::TracepointEvent> bio_queue_;
std::optional<perf::tracepoint::TracepointEvent> bio_issue_;
std::optional<perf::tracepoint::TracepointEvent> bio_complete_;
std::optional<perf::tracepoint::TracepointEventAttr> bio_queue_;
std::optional<perf::tracepoint::TracepointEventAttr> bio_issue_;
std::optional<perf::tracepoint::TracepointEventAttr> bio_complete_;

// The unit "sector" is always 512 bit large, regardless of the actual sector size of the device
static constexpr int SECTOR_SIZE = 512;
Expand Down
23 changes: 11 additions & 12 deletions include/lo2s/perf/counter/counter_collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#pragma once

#include <lo2s/perf/event.hpp>
#include <lo2s/perf/event_attr.hpp>

#include <optional>
#include <vector>
Expand All @@ -34,29 +34,28 @@ namespace counter
{
struct CounterCollection
{
std::optional<Event> leader_;
std::vector<Event> counters;
CounterCollection() : leader(std::nullopt)
{
}

std::optional<EventAttr> leader = std::nullopt;
std::vector<EventAttr> counters;

double get_scale(int index) const
{
if (index == 0)
{
return leader_.value().scale();
return leader.value().scale();
}
else
{
return counters[index - 1].scale();
}
}

Event& leader() const
{
return const_cast<Event&>(leader_.value());
}

friend bool operator==(const CounterCollection& lhs, const CounterCollection& rhs)
{
if (lhs.leader_.value() == rhs.leader_.value())
if (lhs.leader.value() == rhs.leader.value())
{
return lhs.counters == rhs.counters;
}
Expand All @@ -65,11 +64,11 @@ struct CounterCollection

friend bool operator<(const CounterCollection& lhs, const CounterCollection& rhs)
{
if (lhs.leader_.value() == rhs.leader_.value())
if (lhs.leader.value() == rhs.leader.value())
{
return lhs.counters < rhs.counters;
}
return lhs.leader_.value() < rhs.leader_.value();
return lhs.leader.value() < rhs.leader.value();
}
};

Expand Down
69 changes: 0 additions & 69 deletions include/lo2s/perf/counter/counter_provider.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion include/lo2s/perf/counter/group/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <lo2s/perf/counter/counter_collection.hpp>
#include <lo2s/perf/counter/group/group_counter_buffer.hpp>
#include <lo2s/perf/event.hpp>
#include <lo2s/perf/event_attr.hpp>
#include <lo2s/perf/event_reader.hpp>

#include <optional>
Expand Down
2 changes: 1 addition & 1 deletion include/lo2s/perf/counter/userspace/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <lo2s/execution_scope.hpp>
#include <lo2s/perf/counter/counter_collection.hpp>
#include <lo2s/perf/counter/userspace/userspace_counter_buffer.hpp>
#include <lo2s/perf/event_provider.hpp>
#include <lo2s/perf/event_resolver.hpp>
#include <lo2s/trace/trace.hpp>

#include <cstdint>
Expand Down
Loading