diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-12-12 07:49:45 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-14 14:30:49 -0500 |
commit | 9b51f66dcb09ac5eb6bc68fc111d5c7a1e0131d6 (patch) | |
tree | f7b3482ae284c214119efe309e356fb84de126bb /kernel/exit.c | |
parent | ee06094f8279e1312fc0a31591320cc7b6f0ab1e (diff) |
perfcounters: implement "counter inheritance"
Impact: implement new performance feature
Counter inheritance can be used to run performance counters in a workload,
transparently - and pipe back the counter results to the parent counter.
Inheritance for performance counters works the following way: when creating
a counter it can be marked with the .inherit=1 flag. Such counters are then
'inherited' by all child tasks (be they fork()-ed or clone()-ed). These
counters get inherited through exec() boundaries as well (except through
setuid boundaries).
The counter values get added back to the parent counter(s) when the child
task(s) exit - much like stime/utime statistics are gathered. So inherited
counters are ideal to gather summary statistics about an application's
behavior via shell commands, without having to modify that application.
The timec.c command utilizes counter inheritance:
http://redhat.com/~mingo/perfcounters/timec.c
Sample output:
$ ./timec -e 1 -e 3 -e 5 ls -lR /usr/include/ >/dev/null
Performance counter stats for 'ls':
163516953 instructions
2295 cache-misses
2855182 branch-misses
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/exit.c')
-rw-r--r-- | kernel/exit.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 2d8be7ebb0f7..d336c90a5f13 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -1093,11 +1093,12 @@ NORET_TYPE void do_exit(long code) | |||
1093 | mpol_put(tsk->mempolicy); | 1093 | mpol_put(tsk->mempolicy); |
1094 | tsk->mempolicy = NULL; | 1094 | tsk->mempolicy = NULL; |
1095 | #endif | 1095 | #endif |
1096 | #ifdef CONFIG_FUTEX | ||
1097 | /* | 1096 | /* |
1098 | * This must happen late, after the PID is not | 1097 | * These must happen late, after the PID is not |
1099 | * hashed anymore: | 1098 | * hashed anymore, but still at a point that may sleep: |
1100 | */ | 1099 | */ |
1100 | perf_counter_exit_task(tsk); | ||
1101 | #ifdef CONFIG_FUTEX | ||
1101 | if (unlikely(!list_empty(&tsk->pi_state_list))) | 1102 | if (unlikely(!list_empty(&tsk->pi_state_list))) |
1102 | exit_pi_state_list(tsk); | 1103 | exit_pi_state_list(tsk); |
1103 | if (unlikely(current->pi_state_cache)) | 1104 | if (unlikely(current->pi_state_cache)) |