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.
This commit is contained in:
Bruce Evans 2018-06-02 10:36:30 +00:00
parent d10566cf49
commit fa49511709
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334529

View File

@ -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