aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/perf_counter.h
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2009-02-10 22:35:35 -0500
committerPaul Mackerras <paulus@samba.org>2009-02-10 23:06:59 -0500
commit0475f9ea8e2cc030298908949e0d5da9f2fc2cfe (patch)
treeeb2585d92e00ae4c7fc7e0654ffacde7e8a57e1c /include/linux/perf_counter.h
parentd278c48435625cb6b7edcf6a547620768b175709 (diff)
perf_counters: allow users to count user, kernel and/or hypervisor events
Impact: new perf_counter feature This extends the perf_counter_hw_event struct with bits that specify that events in user, kernel and/or hypervisor mode should not be counted (i.e. should be excluded), and adds code to program the PMU mode selection bits accordingly on x86 and powerpc. For software counters, we don't currently have the infrastructure to distinguish which mode an event occurs in, so we currently fail the counter initialization if the setting of the hw_event.exclude_* bits would require us to distinguish. Context switches and CPU migrations are currently considered to occur in kernel mode. On x86, this changes the previous policy that only root can count kernel events. Now non-root users can count kernel events or exclude them. Non-root users still can't use NMI events, though. On x86 we don't appear to have any way to control whether hypervisor events are counted or not, so hw_event.exclude_hv is ignored. On powerpc, the selection of whether to count events in user, kernel and/or hypervisor mode is PMU-wide, not per-counter, so this adds a check that the hw_event.exclude_* settings are the same as other events on the PMU. Counters being added to a group have to have the same settings as the other hardware counters in the group. Counters and groups can only be enabled in hw_perf_group_sched_in or power_perf_enable if they have the same settings as any other counters already on the PMU. If we are not running on a hypervisor, the exclude_hv setting is ignored (by forcing it to 0) since we can't ever get any hypervisor events. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/linux/perf_counter.h')
-rw-r--r--include/linux/perf_counter.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index f55381fbcac9..c83f51d6e359 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -83,14 +83,17 @@ struct perf_counter_hw_event {
83 u64 irq_period; 83 u64 irq_period;
84 u32 record_type; 84 u32 record_type;
85 85
86 u32 disabled : 1, /* off by default */ 86 u32 disabled : 1, /* off by default */
87 nmi : 1, /* NMI sampling */ 87 nmi : 1, /* NMI sampling */
88 raw : 1, /* raw event type */ 88 raw : 1, /* raw event type */
89 inherit : 1, /* children inherit it */ 89 inherit : 1, /* children inherit it */
90 pinned : 1, /* must always be on PMU */ 90 pinned : 1, /* must always be on PMU */
91 exclusive : 1, /* only counter on PMU */ 91 exclusive : 1, /* only group on PMU */
92 92 exclude_user : 1, /* don't count user */
93 __reserved_1 : 26; 93 exclude_kernel : 1, /* ditto kernel */
94 exclude_hv : 1, /* ditto hypervisor */
95
96 __reserved_1 : 23;
94 97
95 u64 __reserved_2; 98 u64 __reserved_2;
96}; 99};