Module Name: src
Committed By: martin
Date: Sat Jun 7 09:54:34 UTC 2014
Modified Files:
src/sys/fs/tmpfs: tmpfs.h tmpfs_mem.c tmpfs_vfsops.c
Log Message:
Remove the hardcoded 4 MB free kernel memory limit and replace it
by uvmexp.freetarg, as discussed on tech-kern.
Main purpose is to make tmpfs usable (as far as possible) on small memory
machines.
This is a bit experimental, but we need to give it some real world exposure
to see how well it works.
To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/fs/tmpfs/tmpfs.h
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/tmpfs/tmpfs_mem.c
cvs rdiff -u -r1.61 -r1.62 src/sys/fs/tmpfs/tmpfs_vfsops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/fs/tmpfs/tmpfs.h
diff -u src/sys/fs/tmpfs/tmpfs.h:1.49 src/sys/fs/tmpfs/tmpfs.h:1.50
--- src/sys/fs/tmpfs/tmpfs.h:1.49 Wed Apr 30 01:33:51 2014
+++ src/sys/fs/tmpfs/tmpfs.h Sat Jun 7 09:54:34 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs.h,v 1.49 2014/04/30 01:33:51 christos Exp $ */
+/* $NetBSD: tmpfs.h,v 1.50 2014/06/07 09:54:34 martin Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -307,13 +307,6 @@ bool tmpfs_strname_neqlen(struct compon
KASSERT((node)->tn_size % sizeof(tmpfs_dirent_t) == 0);
/*
- * Memory management stuff.
- */
-
-/* Amount of memory pages to reserve for the system. */
-#define TMPFS_PAGES_RESERVED (4 * 1024 * 1024 / PAGE_SIZE)
-
-/*
* Routines to convert VFS structures to tmpfs internal ones.
*/
Index: src/sys/fs/tmpfs/tmpfs_mem.c
diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.5 src/sys/fs/tmpfs/tmpfs_mem.c:1.6
--- src/sys/fs/tmpfs/tmpfs_mem.c:1.5 Wed Apr 30 01:33:51 2014
+++ src/sys/fs/tmpfs/tmpfs_mem.c Sat Jun 7 09:54:34 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_mem.c,v 1.5 2014/04/30 01:33:51 christos Exp $ */
+/* $NetBSD: tmpfs_mem.c,v 1.6 2014/06/07 09:54:34 martin Exp $ */
/*
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.5 2014/04/30 01:33:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.6 2014/06/07 09:54:34 martin Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -89,7 +89,7 @@ tmpfs_mntmem_set(struct tmpfs_mount *mp,
* => If 'total' is true, then return _total_ amount of pages.
* => If false, then return the amount of _free_ memory pages.
*
- * Remember to remove TMPFS_PAGES_RESERVED from the returned value to avoid
+ * Remember to remove uvmexp.freetarg from the returned value to avoid
* excessive memory usage.
*/
size_t
@@ -118,10 +118,10 @@ tmpfs_bytes_max(struct tmpfs_mount *mp)
size_t freepages = tmpfs_mem_info(false);
uint64_t avail_mem;
- if (freepages < TMPFS_PAGES_RESERVED) {
+ if (freepages < uvmexp.freetarg) {
freepages = 0;
} else {
- freepages -= TMPFS_PAGES_RESERVED;
+ freepages -= uvmexp.freetarg;
}
avail_mem = round_page(mp->tm_bytes_used) + (freepages << PAGE_SHIFT);
return MIN(mp->tm_mem_limit, avail_mem);
Index: src/sys/fs/tmpfs/tmpfs_vfsops.c
diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.61 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.62
--- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.61 Wed Apr 30 01:59:30 2014
+++ src/sys/fs/tmpfs/tmpfs_vfsops.c Sat Jun 7 09:54:34 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_vfsops.c,v 1.61 2014/04/30 01:59:30 christos Exp $ */
+/* $NetBSD: tmpfs_vfsops.c,v 1.62 2014/06/07 09:54:34 martin Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.61 2014/04/30 01:59:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.62 2014/06/07 09:54:34 martin Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -132,7 +132,7 @@ tmpfs_mount(struct mount *mp, const char
/* Prohibit mounts if there is not enough memory. */
- if (tmpfs_mem_info(true) < TMPFS_PAGES_RESERVED)
+ if (tmpfs_mem_info(true) < uvmexp.freetarg)
return EINVAL;
/* Get the memory usage limit for this file-system. */