Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Jun 2018 10:36:31 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334529 - head/sys/dev/syscons
Message-ID:  <201806021036.w52AaVNu065580@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Sat Jun  2 10:36:30 2018
New Revision: 334529
URL: https://svnweb.freebsd.org/changeset/base/334529

Log:
  Use per-CPU attributes earlier.
  
  The per-CPU ts is not initialized early, so the global kernel ts is used
  early, but it ony has 1 (normal) attribute.  Switch this to the per-CPU
  attribute.
  
  The difference is most visible with EARLY_AP_STARTUP.
  
  Change to using the curcpu macro instead of PCPU_GET(cpuid) in 2 places for
  the above and in 1 other place in my old code in syscons.  The function-like
  spelling is perhaps better for indicating that curcpu is volatile (unlike
  curthread), but for CPU attributes volatility is a feature.

Modified:
  head/sys/dev/syscons/syscons.c

Modified: head/sys/dev/syscons/syscons.c
==============================================================================
--- head/sys/dev/syscons/syscons.c	Sat Jun  2 09:59:27 2018	(r334528)
+++ head/sys/dev/syscons/syscons.c	Sat Jun  2 10:36:30 2018	(r334529)
@@ -2023,18 +2023,27 @@ sc_cnputc(struct consdev *cd, int c)
 	    sizeof(sc_cnputc_log))
 	    continue;
 	/* Console output has a per-CPU "input" state.  Switch for it. */
-	oldtsw = scp->tsw;
-	oldts = scp->ts;
-	ts = sc_kts[PCPU_GET(cpuid)];
+	ts = sc_kts[curcpu];
 	if (ts != NULL) {
+	    oldtsw = scp->tsw;
+	    oldts = scp->ts;
 	    scp->tsw = sc_ktsw;
 	    scp->ts = ts;
 	    (*scp->tsw->te_sync)(scp);
+	} else {
+	    /* Only 1 tsw early.  Switch only its attr. */
+	    (*scp->tsw->te_default_attr)(scp, sc_kattrtab[curcpu],
+					 SC_KERNEL_CONS_REV_ATTR);
 	}
 	sc_puts(scp, buf, 1);
-	scp->tsw = oldtsw;
-	scp->ts = oldts;
-	(*scp->tsw->te_sync)(scp);
+	if (ts != NULL) {
+	    scp->tsw = oldtsw;
+	    scp->ts = oldts;
+	    (*scp->tsw->te_sync)(scp);
+	} else {
+	    (*scp->tsw->te_default_attr)(scp, SC_KERNEL_CONS_ATTR,
+					 SC_KERNEL_CONS_REV_ATTR);
+	}
     }
 
     s = spltty();	/* block sckbdevent and scrn_timer */
@@ -4177,7 +4186,7 @@ sc_kattr(void)
 {
     if (sc_console == NULL)
 	return (SC_KERNEL_CONS_ATTR);	/* for very early, before pcpu */
-    return (sc_kattrtab[PCPU_GET(cpuid) % nitems(sc_kattrtab)]);
+    return (sc_kattrtab[curcpu % nitems(sc_kattrtab)]);
 }
 
 static void



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