)]}'
{
  "commit": "564c2b210add41df9a3a5aaa365c1d97cff6110d",
  "tree": "2fe54df816abfe8c6010d277c79fbe18aa5c4082",
  "parents": [
    "a63eaf34ae60bdb067a354cc8def2e8f4a01f5f4"
  ],
  "author": {
    "name": "Paul Mackerras",
    "email": "paulus@samba.org",
    "time": "Fri May 22 14:27:22 2009 +1000"
  },
  "committer": {
    "name": "Ingo Molnar",
    "email": "mingo@elte.hu",
    "time": "Fri May 22 12:18:20 2009 +0200"
  },
  "message": "perf_counter: Optimize context switch between identical inherited contexts\n\nWhen monitoring a process and its descendants with a set of inherited\ncounters, we can often get the situation in a context switch where\nboth the old (outgoing) and new (incoming) process have the same set\nof counters, and their values are ultimately going to be added together.\nIn that situation it doesn\u0027t matter which set of counters are used to\ncount the activity for the new process, so there is really no need to\ngo through the process of reading the hardware counters and updating\nthe old task\u0027s counters and then setting up the PMU for the new task.\n\nThis optimizes the context switch in this situation.  Instead of\nscheduling out the perf_counter_context for the old task and\nscheduling in the new context, we simply transfer the old context\nto the new task and keep using it without interruption.  The new\ncontext gets transferred to the old task.  This means that both\ntasks still have a valid perf_counter_context, so no special case\nis introduced when the old task gets scheduled in again, either on\nthis CPU or another CPU.\n\nThe equivalence of contexts is detected by keeping a pointer in\neach cloned context pointing to the context it was cloned from.\nTo cope with the situation where a context is changed by adding\nor removing counters after it has been cloned, we also keep a\ngeneration number on each context which is incremented every time\na context is changed.  When a context is cloned we take a copy\nof the parent\u0027s generation number, and two cloned contexts are\nequivalent only if they have the same parent and the same\ngeneration number.  In order that the parent context pointer\nremains valid (and is not reused), we increment the parent\ncontext\u0027s reference count for each context cloned from it.\n\nSince we don\u0027t have individual fds for the counters in a cloned\ncontext, the only thing that can make two clones of a given parent\ndifferent after they have been cloned is enabling or disabling all\ncounters with prctl.  To account for this, we keep a count of the\nnumber of enabled counters in each context.  Two contexts must have\nthe same number of enabled counters to be considered equivalent.\n\nHere are some measurements of the context switch time as measured with\nthe lat_ctx benchmark from lmbench, comparing the times obtained with\nand without this patch series:\n\n\t\t-----Unmodified-----\t\tWith this patch series\nCounters:\tnone\t2 HW\t4H+4S\tnone\t2 HW\t4H+4S\n\n2 processes:\nAverage\t\t3.44\t6.45\t11.24\t3.12\t3.39\t3.60\nSt dev\t\t0.04\t0.04\t0.13\t0.05\t0.17\t0.19\n\n8 processes:\nAverage\t\t6.45\t8.79\t14.00\t5.57\t6.23\t7.57\nSt dev\t\t1.27\t1.04\t0.88\t1.42\t1.46\t1.42\n\n32 processes:\nAverage\t\t5.56\t8.43\t13.78\t5.28\t5.55\t7.15\nSt dev\t\t0.41\t0.47\t0.53\t0.54\t0.57\t0.81\n\nThe numbers are the mean and standard deviation of 20 runs of\nlat_ctx.  The \"none\" columns are lat_ctx run directly without any\ncounters.  The \"2 HW\" columns are with lat_ctx run under perfstat,\ncounting cycles and instructions.  The \"4H+4S\" columns are lat_ctx run\nunder perfstat with 4 hardware counters and 4 software counters\n(cycles, instructions, cache references, cache misses, task\nclock, context switch, cpu migrations, and page faults).\n\n[ Impact: performance optimization of counter context-switches ]\n\nSigned-off-by: Paul Mackerras \u003cpaulus@samba.org\u003e\nAcked-by: Peter Zijlstra \u003ca.p.zijlstra@chello.nl\u003e\nCc: Corey Ashford \u003ccjashfor@linux.vnet.ibm.com\u003e\nCc: Marcelo Tosatti \u003cmtosatti@redhat.com\u003e\nCc: Arnaldo Carvalho de Melo \u003cacme@redhat.com\u003e\nLKML-Reference: \u003c18966.10666.517218.332164@cargo.ozlabs.ibm.com\u003e\nSigned-off-by: Ingo Molnar \u003cmingo@elte.hu\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "071309005468ae936296237a71ec3dcc60893a4f",
      "old_mode": 33188,
      "old_path": "include/linux/perf_counter.h",
      "new_id": "4cae01a50450808e500716725e60ca51c723cfda",
      "new_mode": 33188,
      "new_path": "include/linux/perf_counter.h"
    },
    {
      "type": "modify",
      "old_id": "06ea3eae886e3b0c0343c3a3ab02795e39504cce",
      "old_mode": 33188,
      "old_path": "kernel/perf_counter.c",
      "new_id": "c10055416dea56aff4fa85027851c56b7f087f03",
      "new_mode": 33188,
      "new_path": "kernel/perf_counter.c"
    },
    {
      "type": "modify",
      "old_id": "419a39d0988fd97ed18c6321a73896493eab2b8a",
      "old_mode": 33188,
      "old_path": "kernel/sched.c",
      "new_id": "4c0d58bce6b28febe75049a7476cb8796b2a6b44",
      "new_mode": 33188,
      "new_path": "kernel/sched.c"
    }
  ]
}
