Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86 rename sys/arch/x86/x86/pmap_tlb.c to sys/arch/...



details:   https://anonhg.NetBSD.org/src/rev/9a3053c890d5
branches:  trunk
changeset: 358926:9a3053c890d5
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Jan 22 19:37:45 2018 +0000

description:
rename sys/arch/x86/x86/pmap_tlb.c to sys/arch/x86/x86/x86_tlb.c, so that
x86 can eventually use uvm/pmap/pmap_tlb.c; step to future PCID support

diffstat:

 sys/arch/x86/conf/files.x86 |    4 +-
 sys/arch/x86/x86/pmap_tlb.c |  478 --------------------------------------------
 sys/arch/x86/x86/x86_tlb.c  |  478 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 480 insertions(+), 480 deletions(-)

diffs (truncated from 982 to 300 lines):

diff -r 3c912f77ddba -r 9a3053c890d5 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86       Mon Jan 22 18:15:56 2018 +0000
+++ b/sys/arch/x86/conf/files.x86       Mon Jan 22 19:37:45 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.x86,v 1.91 2018/01/08 01:41:34 christos Exp $
+#      $NetBSD: files.x86,v 1.92 2018/01/22 19:37:45 jdolecek Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -94,7 +94,7 @@
 file   arch/x86/x86/patch.c            machdep
 file   arch/x86/x86/platform.c         machdep
 file   arch/x86/x86/pmap.c             machdep
-file   arch/x86/x86/pmap_tlb.c         machdep
+file   arch/x86/x86/x86_tlb.c          machdep
 file   arch/x86/x86/pmc.c              machdep
 file   arch/x86/x86/procfs_machdep.c   procfs
 file   arch/x86/x86/sys_machdep.c      machdep
diff -r 3c912f77ddba -r 9a3053c890d5 sys/arch/x86/x86/pmap_tlb.c
--- a/sys/arch/x86/x86/pmap_tlb.c       Mon Jan 22 18:15:56 2018 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,478 +0,0 @@
-/*     $NetBSD: pmap_tlb.c,v 1.8 2016/11/13 12:58:40 maxv Exp $        */
-
-/*-
- * Copyright (c) 2008-2012 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Andrew Doran and Mindaugas Rasiukevicius.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * x86 pmap(9) module: TLB shootdowns.
- *
- * TLB shootdowns are hard interrupts that operate outside the SPL framework.
- * They do not need to be blocked, provided that the pmap module gets the
- * order of events correct.  The calls are made by poking the LAPIC directly.
- * The interrupt handler is short and does one of the following: invalidate
- * a set of pages, all user TLB entries or the entire TLB.
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.8 2016/11/13 12:58:40 maxv Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-
-#include <sys/systm.h>
-#include <sys/atomic.h>
-#include <sys/cpu.h>
-#include <sys/intr.h>
-#include <uvm/uvm.h>
-
-#include <machine/cpuvar.h>
-#ifdef XEN
-#include <xen/xenpmap.h>
-#endif /* XEN */
-#include <x86/i82489reg.h>
-#include <x86/i82489var.h>
-
-/*
- * TLB shootdown structures.
- */
-
-typedef struct {
-#ifdef _LP64
-       uintptr_t               tp_va[14];      /* whole struct: 128 bytes */
-#else
-       uintptr_t               tp_va[13];      /* whole struct: 64 bytes */
-#endif
-       uint16_t                tp_count;
-       uint16_t                tp_pte;
-       int                     tp_userpmap;
-       kcpuset_t *             tp_cpumask;
-} pmap_tlb_packet_t;
-
-/*
- * No more than N separate invlpg.
- *
- * Statistically, a value of six is big enough to cover the requested number
- * of pages in ~ 95% of the TLB shootdowns we are getting. We therefore rarely
- * reach the limit, and increasing it can actually reduce the performance due
- * to the high cost of invlpg.
- */
-#define        TP_MAXVA                6
-
-/*
- * TLB shootdown state.
- */
-static pmap_tlb_packet_t       pmap_tlb_packet         __cacheline_aligned;
-static volatile u_int          pmap_tlb_pendcount      __cacheline_aligned;
-static volatile u_int          pmap_tlb_gen            __cacheline_aligned;
-static struct evcnt            pmap_tlb_evcnt          __cacheline_aligned;
-
-/*
- * TLB shootdown statistics.
- */
-#ifdef TLBSTATS
-static struct evcnt            tlbstat_local[TLBSHOOT__MAX];
-static struct evcnt            tlbstat_remote[TLBSHOOT__MAX];
-static struct evcnt            tlbstat_kernel[TLBSHOOT__MAX];
-static struct evcnt            tlbstat_single_req;
-static struct evcnt            tlbstat_single_issue;
-static const char *            tlbstat_name[ ] = {
-       "APTE",
-       "KENTER",
-       "KREMOVE",
-       "FREE_PTP1",
-       "FREE_PTP2",
-       "REMOVE_PTE",
-       "REMOVE_PTES",
-       "SYNC_PV1",
-       "SYNC_PV2",
-       "WRITE_PROTECT",
-       "ENTER",
-       "UPDATE",
-       "BUS_DMA",
-       "BUS_SPACE"
-};
-#endif
-
-void
-pmap_tlb_init(void)
-{
-
-       memset(&pmap_tlb_packet, 0, sizeof(pmap_tlb_packet_t));
-       pmap_tlb_pendcount = 0;
-       pmap_tlb_gen = 0;
-
-       evcnt_attach_dynamic(&pmap_tlb_evcnt, EVCNT_TYPE_INTR,
-           NULL, "TLB", "shootdown");
-
-#ifdef TLBSTATS
-       int i;
-
-       for (i = 0; i < TLBSHOOT__MAX; i++) {
-               evcnt_attach_dynamic(&tlbstat_local[i], EVCNT_TYPE_MISC,
-                   NULL, "tlbshoot local", tlbstat_name[i]);
-       }
-       for (i = 0; i < TLBSHOOT__MAX; i++) {
-               evcnt_attach_dynamic(&tlbstat_remote[i], EVCNT_TYPE_MISC,
-                   NULL, "tlbshoot remote", tlbstat_name[i]);
-       }
-       for (i = 0; i < TLBSHOOT__MAX; i++) {
-               evcnt_attach_dynamic(&tlbstat_kernel[i], EVCNT_TYPE_MISC,
-                   NULL, "tlbshoot kernel", tlbstat_name[i]);
-       }
-       evcnt_attach_dynamic(&tlbstat_single_req, EVCNT_TYPE_MISC,
-           NULL, "tlbshoot single page", "requests");
-       evcnt_attach_dynamic(&tlbstat_single_issue, EVCNT_TYPE_MISC,
-           NULL, "tlbshoot single page", "issues");
-#endif
-}
-
-void
-pmap_tlb_cpu_init(struct cpu_info *ci)
-{
-       pmap_tlb_packet_t *tp = (pmap_tlb_packet_t *)ci->ci_pmap_data;
-
-       memset(tp, 0, sizeof(pmap_tlb_packet_t));
-       kcpuset_create(&tp->tp_cpumask, true);
-}
-
-static inline void
-pmap_tlbstat_count(struct pmap *pm, vaddr_t va, tlbwhy_t why)
-{
-#ifdef TLBSTATS
-       const cpuid_t cid = cpu_index(curcpu());
-       bool local = false, remote = false;
-
-       if (va != (vaddr_t)-1LL) {
-               atomic_inc_64(&tlbstat_single_req.ev_count);
-       }
-       if (pm == pmap_kernel()) {
-               atomic_inc_64(&tlbstat_kernel[why].ev_count);
-               return;
-       }
-
-       if (va >= VM_MAXUSER_ADDRESS) {
-               remote = kcpuset_isotherset(pm->pm_kernel_cpus, cid);
-               local = kcpuset_isset(pm->pm_kernel_cpus, cid);
-       }
-       remote |= kcpuset_isotherset(pm->pm_cpus, cid);
-       local |= kcpuset_isset(pm->pm_cpus, cid);
-
-       if (local) {
-               atomic_inc_64(&tlbstat_local[why].ev_count);
-       }
-       if (remote) {
-               atomic_inc_64(&tlbstat_remote[why].ev_count);
-       }
-#endif
-}
-
-static inline void
-pmap_tlb_invalidate(const pmap_tlb_packet_t *tp)
-{
-       int i;
-
-       /* Find out what we need to invalidate. */
-       if (tp->tp_count == (uint16_t)-1) {
-               u_int egen = uvm_emap_gen_return();
-               if (tp->tp_pte & PG_G) {
-                       /* Invalidating user and kernel TLB entries. */
-                       tlbflushg();
-               } else {
-                       /* Invalidating user TLB entries only. */
-                       tlbflush();
-               }
-               uvm_emap_update(egen);
-       } else {
-               /* Invalidating a single page or a range of pages. */
-               for (i = tp->tp_count - 1; i >= 0; i--) {
-                       pmap_update_pg(tp->tp_va[i]);
-               }
-       }
-}
-
-/*
- * pmap_tlb_shootdown: invalidate a page on all CPUs using pmap 'pm'.
- */
-void
-pmap_tlb_shootdown(struct pmap *pm, vaddr_t va, pt_entry_t pte, tlbwhy_t why)
-{
-       pmap_tlb_packet_t *tp;
-       int s;
-
-#ifndef XEN
-       KASSERT((pte & PG_G) == 0 || pm == pmap_kernel());
-#endif
-
-       /*
-        * If tearing down the pmap, do nothing.  We will flush later
-        * when we are ready to recycle/destroy it.
-        */
-       if (__predict_false(curlwp->l_md.md_gc_pmap == pm)) {
-               return;
-       }
-
-       if ((pte & PG_PS) != 0) {
-               va &= PG_LGFRAME;
-       }
-
-       /*
-        * Add the shootdown operation to our pending set.
-        */
-       s = splvm();
-       tp = (pmap_tlb_packet_t *)curcpu()->ci_pmap_data;
-
-       /* Whole address flush will be needed if PG_G is set. */
-       CTASSERT(PG_G == (uint16_t)PG_G);
-       tp->tp_pte |= (uint16_t)pte;
-
-       if (tp->tp_count == (uint16_t)-1) {
-               /*
-                * Already flushing everything.
-                */
-       } else if (tp->tp_count < TP_MAXVA && va != (vaddr_t)-1LL) {
-               /* Flush a single page. */
-               tp->tp_va[tp->tp_count++] = va;
-               KASSERT(tp->tp_count > 0);
-       } else {
-               /* Flush everything. */
-               tp->tp_count = (uint16_t)-1;
-       }
-
-       if (pm != pmap_kernel()) {
-               kcpuset_merge(tp->tp_cpumask, pm->pm_cpus);
-               if (va >= VM_MAXUSER_ADDRESS) {
-                       kcpuset_merge(tp->tp_cpumask, pm->pm_kernel_cpus);
-               }
-               tp->tp_userpmap = 1;
-       } else {
-               kcpuset_copy(tp->tp_cpumask, kcpuset_running);
-       }
-       pmap_tlbstat_count(pm, va, why);
-       splx(s);
-}



Home | Main Index | Thread Index | Old Index