[PATCH v3 43/46] perf/x86/intel/cmt: add CMT_UF_NOSTEAL_RMID flag
From: David Carrillo-Cisneros
Date: Sat Oct 29 2016 - 20:41:10 EST
Allow user to specify that rmids used by a cgroup/event cannot be stolen.
The pmonrs that are marked with CMT_UF_NOSTEAL_RMID will never lose a valid
rmid once they have receive one.
Signed-off-by: David Carrillo-Cisneros <davidcc@xxxxxxxxxx>
---
arch/x86/events/intel/cmt.c | 10 +++++++++-
arch/x86/events/intel/cmt.h | 5 ++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/arch/x86/events/intel/cmt.c b/arch/x86/events/intel/cmt.c
index e677511..8cbcbc6 100644
--- a/arch/x86/events/intel/cmt.c
+++ b/arch/x86/events/intel/cmt.c
@@ -41,7 +41,7 @@ static struct monr *monr_hrchy_root;
/* Flags for root monr and all its pmonrs while being monitored. */
static enum cmt_user_flags root_monr_uflags =
- CMT_UF_HAS_USER | CMT_UF_NOLAZY_RMID;
+ CMT_UF_HAS_USER | CMT_UF_NOSTEAL_RMID | CMT_UF_NOLAZY_RMID;
/* Auxiliar flags */
static enum cmt_user_flags *pkg_uflags_zeroes;
@@ -499,6 +499,7 @@ static void monr_dealloc(struct monr *monr)
*/
if (WARN_ON_ONCE(!(monr->flags & CMT_MONR_ZOMBIE)) ||
WARN_ON_ONCE(monr->nr_has_user) ||
+ WARN_ON_ONCE(monr->nr_nosteal_rmid) ||
WARN_ON_ONCE(monr->nr_nolazy_rmid) ||
WARN_ON_ONCE(monr->mon_cgrp) ||
WARN_ON_ONCE(monr->mon_events))
@@ -743,10 +744,13 @@ static bool monr_account_uflags(struct monr *monr,
if (uflags & CMT_UF_HAS_USER)
monr->nr_has_user += account ? 1 : -1;
+ if (uflags & CMT_UF_NOSTEAL_RMID)
+ monr->nr_nosteal_rmid += account ? 1 : -1;
if (uflags & CMT_UF_NOLAZY_RMID)
monr->nr_nolazy_rmid += account ? 1 : -1;
monr->uflags = (monr->nr_has_user ? CMT_UF_HAS_USER : 0) |
+ (monr->nr_nosteal_rmid ? CMT_UF_NOSTEAL_RMID : 0) |
(monr->nr_nolazy_rmid ? CMT_UF_NOLAZY_RMID : 0);
return old_flags != monr->uflags;
@@ -1400,6 +1404,10 @@ static bool can_steal_rmid(struct pmonr *pmonr)
u64 last_all_active, next_steal_time, last_pmonr_active;
last_all_active = atomic64_read(&monr->last_rmid_recoup);
+
+ if (pmonr_uflags(pmonr) & CMT_UF_NOSTEAL_RMID)
+ return false;
+
/*
* Can steal if no pmonr has been stolen or all not Unused have been
* in Active state for long enough.
diff --git a/arch/x86/events/intel/cmt.h b/arch/x86/events/intel/cmt.h
index 872cce0..c377076 100644
--- a/arch/x86/events/intel/cmt.h
+++ b/arch/x86/events/intel/cmt.h
@@ -290,7 +290,8 @@ enum cmt_user_flags {
/* if no has_user other flags are meaningless. */
CMT_UF_HAS_USER = BIT(0), /* has cgroup or event users */
CMT_UF_NOLAZY_RMID = BIT(1), /* try to obtain rmid on creation */
- CMT_UF_MAX = BIT(2) - 1,
+ CMT_UF_NOSTEAL_RMID = BIT(2), /* do not steal this rmid */
+ CMT_UF_MAX = BIT(3) - 1,
CMT_UF_ERROR = CMT_UF_MAX + 1,
};
@@ -309,6 +310,7 @@ enum cmt_user_flags {
* monr is monitoring in all required packages.
* @flags: monr_flags.
* @nr_has_user: nr of CMT_UF_HAS_USER set in events in mon_events.
+ * @nr_nosteal_user: nr of CMT_UF_NOSTEAL_RMID 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.
* @pkg_uflags: package level cmt_user_flags, each entry is used as
@@ -335,6 +337,7 @@ struct monr {
enum monr_flags flags;
int nr_has_user;
+ int nr_nosteal_rmid;
int nr_nolazy_rmid;
enum cmt_user_flags uflags;
enum cmt_user_flags pkg_uflags[];
--
2.8.0.rc3.226.g39d4020