2

I'm sure this is just the way it is, but can somebody give a good reference to an explanation of this observeation.

When I add up all the fields for a CPU in /proc/stat, CPU0 only reports activity for 6134 seconds It is thus 89 seconds behind /proc/uptime

According to http://man7.org/linux/man-pages/man5/proc.5.html all kinds of activity seems covered, but are there something which is not counted?

~ # cat /proc/uptime                                                 
6223.05 10849.57
~ # awk /cpu/'{print $1, $2+$3+$4+$5+$6+$7+$8+$9+$10+$11}' /proc/stat
cpu 1233568
cpu0 613483
cpu1 620083

I'm using a dual core ARMv7 Processor rev 5 (v7l)
CPU0 is by intention higher loaded thatn CPU1

Btw my ubuntu does the same.

EDIT: I have now observed that it can also run faster This small script shows my problem.

b=`awk /cpu1/'{print $2+$3+$4+$5+$6+$7+$8+$9+$10+$11}' /proc/stat`
sleep 1
a=`awk /cpu1/'{print $2+$3+$4+$5+$6+$7+$8+$9+$10+$11}' /proc/stat`
expr $a - $b

Usually the sleep takes 20 ms extra, but on my target with 100 jiffies/s, I counted up to 140 jiffies/s this way.

It seems to be the user space and the idle that counts the jiffies. On one samle I calculated 102 user space jiffies, which can be explained by sleep taking 20 ms extra. Thus user space takes up all the time.

But then there was also 33 idle ticks.

It is random what my system reports, between reboots. Typically it is around 40, 90 or 140 jiffies/s with the same piece of software. It does not change once the system is up.

Either my system got a bug in how /proc/stat counters is updated. OR the counters in /proc/stat is not jiffies.

F. Hauri - Give Up GitHub
  • 64,122
  • 17
  • 116
  • 137
Kjeld Flarup
  • 1,471
  • 10
  • 15

0 Answers0