Skip to content

Commit

Permalink
use block_bio_queue/complete instead of rq_insert/rq_complete
Browse files Browse the repository at this point in the history
The latter isn't available on ancient Linuxes (*cough* HPC *cough*)
  • Loading branch information
cvonelm committed Jan 13, 2022
1 parent a271d55 commit 06e97df
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
19 changes: 14 additions & 5 deletions include/lo2s/perf/bio/event_cacher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extern "C" namespace lo2s
class EventCacher : public Reader<EventCacher>
{
public:
struct __attribute((__packed__)) RecordBlock
struct __attribute((__packed__)) RecordBlockCommon
{
uint16_t common_type; // 2
uint8_t common_flag; // 3
Expand All @@ -57,11 +57,19 @@ extern "C" namespace lo2s
uint64_t sector; // 24

uint32_t nr_sector; // 28
int32_t error_or_bytes;
};
struct __attribute((__packed__)) RecordBlockInsert
{
struct RecordBlockCommon common;
char rwbs[8]; // 40
char comm[16]; // 56
};

char rwbs[8]; // 40
char comm[16]; // 56
char __data_loc[4]; // 56
struct __attribute((__packed__)) RecordBlockComplete
{
struct RecordBlockCommon common;
int error;
char rwbs[8];
};

EventCacher(Cpu cpu, std::unique_ptr<Writer>& writer, BioEventType type);
Expand All @@ -81,6 +89,7 @@ extern "C" namespace lo2s
}

private:
bool insert_event(RecordBlockCommon* common, uint64_t time, char* rwbs);
std::unique_ptr<Writer>& writer_;
std::vector<BioEvent> events_;
};
Expand Down
4 changes: 2 additions & 2 deletions include/lo2s/perf/bio/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class Reader : public EventReader<T>
attr.type = PERF_TYPE_TRACEPOINT;
if (type == BioEventType::INSERT)
{
attr.config = tracepoint::EventFormat("block:block_rq_insert").id();
attr.config = tracepoint::EventFormat("block:block_bio_queue").id();
}
else
{
attr.config = tracepoint::EventFormat("block:block_rq_complete").id();
attr.config = tracepoint::EventFormat("block:block_bio_complete").id();
}
attr.sample_period = 1;
attr.sample_type = PERF_SAMPLE_RAW | PERF_SAMPLE_TIME;
Expand Down
29 changes: 22 additions & 7 deletions src/perf/bio/event_cacher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,31 @@ EventCacher::EventCacher(Cpu cpu, std::unique_ptr<Writer>& writer, BioEventType

bool EventCacher::handle(const Reader::RecordSampleType* sample)
{
struct RecordBlock* record = (struct RecordBlock*)&sample->tp_data;
if (type_ == BioEventType::INSERT)
{
struct RecordBlockInsert* record = (struct RecordBlockInsert*)&sample->tp_data;
return insert_event(&(record->common), sample->time, record->rwbs);
}
else
{
struct RecordBlockComplete* record = (struct RecordBlockComplete*)&sample->tp_data;
return insert_event(&(record->common), sample->time, record->rwbs);
}
return false;
}

bool EventCacher::insert_event(RecordBlockCommon* common, uint64_t time, char* rwbs)
{
Log::error() << rwbs;
otf2::common::io_operation_mode_type mode = otf2::common::io_operation_mode_type::flush;
// TODO: Handle the few io operations that arent either reads or write
if (record->rwbs[0] == 'R')
// Linux reports the size of I/O operations in number of sectors, which are always 512 byte
// lare, regardless of what the real sector size of the block device is
if (rwbs[0] == 'R')
{
mode = otf2::common::io_operation_mode_type::read;
}
else if (record->rwbs[0] == 'W')
else if (rwbs[0] == 'W')
{
mode = otf2::common::io_operation_mode_type::write;
}
Expand All @@ -44,10 +61,8 @@ bool EventCacher::handle(const Reader::RecordSampleType* sample)
return false;
}

// Linux reports the size of I/O operations in number of sectors, which are always 512 byte
// lare, regardless of what the real sector size of the block device is
events_.push_back(BioEvent(makedev(record->dev >> 20, record->dev & ((1U << 20) - 1)),
record->sector, sample->time, type_, mode, record->nr_sector * 512));
events_.push_back(BioEvent(makedev(common->dev >> 20, common->dev & ((1U << 20) - 1)),
common->sector, time, type_, mode, common->nr_sector * 512));

if (events_.size() == config().block_io_cache_size)
{
Expand Down

0 comments on commit 06e97df

Please sign in to comment.