View | Details | Raw Unified | Return to bug 223015 | Differences between
and this patch

Collapse All | Expand All

(-)/usr/src/sys/fs/tmpfs/tmpfs_subr.c (-1 / +25 lines)
Lines 65-70 Link Here
65
SYSCTL_NODE(_vfs, OID_AUTO, tmpfs, CTLFLAG_RW, 0, "tmpfs file system");
65
SYSCTL_NODE(_vfs, OID_AUTO, tmpfs, CTLFLAG_RW, 0, "tmpfs file system");
66
66
67
static long tmpfs_pages_reserved = TMPFS_PAGES_MINRESERVED;
67
static long tmpfs_pages_reserved = TMPFS_PAGES_MINRESERVED;
68
static int tmpfs_inactive_percent = 0;
68
69
69
static int
70
static int
70
sysctl_mem_reserved(SYSCTL_HANDLER_ARGS)
71
sysctl_mem_reserved(SYSCTL_HANDLER_ARGS)
Lines 87-95 Link Here
87
	return (0);
88
	return (0);
88
}
89
}
89
90
91
static int
92
sysctl_inactive_percent(SYSCTL_HANDLER_ARGS)
93
{
94
	int error;
95
	int percent;
96
97
	percent = *(int *)arg1;
98
	error = sysctl_handle_int(oidp, &percent, 0, req);
99
	if (error || !req->newptr)
100
		return (error);
101
	if (percent < 0)
102
		percent = 0;
103
	if (percent > 100)
104
		percent = 100;
105
	*(int *)arg1 = percent;
106
	return (0);
107
}
108
90
SYSCTL_PROC(_vfs_tmpfs, OID_AUTO, memory_reserved, CTLTYPE_LONG|CTLFLAG_RW,
109
SYSCTL_PROC(_vfs_tmpfs, OID_AUTO, memory_reserved, CTLTYPE_LONG|CTLFLAG_RW,
91
    &tmpfs_pages_reserved, 0, sysctl_mem_reserved, "L",
110
    &tmpfs_pages_reserved, 0, sysctl_mem_reserved, "L",
92
    "Amount of available memory and swap below which tmpfs growth stops");
111
    "Amount of available memory and swap below which tmpfs growth stops");
112
SYSCTL_PROC(_vfs_tmpfs, OID_AUTO, inactive_percent, CTLTYPE_INT|CTLFLAG_RW,
113
    &tmpfs_inactive_percent, 0, sysctl_inactive_percent, "I",
114
    "Percentage of inactive memory to add to free space");
93
115
94
static __inline int tmpfs_dirtree_cmp(struct tmpfs_dirent *a,
116
static __inline int tmpfs_dirtree_cmp(struct tmpfs_dirent *a,
95
    struct tmpfs_dirent *b);
117
    struct tmpfs_dirent *b);
Lines 100-106 Link Here
100
{
122
{
101
	vm_ooffset_t avail;
123
	vm_ooffset_t avail;
102
124
103
	avail = swap_pager_avail + vm_cnt.v_free_count - tmpfs_pages_reserved;
125
	avail = swap_pager_avail + vm_cnt.v_free_count +
126
		(vm_cnt.v_inactive_count / 100 * tmpfs_inactive_percent) -
127
		tmpfs_pages_reserved;
104
	if (__predict_false(avail < 0))
128
	if (__predict_false(avail < 0))
105
		avail = 0;
129
		avail = 0;
106
	return (avail);
130
	return (avail);

Return to bug 223015