linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 5/7] mmap_lock: add /proc/<pid>/mmap_lock_contention interface
@ 2020-05-28 23:53 Axel Rasmussen
  0 siblings, 0 replies; only message in thread
From: Axel Rasmussen @ 2020-05-28 23:53 UTC (permalink / raw)
  To: Andrew Morton, David Rientjes, Davidlohr Bueso, Ingo Molnar,
	Ingo Molnar, Jerome Glisse, Laurent Dufour, Liam R . Howlett,
	Matthew Wilcox, Michel Lespinasse, Peter Zijlstra,
	Vlastimil Babka, Will Deacon
  Cc: linux-fsdevel, linux-kernel, linux-mm, AKASHI Takahiro,
	Aleksa Sarai, Alexander Potapenko, Alexey Dobriyan, Al Viro,
	Andrei Vagin, Ard Biesheuvel, Brendan Higgins, chenqiwu,
	Christian Brauner, Christian Kellner, Corentin Labbe,
	Daniel Jordan, Dan Williams, David Gow, David S. Miller,
	Dmitry V. Levin, Eric W. Biederman, Eugene Syromiatnikov,
	Jamie Liu, Jason Gunthorpe, John Garry, John Hubbard,
	Jonathan Adams, Junaid Shahid, Kees Cook, Kirill A. Shutemov,
	Konstantin Khlebnikov, Krzysztof Kozlowski, Mark Rutland,
	Masahiro Yamada, Masami Hiramatsu, Mathieu Desnoyers,
	Michal Hocko, Mikhail Zaslonko, Petr Mladek, Ralph Campbell,
	Randy Dunlap, Roman Gushchin, Shakeel Butt, Steven Rostedt,
	Tal Gilboa, Thomas Gleixner, Uwe Kleine-König,
	Vincenzo Frascino, Yang Shi, Yu Zhao, Axel Rasmussen

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@google.com>
---
 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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-28 23:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 23:53 [PATCH v2 5/7] mmap_lock: add /proc/<pid>/mmap_lock_contention interface Axel Rasmussen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).