[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1477787923-61185-26-git-send-email-davidcc@google.com>
Date: Sat, 29 Oct 2016 17:38:22 -0700
From: David Carrillo-Cisneros <davidcc@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: "x86@...nel.org" <x86@...nel.org>, Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Andi Kleen <ak@...ux.intel.com>,
Kan Liang <kan.liang@...el.com>,
Peter Zijlstra <peterz@...radead.org>,
Vegard Nossum <vegard.nossum@...il.com>,
Marcelo Tosatti <mtosatti@...hat.com>,
Nilay Vaish <nilayvaish@...il.com>,
Borislav Petkov <bp@...e.de>,
Vikas Shivappa <vikas.shivappa@...ux.intel.com>,
Ravi V Shankar <ravi.v.shankar@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>,
Paul Turner <pjt@...gle.com>,
Stephane Eranian <eranian@...gle.com>,
David Carrillo-Cisneros <davidcc@...gle.com>
Subject: [PATCH v3 25/46] perf/x86/intel/cmt: add monr->flags and CMT_MONR_ZOMBIE
Add a new enumeration to store monr's internal state information.
This new monr->flags contrasts with monr->uflag that stores user
provided flags.
The first flags is CMT_MONR_ZOMBIE, used to signal that the monr is no
longer valid, yet, must be kept around until its released by its last
user. This is useful when a monr is attached to a cgroup that is destroyed
but there are still events that reference that cgroup.
Signed-off-by: David Carrillo-Cisneros <davidcc@...gle.com>
---
arch/x86/events/intel/cmt.c | 17 +++++++++++++++--
arch/x86/events/intel/cmt.h | 9 +++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/arch/x86/events/intel/cmt.c b/arch/x86/events/intel/cmt.c
index 7545deb..830ce29 100644
--- a/arch/x86/events/intel/cmt.c
+++ b/arch/x86/events/intel/cmt.c
@@ -423,7 +423,12 @@ static void monr_dealloc(struct monr *monr)
{
u16 p, nr_pkgs = topology_max_packages();
- if (WARN_ON_ONCE(monr->nr_has_user) ||
+ /*
+ * Only can dealloc monrs zombie monrs with all pmonrs in Off state
+ * and not attached to the monr hierarchy.
+ */
+ if (WARN_ON_ONCE(!(monr->flags & CMT_MONR_ZOMBIE)) ||
+ WARN_ON_ONCE(monr->nr_has_user) ||
WARN_ON_ONCE(monr->nr_nolazy_rmid) ||
WARN_ON_ONCE(monr->mon_cgrp) ||
WARN_ON_ONCE(monr->mon_events))
@@ -1178,12 +1183,20 @@ static int monr_hrchy_attach_event(struct perf_event *event)
static void monr_destroy(struct monr *monr)
{
+ if (monr->flags & CMT_MONR_ZOMBIE)
+ goto zombie;
+
#ifdef CONFIG_CGROUP_PERF
if (monr->mon_cgrp)
__css_stop_monitoring(&monr->mon_cgrp->css);
#endif
monr_hrchy_remove_leaf(monr);
- monr_dealloc(monr);
+
+ monr->flags = CMT_MONR_ZOMBIE;
+
+zombie:
+ if (!monr_has_user(monr))
+ monr_dealloc(monr);
}
/**
diff --git a/arch/x86/events/intel/cmt.h b/arch/x86/events/intel/cmt.h
index dc52641..1e40e6b 100644
--- a/arch/x86/events/intel/cmt.h
+++ b/arch/x86/events/intel/cmt.h
@@ -240,6 +240,13 @@ struct pkg_data {
};
/**
+ * enum monr_flags - internal monr's flags.
+ */
+enum monr_flags {
+ CMT_MONR_ZOMBIE = BIT(0), /* monr has been terminated. */
+};
+
+/**
* enum cmt_user_flags - user set flags for monr and pmonrs.
*/
enum cmt_user_flags {
@@ -259,6 +266,7 @@ enum cmt_user_flags {
* @parent: Parent in monr hierarchy.
* @children: List of children in monr hierarchy.
* @parent_entry: Entry in parent's children list.
+ * @flags: monr_flags.
* @nr_has_user: nr of CMT_UF_HAS_USER set in events in mon_events.
* @nr_nolazy_user: nr of CMT_UF_NOLAZY_RMID set in events in mon_events.
* @uflags: monr level cmt_user_flags, or'ed with pkg_uflags.
@@ -281,6 +289,7 @@ struct monr {
struct list_head children;
struct list_head parent_entry;
+ enum monr_flags flags;
int nr_has_user;
int nr_nolazy_rmid;
enum cmt_user_flags uflags;
--
2.8.0.rc3.226.g39d4020
Powered by blists - more mailing lists