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-13-git-send-email-davidcc@google.com>
Date:   Sat, 29 Oct 2016 17:38:09 -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 12/46] perf/x86/intel/cmt: add per-package rmid pools

A Resource Monitoring ID (RMID) is a hardware ID used to track cache
occupancy and memory bandwidth. The rmids are a per-package resource
and only one can be programmed at a time per logical CPU.

This patch series creates per-package rmids pools and (default)
lazy allocation of rmids (only reserve when a thread runs in a package)
to potentially allow more simultaneous rmid users than the system-wide
approach of the previous CQM/CMT driver.

Signed-off-by: David Carrillo-Cisneros <davidcc@...gle.com>
---
 arch/x86/events/intel/cmt.c |  5 +++++
 arch/x86/events/intel/cmt.h | 24 +++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/cmt.c b/arch/x86/events/intel/cmt.c
index 07560e5..5799816 100644
--- a/arch/x86/events/intel/cmt.c
+++ b/arch/x86/events/intel/cmt.c
@@ -725,6 +725,11 @@ static struct pkg_data *alloc_pkg_data(int cpu)
 		return ERR_PTR(-ENOMEM);
 
 	pkgd->max_rmid = c->x86_cache_max_rmid;
+	if (pkgd->max_rmid >= CMT_MAX_NR_RMIDS) {
+		pr_err("CPU Package %d supports %d RMIDs. Using %d only.\n",
+		       pkgid, pkgd->max_rmid, CMT_MAX_NR_RMIDS - 1);
+		pkgd->max_rmid = CMT_MAX_NR_RMIDS - 1;
+	}
 
 	mutex_init(&pkgd->mutex);
 	raw_spin_lock_init(&pkgd->lock);
diff --git a/arch/x86/events/intel/cmt.h b/arch/x86/events/intel/cmt.h
index 66b078a..6211392 100644
--- a/arch/x86/events/intel/cmt.h
+++ b/arch/x86/events/intel/cmt.h
@@ -3,6 +3,11 @@
  * (formerly Intel Cache QoS Monitoring, CQM)
  *
  *
+ * A Resource Monitoring ID (RMID) is a hardware ID used in Intel RDT to
+ * monitor cache and memory events such as LLC Occupancy and Memory
+ * Bandwidth. Changes in such metrics that are caused by a CPU are
+ * counted towards the rmid active in that CPU at the time.
+ *
  * A "Monitored Resource" (monr) is the entity monitored by CMT and MBM.
  * In order to monitor a cgroups and/or thread, it must be associated to
  * a monr. A monr is active in a CPU when a thread that is associated to
@@ -28,7 +33,8 @@
  * cgroup or process.
  *
  * Each monr has a package monr (pmonr) for each package with at least one
- * online cpu. The pmonr handles the CMT and MBM monitoring within its package.
+ * online cpu. The pmonr handles the CMT and MBM monitoring within its package
+ * by managing the rmid to write into each CPU that runs a monitored thread.
  *
  *
  * Locking
@@ -55,9 +61,22 @@ struct pmonr {
 	struct pkg_data				*pkgd;
 };
 
+/*
+ * Compile constant required for bitmap macros.
+ * Broadwell EP has 2 rmids per logical core, use twice as many as upper bound.
+ * 128 is a reasonable upper bound for logical cores per package for the
+ * foreseeable future. Adjust as CPUs grow.
+ */
+#define CMT_MAX_NR_RMIDS	(2 * 2 * 128)
+#define CMT_MAX_NR_RMIDS_BYTES	DIV_ROUND_UP(CMT_MAX_NR_RMIDS, BITS_PER_BYTE)
+#define CMT_MAX_NR_RMIDS_LONGS	BITS_TO_LONGS(CMT_MAX_NR_RMIDS)
+
 /**
  * struct pkg_data - Per-package CMT data.
  *
+ * @free_rmids:			Pool of free rmids.
+ * @dirty_rmids:		Pool of "dirty" rmids that are not referenced
+ *				by a pmonr.
  * @mutex:			Hold when modifying this pkg_data.
  * @lock:			Hold to protect pmonrs in this pkg_data.
  * @work_cpu:			CPU to run rotation and other batch jobs.
@@ -67,6 +86,9 @@ struct pmonr {
  * @pkgid:			The logical package id for this pkgd.
  */
 struct pkg_data {
+	unsigned long		free_rmids[CMT_MAX_NR_RMIDS_LONGS];
+	unsigned long		dirty_rmids[CMT_MAX_NR_RMIDS_LONGS];
+
 	struct mutex		mutex;
 	raw_spinlock_t		lock;
 
-- 
2.8.0.rc3.226.g39d4020

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ