aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Savitski <rsavitski@google.com>2022-04-20 14:11:49 +0100
committerRyan Savitski <rsavitski@google.com>2022-04-20 13:12:16 +0000
commit20431b0e12148aaacc7f9bb22b6f1c303fc54c56 (patch)
treee6829df108c5d490feeb6f38091871d32c77d423
parent3c9ba85055dfe34570196ca2eb0331f511d9717d (diff)
downloadperfetto-20431b0e12148aaacc7f9bb22b6f1c303fc54c56.tar.gz
traced_perf: fixup erroneous [D]CHECKS
The contiguous sample dcheck wasn't correct, it failed when the end of the event aligned with the end of the buffer (e.g. 4 != 4%4). Instead of fixing it up, remove the dcheck altogether as it's strongly implied by the if-else condition and surrounding checks. Assignment in the CHECK was an error-prone typo. I double-checked the rest of the codebase with a basic search, no other hits. Change-Id: I1c051d87590bb3c4f17287498123255d7338cf73
-rw-r--r--src/profiling/perf/event_reader.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/profiling/perf/event_reader.cc b/src/profiling/perf/event_reader.cc
index de05f8b70..3c6271a8e 100644
--- a/src/profiling/perf/event_reader.cc
+++ b/src/profiling/perf/event_reader.cc
@@ -135,7 +135,9 @@ base::Optional<PerfRingBuffer> PerfRingBuffer::Allocate(
ret.metadata_page_ = reinterpret_cast<perf_event_mmap_page*>(mmap_addr);
ret.data_buf_ = reinterpret_cast<char*>(mmap_addr) + base::kPageSize;
PERFETTO_CHECK(ret.metadata_page_->data_offset == base::kPageSize);
- PERFETTO_CHECK(ret.metadata_page_->data_size = ret.data_buf_sz_);
+ PERFETTO_CHECK(ret.metadata_page_->data_size == ret.data_buf_sz_);
+
+ PERFETTO_DCHECK(IsPowerOfTwo(ret.data_buf_sz_));
return base::make_optional(std::move(ret));
}
@@ -178,8 +180,6 @@ char* PerfRingBuffer::ReadRecordNonconsuming() {
// event wrapped - reconstruct it, and return a pointer to the buffer
if (read_pos + evt_size > data_buf_sz_) {
- PERFETTO_DCHECK(read_pos + evt_size !=
- ((read_pos + evt_size) & (data_buf_sz_ - 1)));
PERFETTO_DLOG("PerfRingBuffer: returning reconstructed event");
size_t prefix_sz = data_buf_sz_ - read_pos;
@@ -189,9 +189,6 @@ char* PerfRingBuffer::ReadRecordNonconsuming() {
return &reconstructed_record_[0];
} else {
// usual case - contiguous sample
- PERFETTO_DCHECK(read_pos + evt_size ==
- ((read_pos + evt_size) & (data_buf_sz_ - 1)));
-
return data_buf_ + read_pos;
}
}