)]}'
{
  "commit": "0cf55e1ec08bb5a22e068309e2d8ba1180ab4239",
  "tree": "6102662a9594d51155bee11666fe8517fcbe6039",
  "parents": [
    "d99ca3b977fc5a93141304f571475c2af9e6c1c5"
  ],
  "author": {
    "name": "Hidetoshi Seto",
    "email": "seto.hidetoshi@jp.fujitsu.com",
    "time": "Wed Dec 02 17:28:07 2009 +0900"
  },
  "committer": {
    "name": "Ingo Molnar",
    "email": "mingo@elte.hu",
    "time": "Wed Dec 02 17:32:40 2009 +0100"
  },
  "message": "sched, cputime: Introduce thread_group_times()\n\nThis is a real fix for problem of utime/stime values decreasing\ndescribed in the thread:\n\n   http://lkml.org/lkml/2009/11/3/522\n\nNow cputime is accounted in the following way:\n\n - {u,s}time in task_struct are increased every time when the thread\n   is interrupted by a tick (timer interrupt).\n\n - When a thread exits, its {u,s}time are added to signal-\u003e{u,s}time,\n   after adjusted by task_times().\n\n - When all threads in a thread_group exits, accumulated {u,s}time\n   (and also c{u,s}time) in signal struct are added to c{u,s}time\n   in signal struct of the group\u0027s parent.\n\nSo {u,s}time in task struct are \"raw\" tick count, while\n{u,s}time and c{u,s}time in signal struct are \"adjusted\" values.\n\nAnd accounted values are used by:\n\n - task_times(), to get cputime of a thread:\n   This function returns adjusted values that originates from raw\n   {u,s}time and scaled by sum_exec_runtime that accounted by CFS.\n\n - thread_group_cputime(), to get cputime of a thread group:\n   This function returns sum of all {u,s}time of living threads in\n   the group, plus {u,s}time in the signal struct that is sum of\n   adjusted cputimes of all exited threads belonged to the group.\n\nThe problem is the return value of thread_group_cputime(),\nbecause it is mixed sum of \"raw\" value and \"adjusted\" value:\n\n  group\u0027s {u,s}time \u003d foreach(thread){{u,s}time} + exited({u,s}time)\n\nThis misbehavior can break {u,s}time monotonicity.\nAssume that if there is a thread that have raw values greater\nthan adjusted values (e.g. interrupted by 1000Hz ticks 50 times\nbut only runs 45ms) and if it exits, cputime will decrease (e.g.\n-5ms).\n\nTo fix this, we could do:\n\n  group\u0027s {u,s}time \u003d foreach(t){task_times(t)} + exited({u,s}time)\n\nBut task_times() contains hard divisions, so applying it for\nevery thread should be avoided.\n\nThis patch fixes the above problem in the following way:\n\n - Modify thread\u0027s exit (\u003d __exit_signal()) not to use task_times().\n   It means {u,s}time in signal struct accumulates raw values instead\n   of adjusted values.  As the result it makes thread_group_cputime()\n   to return pure sum of \"raw\" values.\n\n - Introduce a new function thread_group_times(*task, *utime, *stime)\n   that converts \"raw\" values of thread_group_cputime() to \"adjusted\"\n   values, in same calculation procedure as task_times().\n\n - Modify group\u0027s exit (\u003d wait_task_zombie()) to use this introduced\n   thread_group_times().  It make c{u,s}time in signal struct to\n   have adjusted values like before this patch.\n\n - Replace some thread_group_cputime() by thread_group_times().\n   This replacements are only applied where conveys the \"adjusted\"\n   cputime to users, and where already uses task_times() near by it.\n   (i.e. sys_times(), getrusage(), and /proc/\u003cPID\u003e/stat.)\n\nThis patch have a positive side effect:\n\n - Before this patch, if a group contains many short-life threads\n   (e.g. runs 0.9ms and not interrupted by ticks), the group\u0027s\n   cputime could be invisible since thread\u0027s cputime was accumulated\n   after adjusted: imagine adjustment function as adj(ticks, runtime),\n     {adj(0, 0.9) + adj(0, 0.9) + ....} \u003d {0 + 0 + ....} \u003d 0.\n   After this patch it will not happen because the adjustment is\n   applied after accumulated.\n\nv2:\n - remove if()s, put new variables into signal_struct.\n\nSigned-off-by: Hidetoshi Seto \u003cseto.hidetoshi@jp.fujitsu.com\u003e\nAcked-by: Peter Zijlstra \u003cpeterz@infradead.org\u003e\nCc: Spencer Candland \u003cspencer@bluehost.com\u003e\nCc: Americo Wang \u003cxiyou.wangcong@gmail.com\u003e\nCc: Oleg Nesterov \u003coleg@redhat.com\u003e\nCc: Balbir Singh \u003cbalbir@in.ibm.com\u003e\nCc: Stanislaw Gruszka \u003csgruszka@redhat.com\u003e\nLKML-Reference: \u003c4B162517.8040909@jp.fujitsu.com\u003e\nSigned-off-by: Ingo Molnar \u003cmingo@elte.hu\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "ca61a88aed663bc6b6fed8d7c94e270140d68f3c",
      "old_mode": 33188,
      "old_path": "fs/proc/array.c",
      "new_id": "2571da43c7364b0d227b108f3ae1c85562e7eb15",
      "new_mode": 33188,
      "new_path": "fs/proc/array.c"
    },
    {
      "type": "modify",
      "old_id": "dff85e58264e92c1589b7302e5bd9c6c4d0546ae",
      "old_mode": 33188,
      "old_path": "include/linux/sched.h",
      "new_id": "34238bd10ebf72eae34217200e267cffe7a13178",
      "new_mode": 33188,
      "new_path": "include/linux/sched.h"
    },
    {
      "type": "modify",
      "old_id": "2eaf68b634e3b592726b5176188cc6186cbc6b27",
      "old_mode": 33188,
      "old_path": "kernel/exit.c",
      "new_id": "b221ad65fd20206675f270ac91d351070a087662",
      "new_mode": 33188,
      "new_path": "kernel/exit.c"
    },
    {
      "type": "modify",
      "old_id": "ad7cb6d1193c60a1ab3b840fa4d4a83a0d7a38a6",
      "old_mode": 33188,
      "old_path": "kernel/fork.c",
      "new_id": "3d6f121bbe8a3719c31c16cde4122ab341cb48b3",
      "new_mode": 33188,
      "new_path": "kernel/fork.c"
    },
    {
      "type": "modify",
      "old_id": "17e2c1db2bde9e624e776f1d170fc018af86a650",
      "old_mode": 33188,
      "old_path": "kernel/sched.c",
      "new_id": "e6ba726941ae8a744245015f80efc30deba49c5e",
      "new_mode": 33188,
      "new_path": "kernel/sched.c"
    },
    {
      "type": "modify",
      "old_id": "bbdfce0d4347bb451e0785df958892a5a5f475b1",
      "old_mode": 33188,
      "old_path": "kernel/sys.c",
      "new_id": "9968c5fb55b9f331eb2df9ba3ad5a5658da41b7f",
      "new_mode": 33188,
      "new_path": "kernel/sys.c"
    }
  ]
}
