There are a few reasons why that would be the case, the most obvious one is that the per-process accounting uses different logic for counting different things.
Two specific examples:
- The system
stat
has a nice
column that counts user time spent in nice tasks (lower priority) - which you didn't specify that you use, so I'm guessing you didn't sum it. In the process this will be counted as standard user time.
iowait
time - which also you didn't account for - is likely counted in the process stat
as system time. But its a bad idea to also count in iowait
time as it is very unreliable account of actual time, as man proc
explains:
iowait (since Linux 2.5.41)
(5) Time waiting for I/O to complete. This value is not reliable, for the following reasons:
The CPU will not wait for I/O to complete; iowait is the time that a task is waiting for I/O to complete. When a CPU goes into idle state for outstanding task I/O, another task will be scheduled on this CPU.
On a multi-core CPU, the task waiting for I/O to complete is not running on any CPU, so the iowait of each CPU is difficult to calculate.
The value in this field may decrease in certain conditions.
Lastly, I have to note that I believe this type of accounting is useless as it can never be accurate enough for any serious purpose - system and process counters are processed in different parts of the system for different purposes and will never match to any useful degree.