From 35a32aa7100b5f00805e9175e0f01a1d836fd101 Mon Sep 17 00:00:00 2001 From: zcfh <1412805291@qq.com> Date: Fri, 12 Jul 2024 19:10:17 +0800 Subject: [PATCH] Ignore unexpected warnings in `PerfDataSampleReader::Append` Recently, commit 623c777 upgraded perf_data_converter. There are some changes in the `PerfParser::MapBranchStack`. In the new version, even if the mapping of from_ip fails, the mapping process for to_ip will still proceed. This may lead to a situation where from.offset_ equals the initial value 0 when from_ip mapping fails, and to.offset_ equals the actual offset when to_ip mapping succeeds. This inconsistency may cause the subsequent check to erroneously warn about 'Bogus LBR data'. A large number of such warnings during use are more likely to cause confusion and need to be filtered in advance. --- sample_reader.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sample_reader.cc b/sample_reader.cc index f37be53..7674cb5 100644 --- a/sample_reader.cc +++ b/sample_reader.cc @@ -318,6 +318,13 @@ bool PerfDataSampleReader::Append(const std::string &profile_file) { continue; } + // if from_ip map in perf_data_converter PerfParser::MapBranchStack fails but to_ip map succeeeds. + // Then from.offset() == 0 and to.offset() == ${offset}. + // This will cause the following check to erroneously warning "Bogus LBR data". + if (event.branch_stack[i - 1].from.dso_info_ == NULL) { + continue; + } + // TODO(b/62827958): Get rid of this temporary workaround once the issue // of duplicate entries in LBR is resolved. It only happens at the head // of the LBR. In addition, it is possible that the duplication is @@ -333,7 +340,8 @@ bool PerfDataSampleReader::Append(const std::string &profile_file) { (event.branch_stack[0].from.offset() - event.branch_stack[0].to.offset() > absl::GetFlag(FLAGS_strip_dup_backedge_stride_limit))) { - LOG(WARNING) << "Bogus LBR data (duplicated top entry)"; + if (event.branch_stack[1].from.dso_info_ == NULL) + LOG(WARNING) << "Bogus LBR data (duplicated top entry)"; continue; } uint64_t begin = event.branch_stack[i].to.offset();