lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1477787923-61185-25-git-send-email-davidcc@google.com>
Date:   Sat, 29 Oct 2016 17:38:21 -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 24/46] perf/x86/intel/cmt: add perf_cgroup_arch_css_{online,offline}

Use newly introduced architecture specific hooks to update monr hierarchy
when a cgroup goes online/offline.

Add cmt_initialized_key and use it to avoid using the hooks when the
intel_cmt is not active.

Signed-off-by: David Carrillo-Cisneros <davidcc@...gle.com>
---
 arch/x86/events/intel/cmt.c       | 36 ++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/perf_event.h | 19 +++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/arch/x86/events/intel/cmt.c b/arch/x86/events/intel/cmt.c
index 5c64d94..7545deb 100644
--- a/arch/x86/events/intel/cmt.c
+++ b/arch/x86/events/intel/cmt.c
@@ -24,6 +24,7 @@ static struct lock_class_key	lock_keys[CMT_MAX_NR_PKGS];
 static DEFINE_MUTEX(cmt_mutex);
 /* List of monrs that are associated with an event. */
 static LIST_HEAD(cmt_event_monrs);
+DEFINE_STATIC_KEY_FALSE(cmt_initialized_key);
 
 static unsigned int cmt_l3_scale;	/* cmt hw units to bytes. */
 
@@ -1468,6 +1469,21 @@ static int __css_go_online(struct cgroup_subsys_state *css)
 	return 0;
 }
 
+int perf_cgroup_arch_css_online(struct cgroup_subsys_state *css)
+{
+	int err = 0;
+
+	if (static_branch_unlikely(&cmt_initialized_key)) {
+		mutex_lock(&cmt_mutex);
+		monr_hrchy_acquire_mutexes();
+		err = __css_go_online(css);
+		monr_hrchy_release_mutexes();
+		mutex_unlock(&cmt_mutex);
+	}
+
+	return err;
+}
+
 static void __css_go_offline(struct cgroup_subsys_state *css)
 {
 	struct monr *monr;
@@ -1487,6 +1503,17 @@ static void __css_go_offline(struct cgroup_subsys_state *css)
 	monr_destroy(monr);
 }
 
+void perf_cgroup_arch_css_offline(struct cgroup_subsys_state *css)
+{
+	if (static_branch_unlikely(&cmt_initialized_key)) {
+		mutex_lock(&cmt_mutex);
+		monr_hrchy_acquire_mutexes();
+		__css_go_offline(css);
+		monr_hrchy_release_mutexes();
+		mutex_unlock(&cmt_mutex);
+	}
+}
+
 #endif
 
 static void free_pkg_data(struct pkg_data *pkg_data)
@@ -1760,6 +1787,12 @@ static void cmt_dealloc(void)
 
 static void cmt_stop(void)
 {
+
+	static_branch_disable(&cmt_initialized_key);
+
+	/* make sure CMT is turned is off before start tearing it down. */
+	barrier();
+
 	cpuhp_remove_state(CPUHP_AP_PERF_X86_CMT_ONLINE);
 	cpuhp_remove_state(CPUHP_PERF_X86_CMT_PREP);
 
@@ -1841,6 +1874,9 @@ static int __init cmt_start(void)
 	if (err)
 		goto rm_online;
 #endif
+	/* Make sure everything is ready prior to turn on key. */
+	barrier();
+	static_branch_enable(&cmt_initialized_key);
 
 	return 0;
 
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index f353061..783bdbb 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -299,4 +299,23 @@ static inline void perf_check_microcode(void) { }
 
 #define arch_perf_out_copy_user copy_from_user_nmi
 
+
+/*
+ * Hooks for architecture specific features of perf_event cgroup.
+ * Currently used by Intel's CMT.
+ */
+#ifdef CONFIG_CGROUP_PERF
+#ifdef CONFIG_INTEL_RDT_M
+
+#define perf_cgroup_arch_css_online \
+	perf_cgroup_arch_css_online
+int perf_cgroup_arch_css_online(struct cgroup_subsys_state *css);
+
+#define perf_cgroup_arch_css_offline \
+	perf_cgroup_arch_css_offline
+void perf_cgroup_arch_css_offline(struct cgroup_subsys_state *css);
+
+#endif
+#endif
+
 #endif /* _ASM_X86_PERF_EVENT_H */
-- 
2.8.0.rc3.226.g39d4020

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ