diff options
author | Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> | 2015-09-03 23:07:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-09-13 05:27:25 -0400 |
commit | fbbe07011581990ef74dfac06dc8511b1a14badb (patch) | |
tree | 8b026523a68ff8d98107a393d0551c9bfbf00812 /kernel/events | |
parent | 845583767c306dac0290aab908c18b01772ea4b4 (diff) |
perf/core: Add a 'flags' parameter to the PMU transactional interfaces
Currently, the PMU interface allows reading only one counter at a time.
But some PMUs like the 24x7 counters in Power, support reading several
counters at once. To leveage this functionality, extend the transaction
interface to support a "transaction type".
The first type, PERF_PMU_TXN_ADD, refers to the existing transactions,
i.e. used to _schedule_ all the events on the PMU as a group. A second
transaction type, PERF_PMU_TXN_READ, will be used in a follow-on patch,
by the 24x7 counters to read several counters at once.
Extend the transaction interfaces to the PMU to accept a 'txn_flags'
parameter and use this parameter to ignore any transactions that are
not of type PERF_PMU_TXN_ADD.
Thanks to Peter Zijlstra for his input.
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
[peterz: s390 compile fix]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/1441336073-22750-3-git-send-email-sukadev@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 76e64be9bfb5..c80cee82959f 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -1914,7 +1914,7 @@ group_sched_in(struct perf_event *group_event, | |||
1914 | if (group_event->state == PERF_EVENT_STATE_OFF) | 1914 | if (group_event->state == PERF_EVENT_STATE_OFF) |
1915 | return 0; | 1915 | return 0; |
1916 | 1916 | ||
1917 | pmu->start_txn(pmu); | 1917 | pmu->start_txn(pmu, PERF_PMU_TXN_ADD); |
1918 | 1918 | ||
1919 | if (event_sched_in(group_event, cpuctx, ctx)) { | 1919 | if (event_sched_in(group_event, cpuctx, ctx)) { |
1920 | pmu->cancel_txn(pmu); | 1920 | pmu->cancel_txn(pmu); |
@@ -7267,24 +7267,49 @@ static void perf_pmu_nop_void(struct pmu *pmu) | |||
7267 | { | 7267 | { |
7268 | } | 7268 | } |
7269 | 7269 | ||
7270 | static void perf_pmu_nop_txn(struct pmu *pmu, unsigned int flags) | ||
7271 | { | ||
7272 | } | ||
7273 | |||
7270 | static int perf_pmu_nop_int(struct pmu *pmu) | 7274 | static int perf_pmu_nop_int(struct pmu *pmu) |
7271 | { | 7275 | { |
7272 | return 0; | 7276 | return 0; |
7273 | } | 7277 | } |
7274 | 7278 | ||
7275 | static void perf_pmu_start_txn(struct pmu *pmu) | 7279 | DEFINE_PER_CPU(unsigned int, nop_txn_flags); |
7280 | |||
7281 | static void perf_pmu_start_txn(struct pmu *pmu, unsigned int flags) | ||
7276 | { | 7282 | { |
7283 | __this_cpu_write(nop_txn_flags, flags); | ||
7284 | |||
7285 | if (flags & ~PERF_PMU_TXN_ADD) | ||
7286 | return; | ||
7287 | |||
7277 | perf_pmu_disable(pmu); | 7288 | perf_pmu_disable(pmu); |
7278 | } | 7289 | } |
7279 | 7290 | ||
7280 | static int perf_pmu_commit_txn(struct pmu *pmu) | 7291 | static int perf_pmu_commit_txn(struct pmu *pmu) |
7281 | { | 7292 | { |
7293 | unsigned int flags = __this_cpu_read(nop_txn_flags); | ||
7294 | |||
7295 | __this_cpu_write(nop_txn_flags, 0); | ||
7296 | |||
7297 | if (flags & ~PERF_PMU_TXN_ADD) | ||
7298 | return 0; | ||
7299 | |||
7282 | perf_pmu_enable(pmu); | 7300 | perf_pmu_enable(pmu); |
7283 | return 0; | 7301 | return 0; |
7284 | } | 7302 | } |
7285 | 7303 | ||
7286 | static void perf_pmu_cancel_txn(struct pmu *pmu) | 7304 | static void perf_pmu_cancel_txn(struct pmu *pmu) |
7287 | { | 7305 | { |
7306 | unsigned int flags = __this_cpu_read(nop_txn_flags); | ||
7307 | |||
7308 | __this_cpu_write(nop_txn_flags, 0); | ||
7309 | |||
7310 | if (flags & ~PERF_PMU_TXN_ADD) | ||
7311 | return; | ||
7312 | |||
7288 | perf_pmu_enable(pmu); | 7313 | perf_pmu_enable(pmu); |
7289 | } | 7314 | } |
7290 | 7315 | ||
@@ -7523,7 +7548,7 @@ got_cpu_context: | |||
7523 | pmu->commit_txn = perf_pmu_commit_txn; | 7548 | pmu->commit_txn = perf_pmu_commit_txn; |
7524 | pmu->cancel_txn = perf_pmu_cancel_txn; | 7549 | pmu->cancel_txn = perf_pmu_cancel_txn; |
7525 | } else { | 7550 | } else { |
7526 | pmu->start_txn = perf_pmu_nop_void; | 7551 | pmu->start_txn = perf_pmu_nop_txn; |
7527 | pmu->commit_txn = perf_pmu_nop_int; | 7552 | pmu->commit_txn = perf_pmu_nop_int; |
7528 | pmu->cancel_txn = perf_pmu_nop_void; | 7553 | pmu->cancel_txn = perf_pmu_nop_void; |
7529 | } | 7554 | } |