)]}'
{
  "commit": "ad3a37de81c45f6c20d410ece86004b98f7b6d84",
  "tree": "6748194aa66d1648232dc9767cba44615d2e14fd",
  "parents": [
    "be1ac0d81d0e3ab655f8c8ade31fb860ef6aa186"
  ],
  "author": {
    "name": "Paul Mackerras",
    "email": "paulus@samba.org",
    "time": "Fri May 29 16:06:20 2009 +1000"
  },
  "committer": {
    "name": "Ingo Molnar",
    "email": "mingo@elte.hu",
    "time": "Fri May 29 11:02:46 2009 +0200"
  },
  "message": "perf_counter: Don\u0027t swap contexts containing locked mutex\n\nPeter Zijlstra pointed out that under some circumstances, we can take\nthe mutex in a context or a counter and then swap that context or\ncounter to another task, potentially leading to lock order inversions\nor the mutexes not protecting what they are supposed to protect.\n\nThis fixes the problem by making sure that we never take a mutex in a\ncontext or counter which could get swapped to another task.  Most of\nthe cases where we take a mutex is on a top-level counter or context,\ni.e. a counter which has an fd associated with it or a context that\ncontains such a counter.  This adds WARN_ON_ONCE statements to verify\nthat.\n\nThe two cases where we need to take the mutex on a context that is a\nclone of another are in perf_counter_exit_task and\nperf_counter_init_task.  The perf_counter_exit_task case is solved by\nuncloning the context before starting to remove the counters from it.\nThe perf_counter_init_task is a little trickier; we temporarily\ndisable context swapping for the parent (forking) task by setting its\nctx-\u003eparent_gen to the all-1s value after locking the context, if it\nis a cloned context, and restore the ctx-\u003eparent_gen value at the end\nif the context didn\u0027t get uncloned in the meantime.\n\nThis also moves the increment of the context generation count to be\nwithin the same critical section, protected by the context mutex, that\nadds the new counter to the context.  That way, taking the mutex is\nsufficient to ensure that both the counter list and the generation\ncount are stable.\n\n[ Impact: fix hangs, races with inherited and PID counters ]\n\nSigned-off-by: Paul Mackerras \u003cpaulus@samba.org\u003e\nAcked-by: Peter Zijlstra \u003ca.p.zijlstra@chello.nl\u003e\nLKML-Reference: \u003c18975.31580.520676.619896@drongo.ozlabs.ibm.com\u003e\nSigned-off-by: Ingo Molnar \u003cmingo@elte.hu\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "52e5a15321d80b1d19fb324c90d8a5a01be3927d",
      "old_mode": 33188,
      "old_path": "kernel/perf_counter.c",
      "new_id": "db843f812a607bd75e24058ca197255310140d29",
      "new_mode": 33188,
      "new_path": "kernel/perf_counter.c"
    }
  ]
}
