cpuacct.stat is too much bigger than cpuacct.usage
From: qing hao
Date: Wed Nov 01 2017 - 05:01:38 EST
Hello,
I found that on kernel linux3.10, 64-bit, not virtual machine, when I
attach my process to a newly created cgroup
(/sys/fs/cgroup/cpu,cpuacct/p1), the cputime collection of
cpuacct.stat and cpuacct.usage have a big difference. Cputime in
cpuacct.stat is too much bigger than cpuacct.usage.
(I tried on linux4.4, and doesn't has such issue. I searched mailing
list, but didn't find related fix.)
Is there any explanation, or is this a kernel bug? Which file's CPU
time is more accurate that I can trust? I need separated sys time and
user time.
# cat run.sh
#! /bin/bash
sudo echo $$ > /sys/fs/cgroup/cpu,cpuacct/p1/tasks
MAX=200000
for i in $(seq ${MAX})
do
echo "test" > /tmp/p1
rm /tmp/p1
done
# cat cpuacct.stat cpuacct.usage
user 7756
system 37760 --> utime + stime = 377s + 77s = 454s
360566710120 --> total cputime is 360s
# getconf CLK_TCK
100
# pwd
/sys/devices/system/cpu
# cat present
0-3
# cat online
0-3
Looking forward for you reply. Thanks.
-Qing