Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64 clean up a bunch of MULTIPROCESSOR:



details:   https://anonhg.NetBSD.org/src/rev/68c98b2959d8
branches:  trunk
changeset: 752768:68c98b2959d8
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Mar 06 08:08:29 2010 +0000

description:
clean up a bunch of MULTIPROCESSOR:

- always include ci_ipi_evcnt[] in cpuinfo
- #define sparc_ncpus 1 for !MULTIPROCESSOR
- make struct pmap::pm_list an pm_ctx always be an array, and simplify
  several functions and lookups to always be the same

tested on U60 and SB2500 before and after with one and two cpus in an
MP kernel, and UP kernels, and i can't find anything besides noise for
benchmark issues.  (infact, i can't really tell the difference between
GENERIC and GENERIC.MP on these systems...)

diffstat:

 sys/arch/sparc64/include/cpu.h          |   11 ++-
 sys/arch/sparc64/include/intr.h         |    4 +-
 sys/arch/sparc64/include/pmap.h         |   20 ++---
 sys/arch/sparc64/sparc64/autoconf.c     |    6 +-
 sys/arch/sparc64/sparc64/cache.h        |    4 +-
 sys/arch/sparc64/sparc64/cpu.c          |    6 +-
 sys/arch/sparc64/sparc64/db_interface.c |    6 +-
 sys/arch/sparc64/sparc64/pmap.c         |  115 ++++++++-----------------------
 8 files changed, 61 insertions(+), 111 deletions(-)

diffs (truncated from 433 to 300 lines):

diff -r 937e82d86163 -r 68c98b2959d8 sys/arch/sparc64/include/cpu.h
--- a/sys/arch/sparc64/include/cpu.h    Sat Mar 06 06:25:51 2010 +0000
+++ b/sys/arch/sparc64/include/cpu.h    Sat Mar 06 08:08:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.88 2010/02/02 04:28:55 mrg Exp $ */
+/*     $NetBSD: cpu.h,v 1.89 2010/03/06 08:08:29 mrg Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -131,9 +131,9 @@
 
        /* Event counters */
        struct evcnt            ci_tick_evcnt;
-#ifdef MULTIPROCESSOR
+
+       /* This could be under MULTIPROCESSOR, but there's no good reason */
        struct evcnt            ci_ipi_evcnt[IPI_EVCNT_NUM];
-#endif
 
        int                     ci_flags;
        int                     ci_want_ast;
@@ -191,7 +191,12 @@
 
 extern struct cpu_bootargs *cpu_args;
 
+#if defined(MULTIPROCESSOR)
 extern int sparc_ncpus;
+#else
+#define sparc_ncpus 1
+#endif
+
 extern struct cpu_info *cpus;
 extern struct pool_cache *fpstate_cache;
 
diff -r 937e82d86163 -r 68c98b2959d8 sys/arch/sparc64/include/intr.h
--- a/sys/arch/sparc64/include/intr.h   Sat Mar 06 06:25:51 2010 +0000
+++ b/sys/arch/sparc64/include/intr.h   Sat Mar 06 08:08:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.27 2010/02/01 02:42:33 mrg Exp $ */
+/*     $NetBSD: intr.h,v 1.28 2010/03/06 08:08:29 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -73,12 +73,12 @@
 int    mp_cpu_is_paused (sparc64_cpuset_t);
 void   mp_resume_cpu(int);
 #endif /* _LOCORE */
+#endif
 
 #define IPI_EVCNT_TLB_PTE      0
 #define IPI_EVCNT_FPU_SYNCH    1
 #define IPI_EVCNT_FPU_FLUSH    2
 #define IPI_EVCNT_NUM          3
 #define IPI_EVCNT_NAMES { "TLB pte IPI", "FPU synch IPI", "FPU flush IPI" }
-#endif
 
 #endif /* _SPARC64_INTR_H_ */
diff -r 937e82d86163 -r 68c98b2959d8 sys/arch/sparc64/include/pmap.h
--- a/sys/arch/sparc64/include/pmap.h   Sat Mar 06 06:25:51 2010 +0000
+++ b/sys/arch/sparc64/include/pmap.h   Sat Mar 06 08:08:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.51 2010/03/04 08:01:35 mrg Exp $    */
+/*     $NetBSD: pmap.h,v 1.52 2010/03/06 08:08:29 mrg Exp $    */
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -111,19 +111,20 @@
 #define va_to_dir(v)   (int)((((paddr_t)(v))>>PDSHIFT)&PDMASK)
 #define va_to_pte(v)   (int)((((paddr_t)(v))>>PTSHIFT)&PTMASK)
 
+#ifdef MULTIPROCESSOR
+#define PMAP_LIST_MAXNUMCPU    CPUSET_MAXNUMCPU
+#else
+#define PMAP_LIST_MAXNUMCPU    1
+#endif
+
 struct pmap {
        struct uvm_object pm_obj;
 #define pm_lock pm_obj.vmobjlock
 #define pm_refs pm_obj.uo_refs
-#ifdef MULTIPROCESSOR
-       LIST_ENTRY(pmap) pm_list[CPUSET_MAXNUMCPU];     /* per cpu ctx used list */
-#else
-       LIST_ENTRY(pmap) pm_list;       /* single ctx used list */
-#endif
+       LIST_ENTRY(pmap) pm_list[PMAP_LIST_MAXNUMCPU];  /* per cpu ctx used list */
 
        struct pmap_statistics pm_stats;
 
-#ifdef MULTIPROCESSOR
        /*
         * We record the context used on any cpu here. If the context
         * is actually present in the TLB, it will be the plain context
@@ -132,10 +133,7 @@
         * If this pmap has no context allocated on that cpu, the entry
         * will be 0.
         */
-       int pm_ctx[CPUSET_MAXNUMCPU];   /* Current context per cpu */
-#else
-       int pm_ctx;                     /* Current context */
-#endif
+       int pm_ctx[PMAP_LIST_MAXNUMCPU];        /* Current context per cpu */
 
        /*
         * This contains 64-bit pointers to pages that contain
diff -r 937e82d86163 -r 68c98b2959d8 sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Sat Mar 06 06:25:51 2010 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Sat Mar 06 08:08:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.171 2010/03/01 01:14:58 macallan Exp $ */
+/*     $NetBSD: autoconf.c,v 1.172 2010/03/06 08:08:29 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.171 2010/03/01 01:14:58 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.172 2010/03/06 08:08:29 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -207,7 +207,7 @@
                sparc_ncpus++;
        }
 #else
-       sparc_ncpus = 1;
+       /* #define sparc_ncpus 1 */
 #endif
 }
 
diff -r 937e82d86163 -r 68c98b2959d8 sys/arch/sparc64/sparc64/cache.h
--- a/sys/arch/sparc64/sparc64/cache.h  Sat Mar 06 06:25:51 2010 +0000
+++ b/sys/arch/sparc64/sparc64/cache.h  Sat Mar 06 08:08:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cache.h,v 1.15 2010/02/24 09:49:36 mrg Exp $ */
+/*     $NetBSD: cache.h,v 1.16 2010/03/06 08:08:29 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -141,7 +141,7 @@
 void smp_dcache_flush_page_all(paddr_t pa);
 #define        dcache_flush_page_all(pa)       smp_dcache_flush_page_all(pa)
 #else
-#define        tlb_flush_pte(va,pm)    sp_tlb_flush_pte(va, (pm)->pm_ctx)
+#define        tlb_flush_pte(va,pm)    sp_tlb_flush_pte(va, (pm)->pm_ctx[0])
 #define        dcache_flush_page_all(pa)       dcache_flush_page(pa)
 #endif
 
diff -r 937e82d86163 -r 68c98b2959d8 sys/arch/sparc64/sparc64/cpu.c
--- a/sys/arch/sparc64/sparc64/cpu.c    Sat Mar 06 06:25:51 2010 +0000
+++ b/sys/arch/sparc64/sparc64/cpu.c    Sat Mar 06 08:08:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.89 2010/02/22 00:16:31 mrg Exp $ */
+/*     $NetBSD: cpu.c,v 1.90 2010/03/06 08:08:29 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.89 2010/02/22 00:16:31 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.90 2010/03/06 08:08:29 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -77,7 +77,9 @@
 int ecache_min_line_size;
 
 /* Linked list of all CPUs in system. */
+#if defined(MULTIPROCESSOR)
 int sparc_ncpus = 0;
+#endif
 struct cpu_info *cpus = NULL;
 
 volatile sparc64_cpuset_t cpus_active;/* set of active cpus */
diff -r 937e82d86163 -r 68c98b2959d8 sys/arch/sparc64/sparc64/db_interface.c
--- a/sys/arch/sparc64/sparc64/db_interface.c   Sat Mar 06 06:25:51 2010 +0000
+++ b/sys/arch/sparc64/sparc64/db_interface.c   Sat Mar 06 08:08:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_interface.c,v 1.122 2010/02/23 05:32:08 mrg Exp $ */
+/*     $NetBSD: db_interface.c,v 1.123 2010/03/06 08:08:29 mrg Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.122 2010/02/23 05:32:08 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.123 2010/03/06 08:08:29 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -87,7 +87,7 @@
 #ifdef MULTIPROCESSOR
 #define pmap_ctx(PM)   ((PM)->pm_ctx[cpu_number()])
 #else
-#define pmap_ctx(PM)   ((PM)->pm_ctx)
+#define pmap_ctx(PM)   ((PM)->pm_ctx[0])
 #endif
 
 void fill_ddb_regs_from_tf(struct trapframe64 *tf);
diff -r 937e82d86163 -r 68c98b2959d8 sys/arch/sparc64/sparc64/pmap.c
--- a/sys/arch/sparc64/sparc64/pmap.c   Sat Mar 06 06:25:51 2010 +0000
+++ b/sys/arch/sparc64/sparc64/pmap.c   Sat Mar 06 08:08:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.256 2010/03/04 08:11:42 mrg Exp $   */
+/*     $NetBSD: pmap.c,v 1.257 2010/03/06 08:08:30 mrg Exp $   */
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.256 2010/03/04 08:11:42 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.257 2010/03/06 08:08:30 mrg Exp $");
 
 #undef NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define        HWREF
@@ -151,9 +151,7 @@
 static int ctx_alloc(struct pmap *);
 static bool pmap_is_referenced_locked(struct vm_page *);
 
-#ifdef MULTIPROCESSOR
 static void ctx_free(struct pmap *, struct cpu_info *);
-#define pmap_ctx(PM)   ((PM)->pm_ctx[cpu_number()])
 
 /*
  * Check if any MMU has a non-zero context
@@ -171,6 +169,12 @@
        return false;   
 }
 
+#ifdef MULTIPROCESSOR
+#define pmap_ctx(PM)   ((PM)->pm_ctx[cpu_number()])
+#else
+#define pmap_ctx(PM)   ((PM)->pm_ctx[0])
+#endif
+
 /*
  * Check if this pmap has a live mapping on some MMU.
  */
@@ -183,22 +187,6 @@
 
        return pmap_has_ctx(p);
 }
-#else
-static void ctx_free(struct pmap *);
-#define pmap_ctx(PM)   ((PM)->pm_ctx)
-
-static inline bool
-pmap_has_ctx(struct pmap *p)
-{
-       return pmap_ctx(p) > 0;
-}
-
-static inline bool
-pmap_is_on_mmu(struct pmap *p)
-{
-       return p == pmap_kernel() || pmap_ctx(p) > 0;
-}
-#endif
 
 /*
  * Virtual and physical addresses of the start and end of kernel text
@@ -236,7 +224,6 @@
        __asm volatile("clrx [%0]" : : "r" (addr) : "memory");
 }
 
-#ifdef MULTIPROCESSOR
 static void
 tsb_invalidate(vaddr_t va, pmap_t pm)
 {
@@ -247,9 +234,13 @@
        int64_t tag;
 
        i = ptelookup_va(va);
+#ifdef MULTIPROCESSOR
        for (ci = cpus; ci != NULL; ci = ci->ci_next) {
                if (!CPUSET_HAS(cpus_active, ci->ci_index))
                        continue;
+#else
+               ci = curcpu();
+#endif
                ctx = pm->pm_ctx[ci->ci_index];
                if (kpm || ctx > 0) {
                        tag = TSB_TAG(0, ctx, va);
@@ -260,25 +251,10 @@
                                clrx(&ci->ci_tsb_immu[i].data);
                        }
                }
+#ifdef MULTIPROCESSOR
        }
+#endif
 }
-#else



Home | Main Index | Thread Index | Old Index