Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/tmpfs Remove the hardcoded 4 MB free kernel memory li...



details:   https://anonhg.NetBSD.org/src/rev/42677ca3947b
branches:  trunk
changeset: 796518:42677ca3947b
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Jun 07 09:54:34 2014 +0000

description:
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.

diffstat:

 sys/fs/tmpfs/tmpfs.h        |   9 +--------
 sys/fs/tmpfs/tmpfs_mem.c    |  10 +++++-----
 sys/fs/tmpfs/tmpfs_vfsops.c |   6 +++---
 3 files changed, 9 insertions(+), 16 deletions(-)

diffs (90 lines):

diff -r 705022c3168c -r 42677ca3947b sys/fs/tmpfs/tmpfs.h
--- a/sys/fs/tmpfs/tmpfs.h      Sat Jun 07 09:34:02 2014 +0000
+++ b/sys/fs/tmpfs/tmpfs.h      Sat Jun 07 09:54:34 2014 +0000
@@ -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 @@
     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.
  */
 
diff -r 705022c3168c -r 42677ca3947b sys/fs/tmpfs/tmpfs_mem.c
--- a/sys/fs/tmpfs/tmpfs_mem.c  Sat Jun 07 09:34:02 2014 +0000
+++ b/sys/fs/tmpfs/tmpfs_mem.c  Sat Jun 07 09:54:34 2014 +0000
@@ -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 @@
  * => 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 @@
        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);
diff -r 705022c3168c -r 42677ca3947b sys/fs/tmpfs/tmpfs_vfsops.c
--- a/sys/fs/tmpfs/tmpfs_vfsops.c       Sat Jun 07 09:34:02 2014 +0000
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c       Sat Jun 07 09:54:34 2014 +0000
@@ -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 @@
 
 
        /* 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. */



Home | Main Index | Thread Index | Old Index