From owner-svn-src-head@freebsd.org Sat Jun 2 10:36:31 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DA45BF7547B; Sat, 2 Jun 2018 10:36:31 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8D6A479D6F; Sat, 2 Jun 2018 10:36:31 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6AC686A5C; Sat, 2 Jun 2018 10:36:31 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w52AaV8m065581; Sat, 2 Jun 2018 10:36:31 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w52AaVNu065580; Sat, 2 Jun 2018 10:36:31 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201806021036.w52AaVNu065580@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Sat, 2 Jun 2018 10:36:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334529 - head/sys/dev/syscons X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/sys/dev/syscons X-SVN-Commit-Revision: 334529 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jun 2018 10:36:32 -0000 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