Source-Changes-HG archive

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

[src/trunk]: src/sys Remove emap support. Unfortunately it never got to state...



details:   https://anonhg.NetBSD.org/src/rev/ccd49327b5b4
branches:  trunk
changeset: 832592:ccd49327b5b4
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sat May 19 11:39:37 2018 +0000

description:
Remove emap support. Unfortunately it never got to state where it would be
used and usable, due to reliability and limited & complicated MD support.

Going forward, we need to concentrate on interface which do not map anything
into kernel in first place (such as direct map or KVA-less I/O), rather
than making those mappings cheaper to do.

diffstat:

 sys/arch/x86/include/pmap.h |    4 +-
 sys/arch/x86/x86/pmap.c     |   69 +-------
 sys/kern/kern_synch.c       |    5 +-
 sys/kern/sys_pipe.c         |   36 +--
 sys/sys/pipe.h              |    3 +-
 sys/uvm/files.uvm           |    3 +-
 sys/uvm/uvm_emap.c          |  410 --------------------------------------------
 sys/uvm/uvm_extern.h        |   28 +--
 sys/uvm/uvm_init.c          |   10 +-
 9 files changed, 26 insertions(+), 542 deletions(-)

diffs (truncated from 786 to 300 lines):

diff -r 849bfe55d062 -r ccd49327b5b4 sys/arch/x86/include/pmap.h
--- a/sys/arch/x86/include/pmap.h       Sat May 19 11:02:33 2018 +0000
+++ b/sys/arch/x86/include/pmap.h       Sat May 19 11:39:37 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.77 2018/05/08 17:20:44 maxv Exp $   */
+/*     $NetBSD: pmap.h,v 1.78 2018/05/19 11:39:37 jdolecek Exp $       */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -366,8 +366,6 @@
 void           pmap_tlb_shootnow(void);
 void           pmap_tlb_intr(void);
 
-#define        __HAVE_PMAP_EMAP
-
 #define PMAP_GROWKERNEL                /* turn on pmap_growkernel interface */
 #define PMAP_FORK              /* turn on pmap_fork interface */
 
diff -r 849bfe55d062 -r ccd49327b5b4 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Sat May 19 11:02:33 2018 +0000
+++ b/sys/arch/x86/x86/pmap.c   Sat May 19 11:39:37 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.289 2018/03/04 23:25:35 jdolecek Exp $      */
+/*     $NetBSD: pmap.c,v 1.290 2018/05/19 11:39:37 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.289 2018/03/04 23:25:35 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.290 2018/05/19 11:39:37 jdolecek Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1016,67 +1016,6 @@
        }
 }
 
-void
-pmap_emap_enter(vaddr_t va, paddr_t pa, vm_prot_t prot)
-{
-       pt_entry_t *pte, npte;
-
-       KASSERT((prot & ~VM_PROT_ALL) == 0);
-       pte = (va < VM_MIN_KERNEL_ADDRESS) ? vtopte(va) : kvtopte(va);
-
-#ifdef DOM0OPS
-       if (pa < pmap_pa_start || pa >= pmap_pa_end) {
-               npte = pa;
-       } else
-#endif
-               npte = pmap_pa2pte(pa);
-
-       npte = pmap_pa2pte(pa);
-       npte |= protection_codes[prot] | PG_V;
-       pmap_pte_set(pte, npte);
-       pmap_pte_flush();
-}
-
-/*
- * pmap_emap_sync: perform TLB flush or pmap load, if it was deferred.
- */
-void
-pmap_emap_sync(bool canload)
-{
-       struct cpu_info *ci = curcpu();
-       struct pmap *pmap;
-
-       KASSERT(kpreempt_disabled());
-       if (__predict_true(ci->ci_want_pmapload && canload)) {
-               /*
-                * XXX: Hint for pmap_reactivate(), which might suggest to
-                * not perform TLB flush, if state has not changed.
-                */
-               pmap = vm_map_pmap(&curlwp->l_proc->p_vmspace->vm_map);
-               if (__predict_false(pmap == ci->ci_pmap)) {
-                       kcpuset_atomic_clear(pmap->pm_cpus, cpu_index(ci));
-               }
-               pmap_load();
-               KASSERT(ci->ci_want_pmapload == 0);
-       } else {
-               tlbflush();
-       }
-}
-
-void
-pmap_emap_remove(vaddr_t sva, vsize_t len)
-{
-       pt_entry_t *pte;
-       vaddr_t va, eva = sva + len;
-
-       for (va = sva; va < eva; va += PAGE_SIZE) {
-               pte = (va < VM_MIN_KERNEL_ADDRESS) ? vtopte(va) : kvtopte(va);
-               pmap_pte_set(pte, 0);
-       }
-
-       pmap_pte_flush();
-}
-
 __strict_weak_alias(pmap_kenter_ma, pmap_kenter_pa);
 
 #if defined(__x86_64__)
@@ -2925,9 +2864,7 @@
                 */
                kcpuset_atomic_set(pmap->pm_cpus, cid);
 
-               u_int gen = uvm_emap_gen_return();
                tlbflush();
-               uvm_emap_update(gen);
        }
 }
 
@@ -3027,9 +2964,7 @@
 
        lldt(pmap->pm_ldt_sel);
 
-       u_int gen = uvm_emap_gen_return();
        cpu_load_pmap(pmap, oldpmap);
-       uvm_emap_update(gen);
 
        ci->ci_want_pmapload = 0;
 
diff -r 849bfe55d062 -r ccd49327b5b4 sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c     Sat May 19 11:02:33 2018 +0000
+++ b/sys/kern/kern_synch.c     Sat May 19 11:39:37 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_synch.c,v 1.314 2018/02/16 07:04:51 ozaki-r Exp $ */
+/*     $NetBSD: kern_synch.c,v 1.315 2018/05/19 11:39:37 jdolecek Exp $        */
 
 /*-
  * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.314 2018/02/16 07:04:51 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.315 2018/05/19 11:39:37 jdolecek Exp $");
 
 #include "opt_kstack.h"
 #include "opt_perfctrs.h"
@@ -730,7 +730,6 @@
                 * Restore VM context and IPL.
                 */
                pmap_activate(l);
-               uvm_emap_switch(l);
                pcu_switchpoint(l);
 
                if (prevlwp != NULL) {
diff -r 849bfe55d062 -r ccd49327b5b4 sys/kern/sys_pipe.c
--- a/sys/kern/sys_pipe.c       Sat May 19 11:02:33 2018 +0000
+++ b/sys/kern/sys_pipe.c       Sat May 19 11:39:37 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_pipe.c,v 1.144 2018/04/20 19:02:18 jdolecek Exp $  */
+/*     $NetBSD: sys_pipe.c,v 1.145 2018/05/19 11:39:37 jdolecek Exp $  */
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.144 2018/04/20 19:02:18 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.145 2018/05/19 11:39:37 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -92,8 +92,6 @@
 #include <sys/atomic.h>
 #include <sys/pipe.h>
 
-#include <uvm/uvm_extern.h>
-
 /*
  * Use this to disable direct I/O and decrease the code size:
  * #define PIPE_NODIRECT
@@ -102,6 +100,10 @@
 /* XXX Disabled for now; rare hangs switching between direct/buffered */        
 #define PIPE_NODIRECT
 
+#ifndef PIPE_NODIRECT
+#include <uvm/uvm.h>
+#endif
+
 static int     pipe_read(file_t *, off_t *, struct uio *, kauth_cred_t, int);
 static int     pipe_write(file_t *, off_t *, struct uio *, kauth_cred_t, int);
 static int     pipe_close(file_t *);
@@ -509,7 +511,6 @@
                         * Direct copy, bypassing a kernel buffer.
                         */
                        void *va;
-                       u_int gen;
 
                        KASSERT(rpipe->pipe_state & PIPE_DIRECTW);
 
@@ -518,15 +519,8 @@
                                size = uio->uio_resid;
 
                        va = (char *)rmap->kva + rmap->pos;
-                       gen = rmap->egen;
                        mutex_exit(lock);
-
-                       /*
-                        * Consume emap and read the data from loaned pages.
-                        */
-                       uvm_emap_consume(gen);
                        error = uiomove(va, size, uio);
-
                        mutex_enter(lock);
                        if (error)
                                break;
@@ -660,7 +654,6 @@
        struct pipemapping * const wmap = &wpipe->pipe_map;
        const vsize_t len = ptoa(wmap->npages);
 
-       uvm_emap_remove(wmap->kva, len);        /* XXX */
        uvm_km_free(kernel_map, wmap->kva, len, UVM_KMF_VAONLY);
        wmap->kva = 0;
        atomic_add_int(&amountpipekva, -len);
@@ -746,10 +739,12 @@
                return (ENOMEM); /* so that caller fallback to ordinary write */
        }
 
-       /* Enter the loaned pages to KVA, produce new emap generation number. */
-       uvm_emap_enter(wmap->kva + ptoa(starting_color), pgs, npages,
-           VM_PROT_READ);
-       wmap->egen = uvm_emap_produce();
+       /* Enter the loaned pages to kva */
+       vaddr_t kva = wpipe->pipe_map.kva;
+       for (int j = 0; j < npages; j++, kva += PAGE_SIZE) {
+               pmap_kenter_pa(kva, VM_PAGE_TO_PHYS(pgs[j]), VM_PROT_READ, 0);
+       }
+       pmap_update(pmap_kernel());
 
        /* Now we can put the pipe in direct write mode */
        wmap->pos = bpos + ptoa(starting_color);
@@ -791,7 +786,8 @@
        mutex_exit(lock);
 
        if (pgs != NULL) {
-               /* XXX: uvm_emap_remove */
+               pmap_kremove(wpipe->pipe_map.kva, blen);
+               pmap_update(pmap_kernel());
                uvm_unloan(pgs, npages, UVM_LOAN_TOPAGE);
        }
        if (error || amountpipekva > maxpipekva)
@@ -813,7 +809,7 @@
                        return (error);
                }
 
-               bcnt -= wpipe->cnt;
+               bcnt -= wmap->cnt;
        }
 
        uio->uio_resid -= bcnt;
@@ -918,7 +914,7 @@
                 */
                if ((uio->uio_iov->iov_len >= PIPE_MINDIRECT) &&
                    (fp->f_flag & FNONBLOCK) == 0 &&
-                   (wmap->kva || (amountpipekva < limitpipekva))) {
+                   (wpipe->pipe_map.kva || (amountpipekva < limitpipekva))) {
                        error = pipe_direct_write(fp, wpipe, uio);
 
                        /*
diff -r 849bfe55d062 -r ccd49327b5b4 sys/sys/pipe.h
--- a/sys/sys/pipe.h    Sat May 19 11:02:33 2018 +0000
+++ b/sys/sys/pipe.h    Sat May 19 11:39:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pipe.h,v 1.33 2016/01/22 23:38:45 dholland Exp $ */
+/* $NetBSD: pipe.h,v 1.34 2018/05/19 11:39:37 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1996 John S. Dyson
@@ -82,7 +82,6 @@
        voff_t          pos;            /* current position within page */
        int             npages;         /* how many pages allocated */
        struct vm_page  **pgs;          /* pointers to the pages */
-       u_int           egen;           /* emap generation number */
 };
 
 /*
diff -r 849bfe55d062 -r ccd49327b5b4 sys/uvm/files.uvm
--- a/sys/uvm/files.uvm Sat May 19 11:02:33 2018 +0000
+++ b/sys/uvm/files.uvm Sat May 19 11:39:37 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.uvm,v 1.28 2016/12/23 07:15:28 cherry Exp $
+#      $NetBSD: files.uvm,v 1.29 2018/05/19 11:39:37 jdolecek Exp $
 
 #
 # UVM options
@@ -25,7 +25,6 @@
 file   uvm/uvm_bio.c                   uvm
 file   uvm/uvm_coredump.c              coredump
 file   uvm/uvm_device.c                uvm
-file   uvm/uvm_emap.c                  uvm
 file   uvm/uvm_fault.c                 uvm
 file   uvm/uvm_glue.c                  uvm
 file   uvm/uvm_init.c                  uvm
diff -r 849bfe55d062 -r ccd49327b5b4 sys/uvm/uvm_emap.c



Home | Main Index | Thread Index | Old Index