Commit 3be2934d authored by Micha Mueller's avatar Micha Mueller
Browse files

Perf-plugin: adapt read-buffer size to new struct format

parent 605cdbd0
......@@ -44,9 +44,22 @@ PerfSensorGroup::~PerfSensorGroup() {
void PerfSensorGroup::init(boost::asio::io_service& io) {
SensorGroupTemplate::init(io);
//allocate buffer to read in later
//requires 16 byte per sensor plus an additional 8 byte for a 64bit value
std::size_t bufSize = _sensors.size() * 16 + 8;
/* Allocate buffer to read in later. Reading struct has the following format:
*
* struct read_format {
* u64 nr; // The number of events
* u64 time_enabled; // if PERF_FORMAT_TOTAL_TIME_ENABLED
* u64 time_running; // if PERF_FORMAT_TOTAL_TIME_RUNNING
* struct {
* u64 value; // The value of the event
* u64 id; // if PERF_FORMAT_ID
* } values[nr];
* };
*
* Therefore we require 16 byte per sensor plus an additional 8*3 byte
*/
//requires
std::size_t bufSize = _sensors.size() * 16 + 24;
if (!_buf) {
_buf = new char[bufSize];
_bufSize = bufSize;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment