From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753402AbcD2Et6 (ORCPT ); Fri, 29 Apr 2016 00:49:58 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:35711 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753052AbcD2Eqi (ORCPT ); Fri, 29 Apr 2016 00:46:38 -0400 From: David Carrillo-Cisneros To: Peter Zijlstra , Alexander Shishkin , Arnaldo Carvalho de Melo , Ingo Molnar Cc: Vikas Shivappa , Matt Fleming , Tony Luck , Stephane Eranian , Paul Turner , David Carrillo-Cisneros , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/32] perf/core: introduce PMU event flag PERF_CGROUP_NO_RECURSION Date: Thu, 28 Apr 2016 21:43:25 -0700 Message-Id: <1461905018-86355-20-git-send-email-davidcc@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1461905018-86355-1-git-send-email-davidcc@google.com> References: <1461905018-86355-1-git-send-email-davidcc@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some events, such as Intel's CQM llc_occupancy, need small deviations from the traditional behavior in the generic code in a way that depends on the event itself (and known by the PMU) and not in a field of perf_event_attrs. An example is the recursive scope for cgroups: The generic code handles cgroup hierarchy for a cgroup C by simultaneously adding to the PMU the events of all cgroups that are ancestors of C. This approach is incompatible with the CQM hw that only allows one RMID per virtual core at a time. CQM's PMU work-arounds this limitation by internally maintaining the hierarchical dependency between monitored cgroups and only requires that the generic code adds current cgroup's event to the PMU. The introduction of the flag PERF_CGROUP_NO_RECURSION allows the PMU to signal the generic code to avoid using recursive cgroup scope for llc_occupancy events, preventing an undesired overwrite of RMIDs. The PERF_CGROUP_NO_RECURSION, introduced in this patch, is the first flag of this type, more will be added in this patch series. To keep things tidy, this patch introduces the flag field pmu_event_flag, intended to contain all flags that: - Are not user-configurable event attributes (not suitable for perf_event_attributes). - Are known by the PMU during initialization of struct perf_event. - Signal something to the generic code. Reviewed-by: Stephane Eranian Signed-off-by: David Carrillo-Cisneros --- include/linux/perf_event.h | 10 ++++++++++ kernel/events/core.c | 3 +++ 2 files changed, 13 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 81e29c6..e4c58b0 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -594,9 +594,19 @@ struct perf_event { #endif struct list_head sb_list; + + /* Flags to generic code set by PMU. */ + int pmu_event_flags; + #endif /* CONFIG_PERF_EVENTS */ }; +/* + * Possible flags for mpu_event_flags. + */ +/* Do not enable cgroup events in descendant cgroups. */ +#define PERF_CGROUP_NO_RECURSION (1 << 0) + /** * struct perf_event_context - event context structure * diff --git a/kernel/events/core.c b/kernel/events/core.c index 2a868a6..33961ec 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -545,6 +545,9 @@ perf_cgroup_match(struct perf_event *event) if (!cpuctx->cgrp) return false; + if (event->pmu_event_flags & PERF_CGROUP_NO_RECURSION) + return cpuctx->cgrp->css.cgroup == event->cgrp->css.cgroup; + /* * Cgroup scoping is recursive. An event enabled for a cgroup is * also enabled for all its descendant cgroups. If @cpuctx's -- 2.8.0.rc3.226.g39d4020