From 37f8f0ac3b4c3cda0bc03717521fd5ce30d23c36 Mon Sep 17 00:00:00 2001 From: chuck Date: Fri, 15 Jun 2018 15:22:27 +0000 Subject: [PATCH] Add linprocfs support for min_free_kbytes This adds linprocfs support for proc/sys/vm/min_free_kbytes which the free program requires for correct operation. The approach mirrors the approach used in illumos. Reviewed by: imp (mentor), emaste Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15563 --- sys/compat/linprocfs/linprocfs.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index d0551e9cfc84..b4cdea0298a0 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -1302,6 +1302,21 @@ linprocfs_dosem(PFS_FILL_ARGS) return (0); } +/* + * Filler function for proc/sys/vm/min_free_kbytes + * + * This mirrors the approach in illumos to return zero for reads. Effectively, + * it says, no memory is kept in reserve for "atomic allocations". This class + * of allocation can be used at times when a thread cannot be suspended. + */ +static int +linprocfs_dominfree(PFS_FILL_ARGS) +{ + + sbuf_printf(sb, "%d\n", 0); + return (0); +} + /* * Filler function for proc/scsi/device_info */ @@ -1562,6 +1577,7 @@ linprocfs_init(PFS_INIT_ARGS) { struct pfs_node *root; struct pfs_node *dir; + struct pfs_node *sys; root = pi->pi_root; @@ -1643,9 +1659,9 @@ linprocfs_init(PFS_INIT_ARGS) NULL, NULL, NULL, PFS_RD); /* /proc/sys/... */ - dir = pfs_create_dir(root, "sys", NULL, NULL, NULL, 0); + sys = pfs_create_dir(root, "sys", NULL, NULL, NULL, 0); /* /proc/sys/kernel/... */ - dir = pfs_create_dir(dir, "kernel", NULL, NULL, NULL, 0); + dir = pfs_create_dir(sys, "kernel", NULL, NULL, NULL, 0); pfs_create_file(dir, "osrelease", &linprocfs_doosrelease, NULL, NULL, NULL, PFS_RD); pfs_create_file(dir, "ostype", &linprocfs_doostype, @@ -1664,6 +1680,11 @@ linprocfs_init(PFS_INIT_ARGS) pfs_create_file(dir, "uuid", &linprocfs_douuid, NULL, NULL, NULL, PFS_RD); + /* /proc/sys/vm/.... */ + dir = pfs_create_dir(sys, "vm", NULL, NULL, NULL, 0); + pfs_create_file(dir, "min_free_kbytes", &linprocfs_dominfree, + NULL, NULL, NULL, PFS_RD); + return (0); }