aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2015-01-23 13:45:40 -0500
committerIngo Molnar <mingo@kernel.org>2015-02-25 07:53:28 -0500
commit39bed6cbb842d8edf5a26b01122b391d36775b5e (patch)
tree397b0b53990d0dde3f7cea5488f0fc2964294f3e /include
parent8a26ce4e544659256349551283414df504889a59 (diff)
perf: Make perf_cgroup_from_task() global
Move perf_cgroup_from_task() from kernel/events/ to include/linux/ along with the necessary struct definitions, so that it can be used by the PMU code. When the upcoming Intel Cache Monitoring PMU driver assigns monitoring IDs to perf events, it needs to be able to check whether any two monitoring events overlap (say, a cgroup and task event), which means we need to be able to lookup the cgroup associated with a task (if any). Signed-off-by: Matt Fleming <matt.fleming@intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kanaka Juvva <kanaka.d.juvva@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Vikas Shivappa <vikas.shivappa@linux.intel.com> Link: http://lkml.kernel.org/r/1422038748-21397-2-git-send-email-matt@codeblueprint.co.uk Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/perf_event.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 724d3720c9b1..cae4a9481777 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -53,6 +53,7 @@ struct perf_guest_info_callbacks {
53#include <linux/sysfs.h> 53#include <linux/sysfs.h>
54#include <linux/perf_regs.h> 54#include <linux/perf_regs.h>
55#include <linux/workqueue.h> 55#include <linux/workqueue.h>
56#include <linux/cgroup.h>
56#include <asm/local.h> 57#include <asm/local.h>
57 58
58struct perf_callchain_entry { 59struct perf_callchain_entry {
@@ -547,6 +548,35 @@ struct perf_output_handle {
547 int page; 548 int page;
548}; 549};
549 550
551#ifdef CONFIG_CGROUP_PERF
552
553/*
554 * perf_cgroup_info keeps track of time_enabled for a cgroup.
555 * This is a per-cpu dynamically allocated data structure.
556 */
557struct perf_cgroup_info {
558 u64 time;
559 u64 timestamp;
560};
561
562struct perf_cgroup {
563 struct cgroup_subsys_state css;
564 struct perf_cgroup_info __percpu *info;
565};
566
567/*
568 * Must ensure cgroup is pinned (css_get) before calling
569 * this function. In other words, we cannot call this function
570 * if there is no cgroup event for the current CPU context.
571 */
572static inline struct perf_cgroup *
573perf_cgroup_from_task(struct task_struct *task)
574{
575 return container_of(task_css(task, perf_event_cgrp_id),
576 struct perf_cgroup, css);
577}
578#endif /* CONFIG_CGROUP_PERF */
579
550#ifdef CONFIG_PERF_EVENTS 580#ifdef CONFIG_PERF_EVENTS
551 581
552extern int perf_pmu_register(struct pmu *pmu, const char *name, int type); 582extern int perf_pmu_register(struct pmu *pmu, const char *name, int type);