-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(block I/O): Implement Block I/O tracing (#197)
* feat(block I/O): Implement Block I/O tracing - introduce --block-io and --block-cache-size options - write insert, issue, and complete as a non-blocking event - based on block:block_rq_insert block:block_rq_issue and block:block_rq_complete tracepoints Co-authored-by: Mario Bielert <[email protected]>
- Loading branch information
Showing
19 changed files
with
976 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* This file is part of the lo2s software. | ||
* Linux OTF2 sampling | ||
* | ||
* Copyright (c) 2017, | ||
* Technische Universitaet Dresden, Germany | ||
* | ||
* lo2s is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* lo2s is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with lo2s. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <lo2s/perf/bio/event_cacher.hpp> | ||
#include <lo2s/perf/bio/writer.hpp> | ||
|
||
#include <lo2s/monitor/poll_monitor.hpp> | ||
#include <lo2s/trace/trace.hpp> | ||
|
||
#include <map> | ||
#include <memory> | ||
|
||
namespace lo2s | ||
{ | ||
namespace monitor | ||
{ | ||
|
||
class BioMonitor : public PollMonitor | ||
{ | ||
public: | ||
BioMonitor(trace::Trace& trace, Cpu cpu, | ||
std::map<dev_t, std::unique_ptr<perf::bio::Writer>>& writers_); | ||
|
||
private: | ||
void monitor(int fd) override; | ||
void initialize_thread() override; | ||
void finalize_thread() override; | ||
|
||
std::string group() const override | ||
{ | ||
return "lo2s::BioMonitor"; | ||
} | ||
|
||
private: | ||
Cpu cpu_; | ||
perf::bio::EventCacher bio_insert_cacher_; | ||
perf::bio::EventCacher bio_issue_cacher_; | ||
perf::bio::EventCacher bio_complete_cacher_; | ||
}; | ||
} // namespace monitor | ||
} // namespace lo2s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* This file is part of the lo2s software. | ||
* Linux OTF2 sampling | ||
* | ||
* Copyright (c) 2022, | ||
* Technische Universitaet Dresden, Germany | ||
* | ||
* lo2s is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* lo2s is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with lo2s. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
extern "C" | ||
{ | ||
#include <sys/types.h> | ||
} | ||
|
||
namespace lo2s | ||
{ | ||
|
||
enum class BlockDeviceType | ||
{ | ||
PARTITION, | ||
DISK | ||
}; | ||
|
||
struct BlockDevice | ||
{ | ||
BlockDevice() : id(0), name(), type(BlockDeviceType::PARTITION), parent(0) | ||
{ | ||
} | ||
|
||
BlockDevice(dev_t id, const std::string& name, BlockDeviceType type, dev_t parent) | ||
: id(id), name(name), type(type), parent(parent) | ||
{ | ||
} | ||
|
||
static BlockDevice partition(dev_t id, const std::string& name, dev_t parent) | ||
{ | ||
return BlockDevice(id, name, BlockDeviceType::PARTITION, parent); | ||
} | ||
|
||
static BlockDevice disk(dev_t id, const std::string& name) | ||
{ | ||
return BlockDevice(id, name, BlockDeviceType::DISK, 0); | ||
} | ||
|
||
dev_t id; | ||
std::string name; | ||
BlockDeviceType type; | ||
dev_t parent; | ||
}; | ||
} // namespace lo2s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* This file is part of the lo2s software. | ||
* Linux OTF2 sampling | ||
* | ||
* Copyright (c) 2017, | ||
* Technische Universitaet Dresden, Germany | ||
* | ||
* lo2s is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* lo2s is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with lo2s. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <lo2s/perf/bio/reader.hpp> | ||
#include <lo2s/perf/bio/writer.hpp> | ||
#include <lo2s/perf/time/converter.hpp> | ||
|
||
#include <lo2s/trace/trace.hpp> | ||
|
||
#include <otf2xx/definition/metric_instance.hpp> | ||
#include <otf2xx/event/metric.hpp> | ||
#include <otf2xx/writer/local.hpp> | ||
|
||
#include <unordered_map> | ||
#include <vector> | ||
|
||
namespace lo2s | ||
{ | ||
namespace perf | ||
{ | ||
namespace bio | ||
{ | ||
// Note, this cannot be protected for CRTP reasons... | ||
|
||
class EventCacher : public Reader<EventCacher> | ||
{ | ||
public: | ||
struct __attribute((__packed__)) RecordBlock | ||
{ | ||
uint16_t common_type; // 2 | ||
uint8_t common_flag; // 3 | ||
uint8_t common_preempt_count; // 4 | ||
int32_t common_pid; // 8 | ||
|
||
uint32_t dev; // 12 | ||
char padding[4]; // 16 | ||
uint64_t sector; // 24 | ||
|
||
uint32_t nr_sector; // 28 | ||
int32_t error_or_bytes; // 32 | ||
|
||
char rwbs[8]; // 40 | ||
}; | ||
|
||
EventCacher(Cpu cpu, std::map<dev_t, std::unique_ptr<Writer>>& writers, BioEventType type); | ||
|
||
EventCacher(const EventCacher& other) = delete; | ||
|
||
EventCacher(EventCacher&& other) = default; | ||
|
||
public: | ||
using Reader<EventCacher>::handle; | ||
|
||
bool handle(const Reader::RecordSampleType* sample); | ||
|
||
void finalize() | ||
{ | ||
for (auto& events : events_) | ||
{ | ||
writers_[events.first]->submit_events(events.second); | ||
} | ||
} | ||
|
||
private: | ||
std::map<dev_t, std::unique_ptr<Writer>>& writers_; | ||
std::unordered_map<dev_t, std::vector<BioEvent>> events_; | ||
}; | ||
|
||
} // namespace bio | ||
} // namespace perf | ||
} // namespace lo2s |
Oops, something went wrong.