New issue
Advanced search Search tips

Issue 841355 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: May 2018
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

CPU usage not monotonically growing on Linux

Project Member Reported by siggi@chromium.org, May 9 2018

Issue description

The base::ProcessMetrics implementation on Linux walks 
/proc/<pid>/task/<tid>/stat 
and adds them up to get cumulative CPU time. When threads die, their cumulatives vanish from this tally, whereas
/proc/<pid>/stat
should presumably preserve same.
 
Project Member

Comment 1 by bugdroid1@chromium.org, May 14 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6c062bad87e74d1b1ade0889db9fdba838175a28

commit 6c062bad87e74d1b1ade0889db9fdba838175a28
Author: Sigurdur Asgeirsson <siggi@chromium.org>
Date: Mon May 14 22:56:11 2018

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}
[modify] https://crrev.com/6c062bad87e74d1b1ade0889db9fdba838175a28/base/process/process_metrics.h
[modify] https://crrev.com/6c062bad87e74d1b1ade0889db9fdba838175a28/base/process/process_metrics_linux.cc
[modify] https://crrev.com/6c062bad87e74d1b1ade0889db9fdba838175a28/base/process/process_metrics_unittest.cc

Comment 2 by siggi@chromium.org, May 15 2018

Status: Fixed (was: Untriaged)

Comment 3 by siggi@chromium.org, May 16 2018

 Issue 841356  has been merged into this issue.

Sign in to add a comment