]> git.baikalelectronics.ru Git - kernel.git/commit
perf/x86: Add helper to obtain performance counter index
authorReinette Chatre <reinette.chatre@intel.com>
Wed, 19 Sep 2018 17:29:07 +0000 (10:29 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 28 Sep 2018 20:48:26 +0000 (22:48 +0200)
commit78510db1502b41b9180c70df39e516f766145809
tree204d142a2c4d61f45ea645f450f2e6ca67297a6a
parenta9a90e49ebd7719c59f5c0a107e4eac370ccb7c4
perf/x86: Add helper to obtain performance counter index

perf_event_read_local() is the safest way to obtain measurements
associated with performance events. In some cases the overhead
introduced by perf_event_read_local() affects the measurements and the
use of rdpmcl() is needed. rdpmcl() requires the index
of the performance counter used so a helper is introduced to determine
the index used by a provided performance event.

The index used by a performance event may change when interrupts are
enabled. A check is added to ensure that the index is only accessed
with interrupts disabled. Even with this check the use of this counter
needs to be done with care to ensure it is queried and used within the
same disabled interrupts section.

This change introduces a new checkpatch warning:
CHECK: extern prototypes should be avoided in .h files
+extern int x86_perf_rdpmc_index(struct perf_event *event);

This warning was discussed and designated as a false positive in
http://lkml.kernel.org/r/20180919091759.GZ24124@hirez.programming.kicks-ass.net

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: fenghua.yu@intel.com
Cc: tony.luck@intel.com
Cc: acme@kernel.org
Cc: gavin.hindman@intel.com
Cc: jithu.joseph@intel.com
Cc: dave.hansen@intel.com
Cc: hpa@zytor.com
Link: https://lkml.kernel.org/r/b277ffa78a51254f5414f7b1bc1923826874566e.1537377064.git.reinette.chatre@intel.com
arch/x86/events/core.c
arch/x86/include/asm/perf_event.h