[PATCH v2 23/32] perf/x86/intel/cqm: use PERF_INACTIVE_*_READ_* flags in CQM

From: David Carrillo-Cisneros
Date: Wed May 11 2016 - 19:06:07 EST


Use newly added pmu_event flags to:
- Allow thread events to be read from any CPU even if not in
ACTIVE state. Since inter-package values are polled, a thread's
occupancy is always:

local occupancy (read from hw) + remote occupancy (polled values)

- Allow cpu/cgroup events to be read from any CPU in the package where
they run. This potentially saves IPIs when the read function runs in the
same package but in a distinct CPU than the event.

Since reading will always return a new value and inherit_stats is not
supported (due to all children events sharing the same RMID), there is no
need to read during sched_out of an event.

Reviewed-by: Stephane Eranian <eranian@xxxxxxxxxx>
Signed-off-by: David Carrillo-Cisneros <davidcc@xxxxxxxxxx>
---
arch/x86/events/intel/cqm.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
index 12f563d..9038112 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -2689,6 +2689,16 @@ static int intel_cqm_event_init(struct perf_event *event)
*/
event->pmu_event_flags |= PERF_CGROUP_NO_RECURSION;

+ /* Events in CQM PMU are per-package and can be read even when
+ * the cpu is not running the event.
+ */
+ if (event->cpu < 0) {
+ WARN_ON_ONCE(!(event->attach_state & PERF_ATTACH_TASK));
+ event->pmu_event_flags |= PERF_INACTIVE_EV_READ_ANY_CPU;
+ } else {
+ event->pmu_event_flags |= PERF_INACTIVE_CPU_READ_PKG;
+ }
+
mutex_lock(&cqm_mutex);


--
2.8.0.rc3.226.g39d4020