Skip to contentSkip to conversation

mmap_lock: add a histogram structure to struct mm_struct

PATCH In review Axel Rasmussen 1 participant 1 message May 28, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 3/7 mmap_lock: add a histogram structure to struct mm_struct

This histogram will be used to measure lock acquisition latency, when the acquisition is contended. Cases where we acquire the lock immediately with no contention are recorded as "0" (to avoid incurring the cost of really computing the time, while retaining the ability to get an accurate total lock acquisition count).

---
 include/linux/mm_types.h | 11 +++++++++++
 mm/Kconfig               | 13 +++++++++++++
 2 files changed, 24 insertions(+)
include/linux/mm_types.h +11 -0
index d13b90399c16..efeb5db1959d 100644
@@ -376,6 +376,10 @@ struct core_state {
 	struct completion startup;
 };
 
+#ifdef CONFIG_MMAP_LOCK_HISTOGRAMS
+struct histogram_rcu;
+#endif
+
 struct kioctx_table;
 struct mm_struct {
 	struct {
@@ -437,6 +441,13 @@ struct mm_struct {
 					     * counters
 					     */
 		struct rw_semaphore mmap_lock;
+#ifdef CONFIG_MMAP_LOCK_HISTOGRAMS
+		/* Histogram of mmap_lock contended acquire delays. kmalloc'd
+		 * so we can use a forward declaration, to avoid circular
+		 * dependencies between headers.
+		 */
+		struct histogram_rcu *mmap_lock_contention;
+#endif
 
 		struct list_head mmlist; /* List of maybe swapped mm's.	These
 					  * are globally strung together off
mm/Kconfig +13 -0
index c1acc34c1c35..231862afc2ce 100644
@@ -817,6 +817,19 @@ config DEVICE_PRIVATE
 config FRAME_VECTOR
 	bool
 
+config MMAP_LOCK_HISTOGRAMS
+	bool "mmap_lock histograms"
+	select HISTOGRAM
+	default n
+
+	help
+	  Record and report latency histograms describing mmap_lock
+	  contention. Stats can be read from /proc/<pid>/mmap_lock_contention.
+	  True latency is only computed for *contended* acquires, to minimize
+	  overhead. Uncontended acquires are recorded as having "0" latency.
+
+	  If unsure, say "n".
+
 config ARCH_USES_HIGH_VMA_FLAGS
 	bool
 config ARCH_HAS_PKEYS
Signature · 1 line
2.27.0.rc0.183.gde8f92d652-goog