path: root/include
diff options
authorPaul Mackerras <>2009-06-01 17:48:12 +1000
committerIngo Molnar <>2009-06-01 10:04:05 +0200
commit25346b93ca079080c9cb23331db5c4f6404e8530 (patch)
treea444ca96e0c7e32d6c573e680d9365a808f48bfb /include
parent23db9f430be9325a861c7762c1ffadad9ca528a8 (diff)
perf_counter: Provide functions for locking and pinning the context for a task
This abstracts out the code for locking the context associated with a task. Because the context might get transferred from one task to another concurrently, we have to check after locking the context that it is still the right context for the task and retry if not. This was open-coded in find_get_context() and perf_counter_init_task(). This adds a further function for pinning the context for a task, i.e. marking it so it can't be transferred to another task. This adds a 'pin_count' field to struct perf_counter_context to indicate that a context is pinned, instead of the previous method of setting the parent_gen count to all 1s. Pinning the context with a pin_count is easier to undo and doesn't require saving the parent_gen value. This also adds a perf_unpin_context() to undo the effect of perf_pin_task_context() and changes perf_counter_init_task to use it. Signed-off-by: Paul Mackerras <> Cc: Peter Zijlstra <> Cc: Mike Galbraith <> Cc: Paul Mackerras <> Cc: Corey Ashford <> Cc: Marcelo Tosatti <> Cc: Arnaldo Carvalho de Melo <> Cc: John Kacur <> LKML-Reference: <> Signed-off-by: Ingo Molnar <>
Diffstat (limited to 'include')
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index 519a41bba249..81ec79c9f193 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -543,6 +543,7 @@ struct perf_counter_context {
struct perf_counter_context *parent_ctx;
u64 parent_gen;
u64 generation;
+ int pin_count;
struct rcu_head rcu_head;