git: b3c809b96f77 - stable/13 - linprocfs: Add /proc/vm/max_map_count

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Fri, 17 Jun 2022 19:41:35 UTC
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=b3c809b96f778dad3c1b385d2f772c0944b8b47b

commit b3c809b96f778dad3c1b385d2f772c0944b8b47b
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-05-31 08:42:06 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:35:41 +0000

    linprocfs: Add /proc/vm/max_map_count
    
    On Linux this limits the number of maps per mm struct.
    We don't limit mappings, return a suitable large value.
    
    Reviewed by:            emaste
    Differential revision:  https://reviews.freebsd.org/D35351
    MFC after:              2 weeks
    
    (cherry picked from commit 7e2a451119373b7d3f2b3fd062d4ccb099dde022)
---
 sys/compat/linprocfs/linprocfs.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index e1cc3289ce99..6cf25350d9e8 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -1978,6 +1978,21 @@ linprocfs_do_oom_score_adj(PFS_FILL_ARGS)
 	return (0);
 }
 
+/*
+ * Filler function for proc/sys/vm/max_map_count
+ *
+ * Maximum number of active map areas, on Linux this limits the number
+ * of vmaps per mm struct. We don't limit mappings, return a suitable
+ * large value.
+ */
+static int
+linprocfs_domax_map_cnt(PFS_FILL_ARGS)
+{
+
+	sbuf_printf(sb, "%d\n", INT32_MAX);
+	return (0);
+}
+
 /*
  * Constructor
  */
@@ -2122,6 +2137,8 @@ linprocfs_init(PFS_INIT_ARGS)
 	dir = pfs_create_dir(sys, "vm", NULL, NULL, NULL, 0);
 	pfs_create_file(dir, "min_free_kbytes", &linprocfs_dominfree,
 	    NULL, NULL, NULL, PFS_RD);
+	pfs_create_file(dir, "max_map_count", &linprocfs_domax_map_cnt,
+	    NULL, NULL, NULL, PFS_RD);
 
 	return (0);
 }