Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Apr 1999 12:49:32 -0700
From:      Mike Smith <mike@smith.net.au>
To:        Terry Lambert <tlambert@primenet.com>
Cc:        mike@smith.net.au (Mike Smith), peter@netplex.com.au, darius@dons.net.au, freebsd-smp@FreeBSD.ORG
Subject:   Re: Really slow SMP 
Message-ID:  <199904271949.MAA00904@dingo.cdrom.com>
In-Reply-To: Your message of "Tue, 27 Apr 1999 19:43:37 -0000." <199904271943.MAA03094@usr04.primenet.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> > > (There is no MTRR synchronization like there was before.  Previously the
> > >  BSP would dump all it's MTRR registers to a table and all the other AP
> > >  cpus would load that table on startup.  That table doesn't exist anymore.)
> > 
> > Hmm.  It's quite likely that the BIOS is only setting the MTRRs in the 
> > BSP; why aren't the APs doing this anymore?
> 
> Right; this is the crux of the matter: it used to work, now it doesn't.
> 
> Clearly, the SMP patches are what had this effect; the question is why?

I know why; I'm waiting on feedback from peter regarding these patches, 
but I'd appreciate anyone else seeing the problem to try them too.

Also, anyone that can explain why the memory type is printed as 
"unknown (0x6)" gets a free toy; there are 7 entries in the array.  I 
must be missing something here...

Index: i386/i386/i686_mem.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/i686_mem.c,v
retrieving revision 1.1
diff -u -r1.1 i686_mem.c
--- i686_mem.c	1999/04/07 03:57:45	1.1
+++ i686_mem.c	1999/04/26 05:34:23
@@ -62,21 +62,28 @@
 
 #define mrcopyflags(curr, new) (((curr) & ~MDF_ATTRMASK) | ((new) & MDF_ATTRMASK))
 
-static void			i686_mrinit(struct mem_range_softc *);
-static int			i686_mrset(struct mem_range_softc *,
-					   struct mem_range_desc *,
-					   int *);
+static void			i686_mrinit(struct mem_range_softc *sc);
+static int			i686_mrset(struct mem_range_softc *sc,
+					   struct mem_range_desc *mrd,
+					   int *arg);
+static void			i686_mrAPinit(struct mem_range_softc *sc);
 
 static struct mem_range_ops i686_mrops = {
     i686_mrinit,
-    i686_mrset
+    i686_mrset,
+    i686_mrAPinit
 };
 
+/* XXX for AP startup hook */
+extern struct mem_range_softc	mem_range_softc;
+static u_int64_t		mtrrcap, mtrrdef;
+
 static struct mem_range_desc	*mem_range_match(struct mem_range_softc *sc,
 						 struct mem_range_desc *mrd);
 static void			i686_mrfetch(struct mem_range_softc *sc);
 static int			i686_mtrrtype(int flags);
 static int			i686_mrstore(struct mem_range_softc *sc);
+static int			i686_mrstoreone(struct mem_range_softc *sc);
 static struct mem_range_desc	*i686_mtrrfixsearch(struct mem_range_softc *sc,
 						    u_int64_t addr);
 static int			i686_mrsetlow(struct mem_range_softc *sc,
@@ -226,10 +233,6 @@
 static int
 i686_mrstore(struct mem_range_softc *sc)
 {
-    struct mem_range_desc	*mrd;
-    u_int64_t			msrv;
-    int				i, j, msr;
-    u_int			cr4save;
 
 #ifdef SMP
     /*
@@ -241,6 +244,17 @@
     return(EOPNOTSUPP);
 #endif
 
+    return(i686_mrstoreone(sc));
+}
+
+static int
+i686_mrstoreone(struct mem_range_softc *sc)
+{
+    struct mem_range_desc	*mrd;
+    u_int64_t			msrv;
+    int				i, j, msr;
+    u_int			cr4save;
+
     disable_intr();				/* disable interrupts */
     cr4save = rcr4();				/* save cr4 */
     if (cr4save & CR4_PGE)
@@ -477,7 +491,6 @@
 i686_mrinit(struct mem_range_softc *sc)
 {
     struct mem_range_desc	*mrd;
-    u_int64_t			mtrrcap, mtrrdef;
     int				nmdesc = 0;
     int				i;
 
@@ -491,8 +504,12 @@
 	return;
     }
     nmdesc = mtrrcap & 0xff;
-    printf("Pentium Pro MTRR support enabled, default memory type is %s\n",
-	   i686_mtrrtotext[mtrrdef & 0xff]);
+    printf("Pentium Pro MTRR support enabled, default memory type is ");
+    if ((mtrrdef & 0xff) < (sizeof(i686_mtrrtotext) / sizeof(i686_mtrrtotext[0]))) {
+	printf("%s\n", i686_mtrrtotext[mtrrdef & 0xff]);
+    } else {
+	printf("unknown (0x%x)\n", mtrrdef & 0xff);
+    }
 
     /* If fixed MTRRs supported and enabled */
     if ((mtrrcap & 0x100) && (mtrrdef & 0x400)) {
@@ -537,6 +554,17 @@
 	if (mrd->mr_flags & MDF_ACTIVE)
 	    mrd->mr_flags |= MDF_FIRMWARE;
     }
+}
+
+/*
+ * Initialise MTRRs on an AP after the BSP has run the init code.
+ */
+static void
+i686_mrAPinit(struct mem_range_softc *sc)
+{
+    i686_mrstoreone(sc);			/* set MTRRs to match BSP */
+    wrmsr(MSR_MTRRcap, mtrrcap);	/* set MTRR behaviour to match BSP */
+    wrmsr(MSR_MTRRdefType, mtrrdef);
 }
 
 static void
Index: i386/i386/mem.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/mem.c,v
retrieving revision 1.55
diff -u -r1.55 mem.c
--- mem.c	1999/04/07 03:57:45	1.55
+++ mem.c	1999/04/26 00:46:11
@@ -527,6 +527,12 @@
 	return(mem_range_softc.mr_op->set(&mem_range_softc, mrd, arg));
 }
 
+void
+mem_range_AP_init(void)
+{
+	return(mem_range_softc.mr_op->initAP(&mem_range_softc));
+}
+
 static int 
 random_ioctl(dev, cmd, data, flags, p)
 	dev_t dev;
Index: i386/i386/mp_machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/mp_machdep.c,v
retrieving revision 1.97
diff -u -r1.97 mp_machdep.c
--- mp_machdep.c	1999/04/13 03:24:47	1.97
+++ mp_machdep.c	1999/04/26 00:47:20
@@ -496,10 +496,7 @@
 	PTD[0] = 0;
 	pmap_set_opt((unsigned *)PTD);
 
-#if 0
-	putmtrr();
-	pmap_setvidram();
-#endif
+	mem_range_AP_init();		/* copy memory range attributes from the BSP */
 
 	invltlb();
 }
Index: sys/memrange.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/memrange.h,v
retrieving revision 1.1
diff -u -r1.1 memrange.h
--- memrange.h	1999/04/07 03:59:32	1.1
+++ memrange.h	1999/04/26 00:46:51
@@ -47,6 +47,7 @@
 {
 	void	(*init)(struct mem_range_softc *sc);
 	int	(*set)(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg);
+    	void	(*initAP)(struct mem_range_softc *sc);
 };
 
 struct mem_range_softc 
@@ -61,5 +62,6 @@
 
 extern void mem_range_attr_get(struct mem_range_desc *mrd, int *arg);
 extern int mem_range_attr_set(struct mem_range_desc *mrd, int *arg);
+extern void mem_range_AP_init(void);
 #endif
 

-- 
\\  Sometimes you're ahead,       \\  Mike Smith
\\  sometimes you're behind.      \\  mike@smith.net.au
\\  The race is long, and in the  \\  msmith@freebsd.org
\\  end it's only with yourself.  \\  msmith@cdrom.com




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904271949.MAA00904>