Use /proc/pid/stat to get total CPU time on Linux.

The previous implementation read /proc/pid/task/tid/stat for each
thread in the process. This had two issues:
1. When threads die, their CPU cost dies with them and so cumulative
   CPU cost for a process can go backwards. Reading /proc/pid/stat
   accounts for the cost due to dead threads.
2. It incurs a extra overhead to open all the individual task files
   that can be avoided by having the kernel do the tally in a single
   system call, and grabbing the relevant locks only once.

For back story see e.g. https://crbug.com/546565.

Bug: 841355
Change-Id: I82582e69187e4cd4069cf9dd02a4b62c326897e6
Reviewed-on: https://chromium-review.googlesource.com/1052811
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558505}

CrOS-Libchrome-Original-Commit: 6c062bad87e74d1b1ade0889db9fdba838175a28
3 files changed
tree: 1e229d44aa9dde84e4a0122393d442337b716717
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/