Date: Sun, 4 Jun 2023 17:17:56 GMT From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 02d90458669d - main - tslog: Handle curthread equal to NULL Message-ID: <202306041717.354HHuhf009942@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=02d90458669d6f8063ef32e35069e9246f487b37 commit 02d90458669d6f8063ef32e35069e9246f487b37 Author: Colin Percival <cperciva@FreeBSD.org> AuthorDate: 2023-05-21 20:03:33 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2023-06-04 17:16:22 +0000 tslog: Handle curthread equal to NULL Early in the kernel boot, curthread goes through three stages: 1. Kernel crash when you try to access it, because PCPU doesn't exist. 2. NULL, because PCU exists but isn't initialized. 3. &thread0, which is where most of the kernel boot process runs. This broke TSLOG from inside hammer_time since the scripts which parse logged records didn't understand that NULL meant &thread0. Tell tslog to record &thread0 as the active thread if passed NULL. Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D40324 --- sys/kern/kern_tslog.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/kern_tslog.c b/sys/kern/kern_tslog.c index 5eba7719880d..3629f7d88a93 100644 --- a/sys/kern/kern_tslog.c +++ b/sys/kern/kern_tslog.c @@ -59,6 +59,10 @@ tslog(void * td, int type, const char * f, const char * s) uint64_t tsc = get_cyclecount(); long pos; + /* A NULL thread is thread0 before curthread is set. */ + if (td == NULL) + td = &thread0; + /* Grab a slot. */ pos = atomic_fetchadd_long(&nrecs, 1);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202306041717.354HHuhf009942>