From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757057AbcJ3AoA (ORCPT ); Sat, 29 Oct 2016 20:44:00 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:32911 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755837AbcJ3Ak3 (ORCPT ); Sat, 29 Oct 2016 20:40:29 -0400 From: David Carrillo-Cisneros To: linux-kernel@vger.kernel.org Cc: "x86@kernel.org" , Ingo Molnar , Thomas Gleixner , Andi Kleen , Kan Liang , Peter Zijlstra , Vegard Nossum , Marcelo Tosatti , Nilay Vaish , Borislav Petkov , Vikas Shivappa , Ravi V Shankar , Fenghua Yu , Paul Turner , Stephane Eranian , David Carrillo-Cisneros Subject: [PATCH v3 34/46] perf/core: introduce PERF_EV_CAP_CGROUP_NO_RECURSION Date: Sat, 29 Oct 2016 17:38:31 -0700 Message-Id: <1477787923-61185-35-git-send-email-davidcc@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1477787923-61185-1-git-send-email-davidcc@google.com> References: <1477787923-61185-1-git-send-email-davidcc@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The generic code handles cgroup hierarchy by adding to the PMU the events of all the ancestor cgroups of the cgroup to read. This approach is incompatible with the CMT hw that only allows one rmid per virtual core at a time. CMT's PMU work-arounds this limitation by internally maintaining the hierarchical dependency between monitored cgroups (the monr hierarchy). The flag introduced in this patch signals the generic code that this cgroup event do not need to add ancestor's event recursively. Signed-off-by: David Carrillo-Cisneros --- include/linux/perf_event.h | 5 +++++ kernel/events/core.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 72fe105..3b1d542 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -522,11 +522,16 @@ typedef void (*perf_overflow_handler_t)(struct perf_event *, * * PERF_EV_CAP_READ_ANY_PKG: An event readable from any CPU in any package, * even if inactive. + * + * PERF_EV_CAP_CGROUP_NO_RECURSION: A cgroup event that handles its own + * cgroup scoping. It does not need to be enabled for all of its descendants + * cgroups. */ #define PERF_EV_CAP_SOFTWARE BIT(0) #define PERF_EV_CAP_READ_ACTIVE_PKG BIT(1) #define PERF_EV_CAP_READ_ANY_CPU_PKG BIT(2) #define PERF_EV_CAP_READ_ANY_PKG BIT(3) +#define PERF_EV_CAP_CGROUP_NO_RECURSION BIT(4) #define SWEVENT_HLIST_BITS 8 #define SWEVENT_HLIST_SIZE (1 << SWEVENT_HLIST_BITS) diff --git a/kernel/events/core.c b/kernel/events/core.c index 77afd68..4f43c75 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -590,6 +590,9 @@ perf_cgroup_match(struct perf_event *event) if (!cpuctx->cgrp) return false; + if (event->event_caps & PERF_EV_CAP_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