Skip to content

Commit

Permalink
Revert "implement suggested changes in PerfEvent"
Browse files Browse the repository at this point in the history
This reverts commit fc32170.
  • Loading branch information
cvonelm authored Dec 8, 2024
1 parent 9878889 commit 32cb5cc
Show file tree
Hide file tree
Showing 33 changed files with 533 additions and 522 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ set(SOURCE_FILES
src/process_controller.cpp

src/perf/event_provider.cpp
src/perf/event.cpp
src/perf/reader.cpp

src/perf/bio/block_device.cpp
src/perf/counter/counter_provider.cpp
Expand All @@ -197,8 +197,8 @@ set(SOURCE_FILES

src/perf/sample/writer.cpp
src/perf/time/converter.cpp src/perf/time/reader.cpp
src/perf/tracepoint/format.cpp
src/perf/tracepoint/writer.cpp
src/perf/tracepoint/event.cpp
src/perf/syscall/writer.cpp

src/time/time.cpp
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 @@ -155,11 +155,12 @@ class Writer
}
}

std::vector<perf::tracepoint::TracepointEvent> get_tracepoints()
std::vector<tracepoint::EventFormat> get_tracepoints()
{
bio_queue_ = perf::tracepoint::TracepointEvent("block:block_bio_queue");
bio_issue_ = perf::tracepoint::TracepointEvent("block:block_rq_issue");
bio_complete_ = perf::tracepoint::TracepointEvent("block:block_rq_complete");

bio_queue_ = tracepoint::EventFormat("block:block_bio_queue");
bio_issue_ = tracepoint::EventFormat("block:block_rq_issue");
bio_complete_ = tracepoint::EventFormat("block:block_rq_complete");

return { bio_queue_, bio_issue_, bio_complete_ };
}
Expand All @@ -181,9 +182,9 @@ class Writer
trace::Trace& trace_;
time::Converter& time_converter_;

perf::tracepoint::TracepointEvent bio_queue_;
perf::tracepoint::TracepointEvent bio_issue_;
perf::tracepoint::TracepointEvent bio_complete_;
tracepoint::EventFormat bio_queue_;
tracepoint::EventFormat bio_issue_;
tracepoint::EventFormat 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
6 changes: 3 additions & 3 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/reader.hpp>

#include <vector>

Expand All @@ -33,8 +33,8 @@ namespace counter
{
struct CounterCollection
{
PerfEvent leader;
std::vector<PerfEvent> counters;
SysfsEvent leader;
std::vector<SysfsEvent> counters;

double get_scale(int index) const
{
Expand Down
9 changes: 4 additions & 5 deletions include/lo2s/perf/counter/counter_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <lo2s/measurement_scope.hpp>
#include <lo2s/perf/counter/counter_collection.hpp>
#include <lo2s/perf/event.hpp>
#include <lo2s/perf/reader.hpp>

#include <vector>

Expand Down Expand Up @@ -54,12 +54,11 @@ class CounterProvider
bool has_userspace_counters(ExecutionScope scope);

CounterCollection collection_for(MeasurementScope scope);
std::vector<std::string> get_tracepoint_event_names();

private:
PerfEvent group_leader_;
std::vector<PerfEvent> group_events_;
std::vector<PerfEvent> userspace_events_;
SysfsEvent group_leader_;
std::vector<SysfsEvent> group_events_;
std::vector<SysfsEvent> userspace_events_;
};
} // namespace counter
} // namespace perf
Expand Down
6 changes: 3 additions & 3 deletions include/lo2s/perf/counter/group/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

#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_reader.hpp>
#include <lo2s/perf/reader.hpp>

#include <vector>

Expand Down Expand Up @@ -60,8 +60,8 @@ class Reader : public EventReader<T>
};

protected:
PerfEventGuard counter_leader_;
std::vector<PerfEventGuard> counters_;
PerfEventInstance counter_leader_;
std::vector<PerfEventInstance> counters_;
CounterCollection counter_collection_;
GroupCounterBuffer counter_buffer_;
};
Expand Down
4 changes: 2 additions & 2 deletions 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.hpp>
#include <lo2s/perf/reader.hpp>
#include <lo2s/trace/trace.hpp>

#include <cstdint>
Expand Down Expand Up @@ -60,7 +60,7 @@ class Reader
UserspaceCounterBuffer counter_buffer_;
int timer_fd_;

std::vector<PerfEventGuard> counters_;
std::vector<PerfEventInstance> counters_;
std::vector<UserspaceReadFormat> data_;
};
} // namespace userspace
Expand Down
10 changes: 5 additions & 5 deletions include/lo2s/perf/event_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ class EventProvider
return instance_mutable();
}

static PerfEvent get_event_by_name(const std::string& name);
static SysfsEvent get_event_by_name(const std::string& name);

static bool has_event(const std::string& name);

static std::vector<PerfEvent> get_predefined_events();
static std::vector<SysfsEvent> get_predefined_events();
static std::vector<SysfsEvent> get_pmu_events();

static PerfEvent fallback_metric_leader_event();
static SysfsEvent fallback_metric_leader_event();

class InvalidEvent : public std::runtime_error
{
Expand All @@ -70,9 +70,9 @@ class EventProvider
return e;
}

PerfEvent cache_event(const std::string& name);
SysfsEvent cache_event(const std::string& name);

std::unordered_map<std::string, PerfEvent> event_map_;
std::unordered_map<std::string, SysfsEvent> event_map_;
};

} // namespace perf
Expand Down
24 changes: 13 additions & 11 deletions include/lo2s/perf/io_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <lo2s/measurement_scope.hpp>
#include <lo2s/perf/event_reader.hpp>
#include <lo2s/perf/tracepoint/event.hpp>
#include <lo2s/perf/reader.hpp>
#include <lo2s/perf/tracepoint/format.hpp>
#include <lo2s/perf/util.hpp>

Expand Down Expand Up @@ -60,11 +60,11 @@ struct __attribute((__packed__)) TracepointSampleType

struct IoReaderIdentity
{
IoReaderIdentity(std::string tracepoint, Cpu cpu) : tracepoint(tracepoint), cpu(cpu)
IoReaderIdentity(tracepoint::EventFormat tracepoint, Cpu cpu) : tracepoint(tracepoint), cpu(cpu)
{
}

tracepoint::TracepointEvent tracepoint;
tracepoint::EventFormat tracepoint;
Cpu cpu;

friend bool operator>(const IoReaderIdentity& lhs, const IoReaderIdentity& rhs)
Expand Down Expand Up @@ -93,9 +93,11 @@ class IoReader : public PullReader
public:
IoReader(IoReaderIdentity identity) : identity_(identity)
{
perf::TracepointEvent event(0, identity.tracepoint.id());

try
{
event_ = identity_.tracepoint.open(identity.cpu);
ev_instance_ = event.open(identity.cpu);
}
catch (const std::system_error& e)
{
Expand All @@ -107,10 +109,10 @@ class IoReader : public PullReader

try
{
init_mmap(event_.get_fd());
init_mmap(ev_instance_.get_fd());
Log::debug() << "perf_tracepoint_reader mmap initialized";

event_.enable();
ev_instance_.enable();
}
catch (...)
{
Expand All @@ -121,7 +123,7 @@ class IoReader : public PullReader

void stop()
{
event_.disable();
ev_instance_.disable();
}

TracepointSampleType* top()
Expand All @@ -131,7 +133,7 @@ class IoReader : public PullReader

int fd() const
{
return event_.get_fd();
return ev_instance_.get_fd();
}

IoReader& operator=(const IoReader&) = delete;
Expand All @@ -141,19 +143,19 @@ class IoReader : public PullReader
{
PullReader::operator=(std::move(other));
std::swap(identity_, other.identity_);
std::swap(event_, other.event_);
std::swap(ev_instance_, other.ev_instance_);

return *this;
}

IoReader(IoReader&& other) : PullReader(std::move(other)), identity_(other.identity_)
{
std::swap(event_, other.event_);
std::swap(ev_instance_, other.ev_instance_);
}

private:
IoReaderIdentity identity_;
PerfEventGuard event_;
perf::PerfEventInstance ev_instance_;
};
} // namespace perf
} // namespace lo2s
2 changes: 1 addition & 1 deletion include/lo2s/perf/multi_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MultiReader
{
for (auto tp : writer_.get_tracepoints())
{
IoReaderIdentity id(tp.name(), cpu);
IoReaderIdentity id(tp, cpu);
auto reader = readers_.emplace(std::piecewise_construct, std::forward_as_tuple(id),
std::forward_as_tuple(id));
fds_.emplace_back(reader.first->second.fd());
Expand Down
Loading

0 comments on commit 32cb5cc

Please sign in to comment.