title: /proc/[pid]/stat refresh period
body: <p>hi I am a Linux programmer</p>
  
  <p>I have an order that monitor process cpus usage, so I use data on /proc/[pid]/stat № 14 and 15. That values are called utime and stime.</p>
  
  <p>Example [/proc/[pid]/stat]</p>
  
  <pre><code>30182 (TTTTest) R 30124 30182 30124 34845 30182 4218880 142 0 0 0 5274 0 0 0 20 0 1 0 55611251 17408000 386 18446744073709551615 4194304 4260634 140733397159392 140733397158504 4203154 0 0 0 0 0 0 0 17 2 0 0 0 0 0 6360520 6361584 33239040 140733397167447 140733397167457 140733397167457 140733397168110 0
  </code></pre>
  
  <p>State after 5 sec</p>
  
  <pre><code>30182 (TTTTest) R 30124 30182 30124 34845 30182 4218880 142 0 0 0 5440 0 0 0 20 0 1 0 55611251 17408000 386 18446744073709551615 4194304 4260634 140733397159392 140733397158504 4203154 0 0 0 0 0 0 0 17 2 0 0 0 0 0 6360520 6361584 33239040 140733397167447 140733397167457 140733397167457 140733397168110 0
  </code></pre>
  
  <p>In test environment, this file refreshed 1 ~ 2 sec, so I assume this file often updated by system at least 1 sec.</p>
  
  <p>So I use this calculation</p>
  
  <pre><code>process_cpu_usage = ((utime - old_utime) + (stime - old_stime))/ period
  </code></pre>
  
  <p>In case of above values</p>
  
  <pre><code>33.2 = ((5440 - 5274) + (0 - 0)) / 5
  </code></pre>
  
  <p>But, In commercial servers environment, process run with high load (cpu and file IO), /proc/[pid]/stat file update period increasing even 20~60 sec!!</p>
  
  <p>So top/htop utility can't measure correct process usage value.</p>
  
  <p>Why is this phenomenon occurring??</p>
  
  <p>Our system is [CentOS Linux release 7.1.1503 (Core)]</p>