Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm make ubc_winshift / ubc_winsize constant, and based ...



details:   https://anonhg.NetBSD.org/src/rev/9e614eda49f1
branches:  trunk
changeset: 935127:9e614eda49f1
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Thu Jun 25 14:04:30 2020 +0000

description:
make ubc_winshift / ubc_winsize constant, and based on whatever is bigger
of (1 << UBC_WINSHIFT, MAX_PAGE_SIZE)

given that default UBC_WINSHIFT is 13, this changes behaviour only
for mips and powerpc (BookE/OEA), which will now have twice as much
memory used for UBC windows; if this ever becomes a problem, it's
possible to reduce ubc_nwins in MD code similar to what is done on sparc

this eliminates variable-length arrays in ubc_fault(),
ubc_uiomove(), and ubc_zerorange() so that the stack usage can be
determined and checked in compile time

diffstat:

 sys/uvm/uvm_bio.c |  27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diffs (98 lines):

diff -r 598a00ff9d0e -r 9e614eda49f1 sys/uvm/uvm_bio.c
--- a/sys/uvm/uvm_bio.c Thu Jun 25 11:48:39 2020 +0000
+++ b/sys/uvm/uvm_bio.c Thu Jun 25 14:04:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_bio.c,v 1.117 2020/05/25 19:29:08 ad Exp $ */
+/*     $NetBSD: uvm_bio.c,v 1.118 2020/06/25 14:04:30 jdolecek Exp $   */
 
 /*
  * Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.117 2020/05/25 19:29:08 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.118 2020/06/25 14:04:30 jdolecek Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ubc.h"
@@ -45,6 +45,7 @@
 #include <sys/kernel.h>
 #include <sys/proc.h>
 #include <sys/vnode.h>
+#include <sys/bitops.h>                /* for ilog2() */
 
 #include <uvm/uvm.h>
 #include <uvm/uvm_pdpolicy.h>
@@ -120,9 +121,13 @@
        /* ... rest are NULL */
 };
 
+/* Use value at least as big as maximum page size supported by architecture */
+#define UBC_MAX_WINSHIFT       \
+    ((1 << UBC_WINSHIFT) > MAX_PAGE_SIZE ? UBC_WINSHIFT : ilog2(MAX_PAGE_SIZE))
+
 int ubc_nwins = UBC_NWINS;
-int ubc_winshift __read_mostly = UBC_WINSHIFT;
-int ubc_winsize __read_mostly;
+const int ubc_winshift = UBC_MAX_WINSHIFT;
+const int ubc_winsize = 1 << UBC_MAX_WINSHIFT;
 #if defined(PMAP_PREFER)
 int ubc_nqueues;
 #define UBC_NQUEUES ubc_nqueues
@@ -161,9 +166,7 @@
        /*
         * Make sure ubc_winshift is sane.
         */
-       if (ubc_winshift < PAGE_SHIFT)
-               ubc_winshift = PAGE_SHIFT;
-       ubc_winsize = 1 << ubc_winshift;
+       KASSERT(ubc_winshift >= PAGE_SHIFT);
 
        /*
         * init ubc_object.
@@ -304,7 +307,7 @@
        struct uvm_object *uobj;
        struct ubc_map *umap;
        vaddr_t va, eva, ubc_offset, slot_offset;
-       struct vm_page *pgs[ubc_winsize >> PAGE_SHIFT];
+       struct vm_page *pgs[howmany(ubc_winsize, MIN_PAGE_SIZE)];
        int i, error, npages;
        vm_prot_t prot;
 
@@ -732,7 +735,7 @@
     int flags)
 {
        const bool overwrite = (flags & UBC_FAULTBUSY) != 0;
-       struct vm_page *pgs[ubc_winsize >> PAGE_SHIFT];
+       struct vm_page *pgs[howmany(ubc_winsize, MIN_PAGE_SIZE)];
        voff_t off;
        int error, npages;
 
@@ -798,7 +801,7 @@
 void
 ubc_zerorange(struct uvm_object *uobj, off_t off, size_t len, int flags)
 {
-       struct vm_page *pgs[ubc_winsize >> PAGE_SHIFT];
+       struct vm_page *pgs[howmany(ubc_winsize, MIN_PAGE_SIZE)];
        int npages;
 
 #ifdef UBC_USE_PMAP_DIRECT
@@ -975,7 +978,7 @@
        const bool overwrite = (flags & UBC_FAULTBUSY) != 0;
        voff_t off;
        int error, npages;
-       struct vm_page *pgs[ubc_winsize >> PAGE_SHIFT];
+       struct vm_page *pgs[howmany(ubc_winsize, MIN_PAGE_SIZE)];
 
        KASSERT(todo <= uio->uio_resid);
        KASSERT(((flags & UBC_WRITE) != 0 && uio->uio_rw == UIO_WRITE) ||
@@ -1043,7 +1046,7 @@
 ubc_zerorange_direct(struct uvm_object *uobj, off_t off, size_t todo, int flags)
 {
        int error, npages;
-       struct vm_page *pgs[ubc_winsize >> PAGE_SHIFT];
+       struct vm_page *pgs[howmany(ubc_winsize, MIN_PAGE_SIZE)];
 
        flags |= UBC_WRITE;
 



Home | Main Index | Thread Index | Old Index