tech-kern archive

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

Re: Making tmpfs reserved memory configurable



On Fri, May 30, 2014 at 04:56:01PM +0200, Martin Husemann wrote:
> I have been on a quest to make the stock vax install CD (-image) usable on
> VAX machines with 8 MB recently. (8 MB is the lowest I could persuade simh
> to emulate, for 4 MB we will need a custom kernel anyway and for smaller
> even a custom /boot - I will cover installing on those machines in an
> upcoming improvement of the install docs).

Ok, this (much simpler) patch makes tmpfs work on low memory machines.
Comments?

Martin
Index: tmpfs.h
===================================================================
RCS file: /cvsroot/src/sys/fs/tmpfs/tmpfs.h,v
retrieving revision 1.49
diff -u -p -r1.49 tmpfs.h
--- tmpfs.h     30 Apr 2014 01:33:51 -0000      1.49
+++ tmpfs.h     5 Jun 2014 13:40:19 -0000
@@ -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: tmpfs_mem.c
===================================================================
RCS file: /cvsroot/src/sys/fs/tmpfs/tmpfs_mem.c,v
retrieving revision 1.5
diff -u -p -r1.5 tmpfs_mem.c
--- tmpfs_mem.c 30 Apr 2014 01:33:51 -0000      1.5
+++ tmpfs_mem.c 5 Jun 2014 13:40:19 -0000
@@ -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.freemin 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.freemin) {
                freepages = 0;
        } else {
-               freepages -= TMPFS_PAGES_RESERVED;
+               freepages -= uvmexp.freemin;
        }
        avail_mem = round_page(mp->tm_bytes_used) + (freepages << PAGE_SHIFT);
        return MIN(mp->tm_mem_limit, avail_mem);
Index: tmpfs_vfsops.c
===================================================================
RCS file: /cvsroot/src/sys/fs/tmpfs/tmpfs_vfsops.c,v
retrieving revision 1.61
diff -u -p -r1.61 tmpfs_vfsops.c
--- tmpfs_vfsops.c      30 Apr 2014 01:59:30 -0000      1.61
+++ tmpfs_vfsops.c      5 Jun 2014 13:40:19 -0000
@@ -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.freemin)
                return EINVAL;
 
        /* Get the memory usage limit for this file-system. */
Index: mount_tmpfs.8
===================================================================
RCS file: /cvsroot/src/sbin/mount_tmpfs/mount_tmpfs.8,v
retrieving revision 1.17
diff -u -r1.17 mount_tmpfs.8
--- mount_tmpfs.8       4 Dec 2013 18:05:21 -0000       1.17
+++ mount_tmpfs.8       5 Jun 2014 13:41:09 -0000
@@ -83,7 +83,7 @@
 Specifies the total file system size in bytes.
 If zero is given (the default), the available amount of memory (including
 main memory and swap space) will be used.
-Note that four megabytes are always reserved for the system and cannot
+Note that some memory is always reserved for the system and cannot
 be assigned to the file system.
 .Ar Size
 can alternatively be specified as a percentage of the available


Home | Main Index | Thread Index | Old Index