From 070d6e25632ca77f677dc7d17ef2970671cbb4fc Mon Sep 17 00:00:00 2001 From: bde Date: Sat, 2 Jun 2018 10:36:30 +0000 Subject: [PATCH] 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. --- sys/dev/syscons/syscons.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 4b5d46b9be6..92ed069b63c 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -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 -- 2.45.0