[PATCH v2 5/7] mmap_lock: add /proc/<pid>/mmap_lock_contention interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When this file is read, we print a human-readable listing of histogram
buckets, as well as the number of samples recorded in each bucket.

Signed-off-by: Axel Rasmussen <axelrasmussen@xxxxxxxxxx>
---
 fs/proc/base.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index a96377557db7..42d706474971 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -96,6 +96,8 @@
 #include <linux/posix-timers.h>
 #include <linux/time_namespace.h>
 #include <linux/resctrl.h>
+#include <linux/histogram.h>
+#include <linux/mm_types.h>
 #include <trace/events/oom.h>
 #include "internal.h"
 #include "fd.h"
@@ -3115,6 +3117,26 @@ static int proc_stack_depth(struct seq_file *m, struct pid_namespace *ns,
 }
 #endif /* CONFIG_STACKLEAK_METRICS */
 
+#ifdef CONFIG_MMAP_LOCK_HISTOGRAMS
+static int proc_pid_mmap_lock_contention_show(struct seq_file *m,
+					      struct pid_namespace *ns,
+					      struct pid *pid,
+					      struct task_struct *task)
+{
+	int rc;
+
+	if (unlikely(!task->mm->mmap_lock_contention))
+		return 0;
+
+	rc = histogram_print_buckets_rcu(
+		task->mm->mmap_lock_contention,
+		m->buf + m->count, m->size - m->count);
+	if (rc > 0)
+		m->count += rc;
+	return 0;
+}
+#endif /* CONFIG_MMAP_LOCK_HISTOGRAMS */
+
 /*
  * Thread groups
  */
@@ -3228,6 +3250,9 @@ static const struct pid_entry tgid_base_stuff[] = {
 #ifdef CONFIG_PROC_PID_ARCH_STATUS
 	ONE("arch_status", S_IRUGO, proc_pid_arch_status),
 #endif
+#ifdef CONFIG_MMAP_LOCK_HISTOGRAMS
+	ONE("mmap_lock_contention", S_IRUGO, proc_pid_mmap_lock_contention_show),
+#endif
 };
 
 static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx)
-- 
2.27.0.rc0.183.gde8f92d652-goog





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux