Index: base/process/process_metrics_linux.cc |
diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc |
index 5ecbcb976e2b7f0e55cc871ef34e1b4690df6423..3f33516b137c569b7469a0ae998d6c1a6e381788 100644 |
--- a/base/process/process_metrics_linux.cc |
+++ b/base/process/process_metrics_linux.cc |
@@ -93,23 +93,23 @@ size_t ReadProcStatusAndGetFieldAsSizeT(pid_t pid, const std::string& field) { |
} |
#if defined(OS_LINUX) || defined(OS_AIX) |
-// Read /proc/<pid>/sched and look for |field|. On succes, return true and |
+// Read /proc/<pid>/status and look for |field|. On succes, return true and |
// write the value for |field| into |result|. |
// Only works for fields in the form of "field : uint_value" |
-bool ReadProcSchedAndGetFieldAsUint64(pid_t pid, |
- const std::string& field, |
- uint64_t* result) { |
- std::string sched_data; |
+bool ReadProcStatusAndGetFieldAsUint64(pid_t pid, |
+ const std::string& field, |
+ uint64_t* result) { |
+ std::string stat_data; |
Mark Mentovai
2017/05/03 03:17:17
/proc/pid/stat and /proc/pid/status are distinct.
sabbakumov
2017/05/03 03:21:02
I used the convention from the ReadProcStatusAndGe
sabbakumov
2017/05/03 05:20:05
Done.
|
{ |
// Synchronously reading files in /proc does not hit the disk. |
ThreadRestrictions::ScopedAllowIO allow_io; |
- FilePath sched_file = internal::GetProcPidDir(pid).Append("sched"); |
- if (!ReadFileToString(sched_file, &sched_data)) |
+ FilePath stat_file = internal::GetProcPidDir(pid).Append("status"); |
+ if (!ReadFileToString(stat_file, &stat_data)) |
return false; |
} |
StringPairs pairs; |
- SplitStringIntoKeyValuePairs(sched_data, ':', '\n', &pairs); |
+ SplitStringIntoKeyValuePairs(stat_data, ':', '\n', &pairs); |
TrimKeyValuePairs(&pairs); |
for (size_t i = 0; i < pairs.size(); ++i) { |
const std::string& key = pairs[i].first; |
@@ -959,10 +959,11 @@ void GetSwapInfo(SwapInfo* swap_info) { |
#if defined(OS_LINUX) || defined(OS_AIX) |
int ProcessMetrics::GetIdleWakeupsPerSecond() { |
- uint64_t wake_ups; |
- const char kWakeupStat[] = "se.statistics.nr_wakeups"; |
- return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? |
- CalculateIdleWakeupsPerSecond(wake_ups) : 0; |
+ uint64_t num_switches; |
+ static const char kSwitchStat[] = "voluntary_ctxt_switches"; |
Mark Mentovai
2017/05/03 03:17:18
I haven’t (yet?) verified that this is equivalent
|
+ return ReadProcStatusAndGetFieldAsUint64(process_, kSwitchStat, &num_switches) |
+ ? CalculateIdleWakeupsPerSecond(num_switches) |
+ : 0; |
} |
#endif // defined(OS_LINUX) || defined(OS_AIX) |