Index: /usr/src/sys/fs/tmpfs/tmpfs_subr.c =================================================================== --- /usr/src/sys/fs/tmpfs/tmpfs_subr.c (revision 324624) +++ /usr/src/sys/fs/tmpfs/tmpfs_subr.c (working copy) @@ -65,6 +65,7 @@ SYSCTL_NODE(_vfs, OID_AUTO, tmpfs, CTLFLAG_RW, 0, "tmpfs file system"); static long tmpfs_pages_reserved = TMPFS_PAGES_MINRESERVED; +static int tmpfs_inactive_percent = 0; static int sysctl_mem_reserved(SYSCTL_HANDLER_ARGS) @@ -87,9 +88,30 @@ return (0); } +static int +sysctl_inactive_percent(SYSCTL_HANDLER_ARGS) +{ + int error; + int percent; + + percent = *(int *)arg1; + error = sysctl_handle_int(oidp, &percent, 0, req); + if (error || !req->newptr) + return (error); + if (percent < 0) + percent = 0; + if (percent > 100) + percent = 100; + *(int *)arg1 = percent; + return (0); +} + SYSCTL_PROC(_vfs_tmpfs, OID_AUTO, memory_reserved, CTLTYPE_LONG|CTLFLAG_RW, &tmpfs_pages_reserved, 0, sysctl_mem_reserved, "L", "Amount of available memory and swap below which tmpfs growth stops"); +SYSCTL_PROC(_vfs_tmpfs, OID_AUTO, inactive_percent, CTLTYPE_INT|CTLFLAG_RW, + &tmpfs_inactive_percent, 0, sysctl_inactive_percent, "I", + "Percentage of inactive memory to add to free space"); static __inline int tmpfs_dirtree_cmp(struct tmpfs_dirent *a, struct tmpfs_dirent *b); @@ -100,7 +122,9 @@ { vm_ooffset_t avail; - avail = swap_pager_avail + vm_cnt.v_free_count - tmpfs_pages_reserved; + avail = swap_pager_avail + vm_cnt.v_free_count + + (vm_cnt.v_inactive_count / 100 * tmpfs_inactive_percent) - + tmpfs_pages_reserved; if (__predict_false(avail < 0)) avail = 0; return (avail);