From nobody Sun Jun 04 17:17:56 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QZ3N45MRcz4ZN3f; Sun, 4 Jun 2023 17:17:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QZ3N44mPVz3y2v; Sun, 4 Jun 2023 17:17:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685899076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1tgjOSZtO6aeODv46ndyopEm5cOYq2RktOgKpOiZYV4=; b=cNmsnxBXO7bt+jNS8kLyjhEnHc89FsPEWsHXfb7nQf58+dQdUVYxApbjtEdvIPupLr2jds b0H0rBznUPpRW27DVry0yiOE1du1BpCjeMei1/BoU4a7Cdpgo9J10aPlPM5dL73KiBEb38 y07EQyE7k2C3c23VjQ0QnkDjNut/b/1jgYH2gT817Zg2bRSUXjgA1nGNT7eTuFAILojraC 8dfHqAloo8kOE/UdRsu3UYVOF8u/yxu+9ij0ahSYPmnzpDtDuF/8BYOvhF/g45NDujVwyv 5G6eYmts6ZnPqziTQcRY8uEeCUtFotBN59wCFhSodBnYFfJqF1LTBpJ2QtwbAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685899076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1tgjOSZtO6aeODv46ndyopEm5cOYq2RktOgKpOiZYV4=; b=rJCMhqtBlvxtHeH1/pHd7ckEP8DYb8Pht4BSCxZ/6cMIIBqYbzZ7ZpvbBE7cwwFiqP9XZk ZK9fbCbv/y/4x9ujShlCZfsE8Zb/mnHDp6lKcOe0Nq50hEmSVv2oCeeM8tm+T4lu6pgrVp QobaHbfpxUhJtJuBUPRi4sF5Z8YNNYZHGWyZaProSd68JwebBqO9nlB91E6ODQ9NGZT1qu VoN3fMtk57bwUsGZLaBHnhrcfJRw4UfJfDoxHs5bHKdKfc36HXsHQevRMGpxXpPZVaExzp txnwirEOdwVt3RjA2fbIN/1haheHU4P4Qy5hXVeBHm7IHGT207YtLioQPmkmNA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685899076; a=rsa-sha256; cv=none; b=jzlbYqEOzdYtkoLsJmb9pjni/5t1V8WUInxQs3Cvsh8Cra2rfhLMwVVnv67NpTMazNQTfP t15pKM4+dkfLx+He+BdkXRdigj1gmE0AtcKRmmQo28t4UL1X+2ik4RN5092APif2pejorI vX94bv9xNNDoTLkbycfun/vjMXtm62ZTXQSTUQX6JaNesR2rTEJYUeRntDbXPG/+SBVHIT 6APTmGB6DkG8LZFAeaT/PmtgqsgDW3gB3X+5SqAPe9AQHSq9HV4v0ZlN6ktsGDXJGZGn2q 2miL9KZJlm3ZRqJOKAArqXGU9MtgY1Xe1Oq6E+7UIFr6TNMGltItoGEsSbRwjw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QZ3N43kVSzF1T; Sun, 4 Jun 2023 17:17:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 354HHuQS009943; Sun, 4 Jun 2023 17:17:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 354HHuhf009942; Sun, 4 Jun 2023 17:17:56 GMT (envelope-from git) Date: Sun, 4 Jun 2023 17:17:56 GMT Message-Id: <202306041717.354HHuhf009942@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 02d90458669d - main - tslog: Handle curthread equal to NULL List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 02d90458669d6f8063ef32e35069e9246f487b37 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=02d90458669d6f8063ef32e35069e9246f487b37 commit 02d90458669d6f8063ef32e35069e9246f487b37 Author: Colin Percival AuthorDate: 2023-05-21 20:03:33 +0000 Commit: Colin Percival 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);