summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-08-29 07:30:33 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-08-29 07:30:33 +0000
commit1af0c23c7455a8ca5a992c9d5d8e09fa795cf5f3 (patch)
tree7207f8b7f8fcd8ad2b2a81331e7fc7a67f72b6a3
parent4d75750d3ae4db090265dcbffdc40f49e4a7bb00 (diff)
parent0a26d1b8937ba3c4fda6f66e57cd418e314affba (diff)
downloadextras-1af0c23c7455a8ca5a992c9d5d8e09fa795cf5f3.tar.gz
release-request-5f16c261-dcc8-4c4f-a0bd-deb507084f3d-for-git_oc-mr1-release-4303954 snap-temp-L56100000097484036
Change-Id: I6793f1575118fadabf9d885cd3c8acd81633436c
-rw-r--r--ext4_utils/make_ext4fs.c7
-rw-r--r--simpleperf/event_selection_set.cpp29
2 files changed, 22 insertions, 14 deletions
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index 58069f31..0151026a 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -628,6 +628,13 @@ static void extract_base_fs_allocations(const char *directory, const char *mount
int start_block, end_block;
u32 block_file_size;
u32 real_file_block_size;
+ struct stat buf;
+
+ if (lstat(real_file_name, &buf) == -1)
+ critical_error(err_msg);
+
+ if (!S_ISREG(buf.st_mode))
+ continue;
real_file_fd = open(real_file_name, O_RDONLY);
if (real_file_fd == -1) {
diff --git a/simpleperf/event_selection_set.cpp b/simpleperf/event_selection_set.cpp
index 86f57b9d..7458572d 100644
--- a/simpleperf/event_selection_set.cpp
+++ b/simpleperf/event_selection_set.cpp
@@ -342,7 +342,7 @@ bool EventSelectionSet::OpenEventFilesOnGroup(EventSelectionGroup& group,
EventFd* group_fd = nullptr;
for (auto& selection : group) {
std::unique_ptr<EventFd> event_fd =
- EventFd::OpenEventFile(selection.event_attr, tid, cpu, group_fd);
+ EventFd::OpenEventFile(selection.event_attr, tid, cpu, group_fd, false);
if (event_fd != nullptr) {
LOG(VERBOSE) << "OpenEventFile for " << event_fd->Name();
event_fds.push_back(std::move(event_fd));
@@ -402,24 +402,25 @@ bool EventSelectionSet::OpenEventFiles(const std::vector<int>& on_cpus) {
}
} else {
for (const auto& pair : process_map) {
+ size_t success_count = 0;
+ std::string failed_event_type;
for (const auto& tid : pair.second) {
- size_t success_cpu_count = 0;
- std::string failed_event_type;
for (const auto& cpu : cpus) {
if (OpenEventFilesOnGroup(group, tid, cpu, &failed_event_type)) {
- success_cpu_count++;
+ success_count++;
}
}
- // As the online cpus can be enabled or disabled at runtime, we may not
- // open event file for all cpus successfully. But we should open at
- // least one cpu successfully.
- if (success_cpu_count == 0) {
- PLOG(ERROR) << "failed to open perf event file for event_type "
- << failed_event_type << " for "
- << (tid == -1 ? "all threads" : "thread " + std::to_string(tid))
- << " on all cpus";
- return false;
- }
+ }
+ // We can't guarantee to open perf event file successfully for each thread on each cpu.
+ // Because threads may exit between PrepareThreads() and OpenEventFilesOnGroup(), and
+ // cpus may be offlined between GetOnlineCpus() and OpenEventFilesOnGroup().
+ // So we only check that we can at least monitor one thread for each process.
+ if (success_count == 0) {
+ PLOG(ERROR) << "failed to open perf event file for event_type "
+ << failed_event_type << " for "
+ << (pair.first == -1 ? "all threads"
+ : "threads in process " + std::to_string(pair.first));
+ return false;
}
}
}