From: Fredrik Markstrom <fredrik.markstrom@gmail.com>
To: mingo@redhat.com, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org,
Fredrik Markstrom <fredrik.markstrom@gmail.com>
Subject: [PATCH 0/1] cputime: Make the reported utime+stime correspond to the actual runtime.
Date: Fri, 12 Jun 2015 10:55:15 +0200 [thread overview]
Message-ID: <1434099316-29749-1-git-send-email-fredrik.markstrom@gmail.com> (raw)
We've hunted a bug that manifests itself in top showing abnormal (>100%)
loads on single threads, sometimes top can show a couple of thousand percent.
We've found the cause of this behavior in cputime_adjust() where the kernel
tries to split the actual runtime into user and system time based on the number
of times that thread was found executing in system or user mode respectively.
The actual problem is a piece of code that *independently* updates the reported
utime and stime to force it to be monotonically increasing.
A small application tailored to trigger this case causes top to output the
following (the load should always be ~20%). The application can be found at:
https://gist.github.com/frma71/706410acbd31556dbbfa
The cause of this is the data read from /proc/<pid>/stat as demonstrated by
the awk-script further down in this email.
The application to reproduce it is not very robust and will sometimes not
reliably reproduce it, on my arndale (2*CA15) it does at least nine
times out of ten. Anyway, the code should explain the problem pretty clearly.
I will follow up with my proposed fix (tested with next-20150610) in a minute or so.
# top -d 1 -H -b -p $(pidof loadbug) |grep loadbug
3100 root 20 0 1596 964 700 S 22 0.0 0:00.47 loadbug
3100 root 20 0 1596 964 700 R 21 0.0 0:00.69 loadbug
3100 root 20 0 1596 964 700 S 22 0.0 0:00.92 loadbug
3100 root 20 0 1596 964 700 S 21 0.0 0:01.14 loadbug
3100 root 20 0 1596 964 700 R 21 0.0 0:01.36 loadbug
3100 root 20 0 1596 964 700 S 22 0.0 0:01.59 loadbug
3100 root 20 0 1596 964 700 S 21 0.0 0:01.81 loadbug
3100 root 20 0 1596 964 700 S 22 0.0 0:02.04 loadbug
3100 root 20 0 1596 964 700 S 204 0.0 0:04.13 loadbug <==
3100 root 20 0 1596 964 700 R 0 0.0 0:04.13 loadbug
3100 root 20 0 1596 964 700 S 0 0.0 0:04.13 loadbug
3100 root 20 0 1596 964 700 S 0 0.0 0:04.13 loadbug
3100 root 20 0 1596 964 700 S 0 0.0 0:04.13 loadbug
3100 root 20 0 1596 964 700 S 0 0.0 0:04.13 loadbug
3100 root 20 0 1596 964 700 R 0 0.0 0:04.13 loadbug
3100 root 20 0 1596 964 700 S 0 0.0 0:04.13 loadbug
3100 root 20 0 1596 964 700 S 209 0.0 0:06.28 loadbug
% while true ; do cat /proc/$(pidof loadbug)/task/*/stat ; sleep 2 ; done | awk '{print $14 " " $15 " Delta=" $14+$15-L ;L=$14+$15}'
0 33 Delta=-103
0 77 Delta=44
0 121 Delta=44
0 165 Delta=44
0 208 Delta=43
254 208 Delta=254 <==
254 208 Delta=0
254 208 Delta=0
254 208 Delta=0
254 208 Delta=0
494 208 Delta=240
494 208 Delta=0
494 208 Delta=0
494 208 Delta=0
494 208 Delta=0
717 208 Delta=223
717 208 Delta=0
Fredrik Markstrom (1):
cputime: Make the reported utime+stime correspond to the actual
runtime.
kernel/sched/cputime.c | 46 +++++++++++++++++++---------------------------
1 file changed, 19 insertions(+), 27 deletions(-)
--
1.9.1
next reply other threads:[~2015-06-12 8:57 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-12 8:55 Fredrik Markstrom [this message]
2015-06-12 8:55 ` [PATCH 1/1] cputime: Make the reported utime+stime correspond to the actual runtime Fredrik Markstrom
2015-06-12 10:16 ` Peter Zijlstra
2015-06-12 11:01 ` Peter Zijlstra
2015-06-15 15:34 ` Fredrik Markström
2015-06-16 14:35 ` Fredrik Markström
2015-06-29 14:58 ` Peter Zijlstra
2015-06-29 15:28 ` Fredrik Markström
2015-06-29 18:54 ` Jason Low
2015-06-29 19:08 ` Fredrik Markström
2015-06-29 22:11 ` Jason Low
2015-06-30 9:30 ` Peter Zijlstra
2015-06-30 11:50 ` Fredrik Markström
2015-06-30 12:18 ` Peter Zijlstra
2015-06-30 18:30 ` Fredrik Markström
2015-07-02 12:11 ` Peter Zijlstra
2015-07-02 13:07 ` Peter Zijlstra
2015-07-07 0:51 ` Frederic Weisbecker
2015-07-07 7:59 ` Peter Zijlstra
2015-07-07 8:09 ` Peter Zijlstra
2015-07-07 12:10 ` Fredrik Markström
2015-07-07 15:37 ` Peter Zijlstra
2015-07-07 13:34 ` Frederic Weisbecker
2015-07-07 15:34 ` Peter Zijlstra
2015-07-07 16:26 ` Frederic Weisbecker
2015-06-13 11:17 ` Fredrik Markström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434099316-29749-1-git-send-email-fredrik.markstrom@gmail.com \
--to=fredrik.markstrom@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox