Module Name: src Committed By: jdolecek Date: Sat May 19 11:39:37 UTC 2018
Modified Files: src/sys/arch/x86/include: pmap.h src/sys/arch/x86/x86: pmap.c src/sys/kern: kern_synch.c sys_pipe.c src/sys/sys: pipe.h src/sys/uvm: files.uvm uvm_extern.h uvm_init.c Removed Files: src/sys/uvm: uvm_emap.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.289 -r1.290 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.314 -r1.315 src/sys/kern/kern_synch.c cvs rdiff -u -r1.144 -r1.145 src/sys/kern/sys_pipe.c cvs rdiff -u -r1.33 -r1.34 src/sys/sys/pipe.h cvs rdiff -u -r1.28 -r1.29 src/sys/uvm/files.uvm cvs rdiff -u -r1.13 -r0 src/sys/uvm/uvm_emap.c cvs rdiff -u -r1.211 -r1.212 src/sys/uvm/uvm_extern.h cvs rdiff -u -r1.48 -r1.49 src/sys/uvm/uvm_init.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/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.77 src/sys/arch/x86/include/pmap.h:1.78 --- src/sys/arch/x86/include/pmap.h:1.77 Tue May 8 17:20:44 2018 +++ src/sys/arch/x86/include/pmap.h Sat May 19 11:39:37 2018 @@ -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_shootdown(pmap_t, vaddr_t 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 */ Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.289 src/sys/arch/x86/x86/pmap.c:1.290 --- src/sys/arch/x86/x86/pmap.c:1.289 Sun Mar 4 23:25:35 2018 +++ src/sys/arch/x86/x86/pmap.c Sat May 19 11:39:37 2018 @@ -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 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v } } -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 @@ pmap_reactivate(struct pmap *pmap) */ kcpuset_atomic_set(pmap->pm_cpus, cid); - u_int gen = uvm_emap_gen_return(); tlbflush(); - uvm_emap_update(gen); } } @@ -3027,9 +2964,7 @@ pmap_load(void) 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; Index: src/sys/kern/kern_synch.c diff -u src/sys/kern/kern_synch.c:1.314 src/sys/kern/kern_synch.c:1.315 --- src/sys/kern/kern_synch.c:1.314 Fri Feb 16 07:04:51 2018 +++ src/sys/kern/kern_synch.c Sat May 19 11:39:37 2018 @@ -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 @@ mi_switch(lwp_t *l) * Restore VM context and IPL. */ pmap_activate(l); - uvm_emap_switch(l); pcu_switchpoint(l); if (prevlwp != NULL) { Index: src/sys/kern/sys_pipe.c diff -u src/sys/kern/sys_pipe.c:1.144 src/sys/kern/sys_pipe.c:1.145 --- src/sys/kern/sys_pipe.c:1.144 Fri Apr 20 19:02:18 2018 +++ src/sys/kern/sys_pipe.c Sat May 19 11:39:37 2018 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v #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 @@ __KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v /* 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 @@ again: * Direct copy, bypassing a kernel buffer. */ void *va; - u_int gen; KASSERT(rpipe->pipe_state & PIPE_DIRECTW); @@ -518,15 +519,8 @@ again: 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 @@ pipe_loan_free(struct pipe *wpipe) 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 @@ pipe_direct_write(file_t *fp, struct pip 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 @@ pipe_direct_write(file_t *fp, struct pip 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 @@ pipe_direct_write(file_t *fp, struct pip return (error); } - bcnt -= wpipe->cnt; + bcnt -= wmap->cnt; } uio->uio_resid -= bcnt; @@ -918,7 +914,7 @@ pipe_write(file_t *fp, off_t *offset, st */ 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); /* Index: src/sys/sys/pipe.h diff -u src/sys/sys/pipe.h:1.33 src/sys/sys/pipe.h:1.34 --- src/sys/sys/pipe.h:1.33 Fri Jan 22 23:38:45 2016 +++ src/sys/sys/pipe.h Sat May 19 11:39:37 2018 @@ -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 @@ struct pipemapping { 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 */ }; /* Index: src/sys/uvm/files.uvm diff -u src/sys/uvm/files.uvm:1.28 src/sys/uvm/files.uvm:1.29 --- src/sys/uvm/files.uvm:1.28 Fri Dec 23 07:15:28 2016 +++ src/sys/uvm/files.uvm Sat May 19 11:39:37 2018 @@ -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_aobj.c uvm 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 Index: src/sys/uvm/uvm_extern.h diff -u src/sys/uvm/uvm_extern.h:1.211 src/sys/uvm/uvm_extern.h:1.212 --- src/sys/uvm/uvm_extern.h:1.211 Tue May 8 19:33:57 2018 +++ src/sys/uvm/uvm_extern.h Sat May 19 11:39:37 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_extern.h,v 1.211 2018/05/08 19:33:57 christos Exp $ */ +/* $NetBSD: uvm_extern.h,v 1.212 2018/05/19 11:39:37 jdolecek Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -618,32 +618,6 @@ int ubc_uiomove(struct uvm_object *, s void ubc_zerorange(struct uvm_object *, off_t, size_t, int); void ubc_purge(struct uvm_object *); -/* uvm_emap.c */ -void uvm_emap_sysinit(void); -#ifdef __HAVE_PMAP_EMAP -void uvm_emap_switch(lwp_t *); -#else -#define uvm_emap_switch(l) -#endif - -u_int uvm_emap_gen_return(void); -void uvm_emap_update(u_int); - -vaddr_t uvm_emap_alloc(vsize_t, bool); -void uvm_emap_free(vaddr_t, size_t); - -void uvm_emap_enter(vaddr_t, struct vm_page **, u_int, - vm_prot_t); -void uvm_emap_remove(vaddr_t, vsize_t); - -#ifdef __HAVE_PMAP_EMAP -void uvm_emap_consume(u_int); -u_int uvm_emap_produce(void); -#else -#define uvm_emap_consume(x) -#define uvm_emap_produce() UVM_EMAP_INACTIVE -#endif - /* uvm_fault.c */ #define uvm_fault(m, a, p) uvm_fault_internal(m, a, p, 0) int uvm_fault_internal(struct vm_map *, vaddr_t, vm_prot_t, int); Index: src/sys/uvm/uvm_init.c diff -u src/sys/uvm/uvm_init.c:1.48 src/sys/uvm/uvm_init.c:1.49 --- src/sys/uvm/uvm_init.c:1.48 Fri Dec 23 07:15:28 2016 +++ src/sys/uvm/uvm_init.c Sat May 19 11:39:37 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_init.c,v 1.48 2016/12/23 07:15:28 cherry Exp $ */ +/* $NetBSD: uvm_init.c,v 1.49 2018/05/19 11:39:37 jdolecek Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.48 2016/12/23 07:15:28 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.49 2018/05/19 11:39:37 jdolecek Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -167,12 +167,6 @@ uvm_init(void) uvm_loan_init(); /* - * Init emap subsystem. - */ - - uvm_emap_sysinit(); - - /* * The VM system is now up! Now that kmem is up we can resize the * <obj,off> => <page> hash table for general use and enable paging * of kernel objects.