From c0a06fd4352cd170bda98871ea0e03226a7a1508 Mon Sep 17 00:00:00 2001 From: delphij Date: Mon, 21 Nov 2011 20:26:22 +0000 Subject: [PATCH 03/65] Improve the way to calculate available pages in tmpfs: - Don't deduct wired pages from total usable counts because it does not make any sense. To make things worse, on systems where swap size is smaller than physical memory and use a lot of wired pages (e.g. ZFS), tmpfs can suddenly have free space of 0 because of this; - Count cached pages as available; [1] - Don't count inactive pages as available, technically we could but that might be too aggressive; [1] [1] Suggested by kib@ MFC after: 1 week git-svn-id: http://svn.freebsd.org/base/head@227802 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f (cherry picked from commit 70b92b76559c717845112ea758fdd723a4f924a8) Signed-off-by: Xin Li --- sys/fs/tmpfs/tmpfs.h | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index e95e3c8..fe00fea 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -502,11 +502,8 @@ int tmpfs_truncate(struct vnode *, off_t); static __inline size_t tmpfs_mem_info(void) { - size_t size; - size = swap_pager_avail + cnt.v_free_count + cnt.v_inactive_count; - size -= size > cnt.v_wire_count ? cnt.v_wire_count : size; - return size; + return (swap_pager_avail + cnt.v_free_count + cnt.v_cache_count); } /* Returns the maximum size allowed for a tmpfs file system. This macro -- 1.7.8.3