Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2343)

Unified Diff: base/trace_event/process_memory_dump.cc

Issue 1398163003: Handle EAGAIN error for the mincore syscall used (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resident
Patch Set: Ignore error in release builds. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/process_memory_dump.cc
diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc
index 0ec007e2ee46f5140bf83ee5580a7f5c1ee221f4..36a317d00deb45dcec8300812ffdee1483ecfc3a 100644
--- a/base/trace_event/process_memory_dump.cc
+++ b/base/trace_event/process_memory_dump.cc
@@ -51,14 +51,32 @@ size_t ProcessMemoryDump::CountResidentBytes(void* start_address,
#if defined(OS_MACOSX) || defined(OS_IOS)
std::vector<char> vec(page_count + 1);
+ // mincore in MAC does not fail with EAGAIN.
int res = mincore(chunk_start, chunk_size, vector_as_array(&vec));
DCHECK(!res);
+ if (res) {
+ LOG(ERROR)
+ << "Mincore call failed. The resident size may not be accurate";
Primiano Tucci (use gerrit) 2015/10/15 11:20:18 nit: s/Mincore/mincore()/ also, if you continue he
ssid 2015/10/15 11:23:43 The call to mincore failed only once. The next set
+ continue;
+ }
+
for (size_t i = 0; i < page_count; i++)
resident_page_count += vec[i] & MINCORE_INCORE ? 1 : 0;
#else // defined(OS_MACOSX) || defined(OS_IOS)
std::vector<unsigned char> vec(page_count + 1);
- int res = mincore(chunk_start, chunk_size, vector_as_array(&vec));
+ int error_counter = 0;
+ int res = 0;
+ // HANDLE_EINTR tries for 100 times. So following the same pattern.
+ do {
+ res = mincore(chunk_start, chunk_size, vector_as_array(&vec));
+ } while (res == -1 && errno == EAGAIN && error_counter++ < 100);
DCHECK(!res);
+ if (res) {
+ LOG(ERROR)
+ << "Mincore call failed. The resident size may not be accurate";
Primiano Tucci (use gerrit) 2015/10/15 11:20:18 can we avoid duplicating this and above?
ssid 2015/10/15 11:23:43 I would have to add 3 extra #if defined. that is w
Primiano Tucci (use gerrit) 2015/10/15 11:27:13 ?? how about you just add this to before line 87:
ssid 2015/10/15 11:39:30 Yes, sounds good.
+ continue;
+ }
+
for (size_t i = 0; i < page_count; i++)
resident_page_count += vec[i];
#endif // defined(OS_MACOSX) || defined(OS_IOS)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698